Design patterns for the Langroid multi-agent LLM framework. Covers agent configuration, tools, task control, and integrations.
Provides Langroid multi-agent framework design patterns for agent configuration, tools, task control, and MCP integrations. Use when building complex LLM workflows that need structured agents, stateful tool handlers, batch processing, or Claude Code tool integration.
/plugin marketplace add langroid/langroid/plugin install langroid-langroid-plugins-langroid@langroid/langroidThis skill inherits all available tools. When active, it can use any tool Claude has access to.
agent-handler-validation-with-state.mdagent-tool-handler-with-state.mddone-sequences-specific-tool.mdmcp-tool-integration.mdquiet-mode.mdrun-batch-tasks.mdtask-return-tool.mdBelow is an INDEX of design patterns organized by category. Each item describes WHAT you might want to implement, followed by a REFERENCE to a document with a complete code example.
Scan this index to find patterns matching your needs, then consult the corresponding document.
Task Returns Tool Directly
Create a Langroid Agent equipped with a single Tool (a ToolMessage), and wrap it in a Task so that running the task returns that ToolMessage directly. Use this pattern when you want a simple LLM agent that returns a structured response.
./task-return-tool.mdStateful Handler on Agent
Define a STATEFUL tool handler as a METHOD on the agent (not inside the
ToolMessage). Use this pattern when: (a) the tool handler needs to execute
external operations (API calls, database queries, file I/O), (b) you need to
track state across retries (e.g., failure counter), (c) the handler needs
access to agent-level resources (connections, configs), or (d) you want
Langroid to automatically loop errors back to the LLM for self-correction.
The method name must match the request field of the ToolMessage. Return a
string for errors (LLM sees it and can retry), or DoneTool(content=result)
to terminate successfully.
./agent-tool-handler-with-state.mdHandler with Validation
Validate tool output against agent state before accepting it. Use this
pattern when: (a) the LLM's tool output must preserve certain content from
the input (e.g., placeholders, required fields), (b) you want automatic
retry if validation fails, (c) you need to compare tool output against
context the LLM received. Define a handler method on a custom agent class
that stores the input context as state, validates the tool output, and
returns an error string for retry or AgentDoneTool for success (note: use
AgentDoneTool, NOT DoneTool). Use done_sequences=["T[ToolName], A"] so the
handler runs before task termination.
./agent-handler-validation-with-state.mdTerminate on Specific Tool
Terminate a Task only when a SPECIFIC tool is called. Use
TaskConfig(done_sequences=["T[ToolName]"]) to exit immediately when that
tool is emitted, or TaskConfig(done_sequences=["T[ToolName], A"]) to exit
after the tool is emitted AND handled by the agent. Use this when an agent
has multiple tools but you only want one specific tool to trigger task
termination.
./done-sequences-specific-tool.mdBatch Processing
Run the SAME task on MULTIPLE inputs concurrently using run_batch_tasks().
Use this pattern when: (a) you need to process many items with the same
agent/task logic, (b) you want parallelism without manual asyncio/threading,
(c) you need state isolation between items (each gets a cloned agent with
fresh message history), (d) you want to avoid connection exhaustion from
creating too many agents manually. Each item gets a cloned task+agent, runs
independently, results collected in order. Supports batch_size for
concurrency limiting.
./run-batch-tasks.mdMCP Tools Integration
Enable a Langroid agent to use MCP (Model Context Protocol) tools from an
external MCP server like Claude Code. Use this pattern when: (a) you want
your agent to use file editing tools (Read, Edit, Write) from Claude Code,
(b) you need to connect to any MCP server via stdio transport, (c) you want
to enable ALL tools from an MCP server or just SPECIFIC tools selectively,
(d) you want to customize/post-process MCP tool results before returning to
the LLM. Uses @mcp_tool decorator for specific tools or get_tools_async()
for all tools.
./mcp-tool-integration.mdQuiet Mode
Suppress verbose Langroid agent output (streaming, tool JSON, intermediate
messages) while showing your own custom progress messages. Use this pattern
when: (a) you want clean CLI output showing only milestone events, (b) you're
running a multi-step workflow and want to show progress without agent noise,
(c) you need thread-safe output control. Use quiet_mode() context manager
to wrap agent task.run() calls, then print your own messages outside the
context.
./quiet-mode.mdThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.