CLAUDE.md · langroid/langroid
CLAUDE.md from langroid/langroid: 295 lines covering Commands, Architecture, Documentation, MCP (Model Context Protocol) Tools Integration and more.
Template by langroid
Chalk Labs
Need help deploying CLAUDE.md · langroid/langroid?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/langroid/langroid/main/CLAUDE.md -o CLAUDE.md
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: prompt-engineering
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
A CLAUDE.md file: project memory Claude Code loads at the start of every session.
- For
- Claude Code
- Length
- 295 lines
- File
CLAUDE.md
Sections
- Commands
- Architecture
- Documentation
- MCP (Model Context Protocol) Tools Integration
- Testing and Tool Message Patterns
- Multi-Agent System Development
- Commit and Pull Request Guidelines
- Codecov Badge Fix (June 2025)
First lines (shown under the repo's MIT license)
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Commands
### Development
- Install core dependencies: `pip install -e .`
- Install dev dependencies: `pip install -e ".[dev]"`
- Install specific feature groups:
- Document chat features: `pip install -e ".[doc-chat]"`
- Database features: `pip install -e ".[db]"`
- HuggingFace embeddings: `pip install -e ".[hf-embeddings]"`
- All features: `pip install -e ".[all]"`
- Run linting and type checking: `make check`
- Format code: `make lint`
### Testing
- Run all tests: `pytest tests/`
- Run specific test: `pytest tests/main/test_file.py::test_function`
- Run tests with coverage: `pytest --cov=langroid tests/`
- Run only main tests: `make tests` (uses `pytest tests/main`)
### Linting and Type Checking
- Lint code: `make check` (runs black, ruff check, mypy)
- Format only: `make lint` (runs black and ruff fix)
- Type check only: `make type-check`
- Always use `make check` to run lints + mypy before trying to commit changes
### Version and Release Management
- Bump version: `./bump_version.sh [patch|minor|major]`
- Or use make commands:
- `make all-patch` - Bump patch version, build, push, release
- `make all-minor` - Bump minor version, build, push, release
- `make all-major` - Bump major version, build, push, release
## Architecture
Langroid is a framework for building LLM-powered agents that can use tools and collaborate with each other.
### Core Components:
1. **Agents** (`langroid/agent/`):
- `chat_agent.py` - Base ChatAgent that can converse and use tools
- `task.py` - Handles execution flow for agents
- `special/` - Domain-specific agents (doc chat, table chat, SQL chat, etc.)
2. **Tools** (`langroid/agent/tools/`):
- Tool system for agents to interact with external systems
- `tool_message.py` - Protocol for tool messages
- Various search tools (Google, DuckDuckGo, Tavily, Exa, etc.)
3. **Language Models** (`langroid/language_models/`):
- Abstract interfaces for different LLM providers
- Implementations for OpenAI, Azure, local models, etc.
- Support for hundreds of LLMs via LiteLLM
4. **Vector Stores** (`langroid/vector_store/`):
- Abstract interface and implementations for different vector databases
- Includes support for Qdrant, Chroma, LanceDB, Pinecone, PGVector, Weaviate
5. **Document Processing** (`langroid/parsing/`):
- Parse and process documents from various formats
- Chunk text for embedding and retrieval
- Support for PDF, DOCX, images, and more
6. **Embedding Models** (`langroid/embedding_models/`):
- Abstract interface for embedding generation
- Support for OpenAI, HuggingFace, and custom embeddings
### Key Multi-Agent Patterns:
- **Task Delegation**: Agents can delegate tasks to other agents through hierarchical task structures
- **Message Passing**: Agents communicate by transforming and passing messages
- **Collaboration**: Multiple agents can work together on complex tasks
### Key Security Features:
- The `full_eval` flag in both `TableChatAgentConfig` and `VectorStoreConfig` controls code injection protection
- Defaults to `False` for security, set to `True` only in trusted environments
## Documentation
- Main documentation is in the `docs/` directory
- Examples in the `examples/` directory demonstrate usage patterns
- Quick start examples available in `examples/quick-start/`
## MCP (Model Context Protocol) Tools Integration
Langroid provides comprehensive support for MCP tools through the `langroid.agent.tools.mcp` module. Here are the key patterns and approaches:
### MCP Tool Creation Methods
#### 1. Using the `@mcp_tool` Decorator (Module Level)
```python
from langroid.agent.tools.mcp import mcp_tool
from fastmcp.client.transports import StdioTransport
transport = StdioTransport(command="...", args=[...])
@mcp_tool(transport, "tool_name")
class MyTool(lr.ToolMessage):
async def handle_async(self):
result = await self.call_tool_async()
# custom processing
return result
```
**Important**: The decorator creates the transport connection at module import time, so it must be used at module level (not inside async functions).
#### 2. Using `get_tool_async` (Inside Async Functions)
```python
from langroid.agent.tools.mcp.fastmcp_client import get_tool_async
async def main():
transport = StdioTransport(command="...", args=[...])
BaseTool = await get_tool_async(transport, "tool_name")
class MyTool(BaseTool):
async def handle_async(self):
result = await self.call_tool_async()
# custom processing
return result
```
**Use this approach when**:
- Creating tools inside async functions
- Need to avoid event loop conflicts
- Want to delay transport creation until runtime
### Transport Types and Event Loop Considerations
- **StdioTransport**: Creates subprocess immediately, can cause "event loop closed" errors if created at module level in certain contexts
- **SSETransport**: HTTP-based, generally safer for module-level creation
- **Best Practice**: Create transports inside async functions when possible, use `asyncio.run()` wrapper for Fire CLI integration
### Tool Message Request Field and Agent Handlers
When you get an MCP tool named "my_tool", Langroid automatically:
1. **Sets the `request` field**: The dynamically created ToolMessage subclass has `request = "my_tool"`
2. **Enables custom agent handlers**: Agents can define these methods:
- `my_tool()` - synchronous handler
- `my_tool_async()` - async handler
The agent's message routing system automatically calls these handlers when the tool is used.
### Custom `handle_async` Method Override
Both decorator and non-decorator approaches support overriding `handle_async`:
```python
class MyTool(BaseTool): # or use @mcp_tool decorator
async def handle_async(self):
# Get raw result from MCP server
result = await self.call_tool_async()
# Option 1: Return processed result to LLM (continues conversation)
return f"<ProcessedResult>{result}</ProcessedResult>"Signals
- Stars
- 4,120
- Forks
- 428
- Open issues
- 43
- Last commit (this folder)
- Sep 16, 2026 (1 month ago)
- Last release
- Oct 24, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/langroid/langroid
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get CLAUDE.md · langroid/langroid running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
CLAUDE.md · langroid/langroid. Agent Mart. https://agentmart.dev/templates/langroid-langroid-claude-md (last updated 2026-10-24)