====== Langroid ====== **Langroid** is an open-source Python framework for building multi-agent LLM applications that treats agents as first-class citizens capable of collaborating through hierarchical task delegation and structured message passing.(([[https://[[github|github]])).com/langroid/langroid|github.com/langroid/langroid]])) Created with a focus on developer ergonomics, Langroid provides a clean, code-driven abstraction where each agent wraps an LLM along with optional tools and vector stores. * **[[github|GitHub]]:** [[https://github.com/langroid/langroid|github.com/langroid/langroid]] * **License:** MIT * **Language:** Python ===== Architecture ===== Langroid's core design centers on two key abstractions: **Agents:** First-class objects encapsulating LLM conversation state, memory (via vector stores), and tools. Each agent maintains its own context and can be specialized for particular tasks. **Tasks:** Wrappers around agents that define specific instructions and enable hierarchical, recursive delegation. Tasks can spawn subtasks and delegate work to other agent-task pairs, forming collaborative workflows. Key architectural features: * **Hierarchical delegation:** Agents can recursively delegate subtasks to other agents, forming tree-structured workflows * **Pydantic-based tool calling:** [[structured_outputs|Structured outputs]] with automatic validation and error handling * **Vector store integration:** Built-in support for [[qdrant|Qdrant]], Chroma, and LanceDB for RAG capabilities * **Knowledge graph support:** Integration with [[neo4j|Neo4j]] and ArangoDB for graph-based reasoning * **LLM flexibility:** Compatible with any LLM ([[openai|OpenAI]], [[anthropic|Anthropic]], local models, open-source via API) * **Redis caching:** Prompt/response caching for performance optimization * **Message provenance:** Detailed logging with source tracking for debugging and observability ===== Python Example ===== import langroid as lr from langroid.agent.tools.orchestration import DoneTool # Configure the LLM (works with [[openai|OpenAI]], [[anthropic|Anthropic]], local models) llm_config = lr.language_models.OpenAIGPTConfig( chat_model="[[openai|openai]]/gpt-4o", ) # Create a research agent with specific instructions researcher_config = lr.ChatAgentConfig( name="Researcher", llm=llm_config, system_message="You research topics and provide detailed factual summaries.", ) researcher = lr.ChatAgent(researcher_config) # Create a writer agent that refines research into polished text writer_config = lr.ChatAgentConfig( name="Writer", llm=llm_config, system_message="You take research notes and write clear, engaging prose.", ) writer = lr.ChatAgent(writer_config) # Wrap agents in Tasks for orchestration researcher_task = lr.Task(researcher, interactive=False) writer_task = lr.Task(writer, interactive=False) # The writer delegates research subtasks to the researcher writer_task.add_sub_task(researcher_task) # Run the pipeline: writer receives a goal and delegates as needed result = writer_task.run( "Write a brief overview of how HNSW graphs work for vector search." ) print(result) ===== Use Cases ===== Langroid excels in scenarios requiring fine-grained multi-agent collaboration: * **Advanced RAG:** Knowledge bases with cited answers from documents * **Business intelligence:** Automated data queries, SQL integration, and workflow automation * **Complex problem-solving:** Strategic planning, diagnostics, multi-step reasoning * **AI-driven development:** Code generation, analysis, and security auditing * **Debate platforms:** Multi-agent setups with dynamic agent parameterization for structured discussions ===== Langroid vs CrewAI vs AutoGen ===== ^ Feature ^ Langroid ^ [[crewai|CrewAI]] ^ [[autogen|AutoGen]] ^ | **Interface** | Code-only (no GUI) | Orchestration-focused, integrable | [[conversational_agents|Conversational agents]] | | **Focus** | Custom multi-agent hierarchies | Production agent fleets | Research-oriented conversations | | **Customization** | Full Python extensibility | Plugin marketplace, easier setup | Flexible conversation patterns | | **Best For** | Developers/researchers needing fine control | Teams deploying agent workflows | Conversational multi-agent research | | **Vendor** | Open-source community | [[crewai|CrewAI]] Inc. | [[microsoft|Microsoft]] | Choose Langroid when you need full control over agent hierarchies, task delegation logic, and integrations without a GUI layer. Choose [[crewai|CrewAI]] for production orchestration with monitoring, or [[autogen|AutoGen]] for conversational multi-agent patterns. ===== See Also ===== * [[xagent|XAgent: Autonomous LLM Agent for Complex Tasks]] * [[metagpt|MetaGPT: Multi-Agent Framework with SOP-Based Collaboration]] * [[langgraph|LangGraph]] * [[agentverse|AgentVerse: Facilitating Multi-Agent Collaboration]] * [[managed_agents_vs_agent_sdk|Managed Agents vs Agent SDK]] ===== References ===== ===== Related Pages ===== * [[crewai|CrewAI]] * [[autogen|AutoGen]] * [[multi_agent_systems|Multi-Agent Systems]] * [[retrieval_augmented_generation|Retrieval-Augmented Generation]]