patterns
Provides structural patterns for the Langroid framework, including task initialization, tool handlers, and validation.
Install
mkdir -p .claude/skills/patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2668" && unzip -o skill.zip -d .claude/skills/patterns && rm skill.zipInstalls to .claude/skills/patterns
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Design patterns for the Langroid multi-agent LLM framework. CoversKey capabilities
- →Implement stateful tool handlers
- →Validate agent outputs against state
- →Manage multi-agent task flows
- →Integrate MCP tools
- →Run concurrent batch tasks
How it works
The skill provides a library of design patterns for the Langroid framework, enabling developers to structure agents, tools, and task control logic.
Inputs & outputs
When to use patterns
- →Creating agents with direct tool returns
- →Implementing stateful tool handlers for API calls
- →Validating agent outputs
- →Managing multi-agent task flows
About this skill
Langroid Patterns
Instructions
Below 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.
Agent & Task Basics
-
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.
- Reference:
./task-return-tool.md
- Reference:
Tool Handlers
-
Stateful 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
requestfield of the ToolMessage. Return a string for errors (LLM sees it and can retry), or DoneTool(content=result) to terminate successfully.- Reference:
./agent-tool-handler-with-state.md
- Reference:
-
Handler 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.- Reference:
./agent-handler-validation-with-state.md
- Reference:
Task Control
-
Terminate 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, orTaskConfig(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.- Reference:
./done-sequences-specific-tool.md
- Reference:
-
Batch 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.- Reference:
./run-batch-tasks.md
- Reference:
Integration & Output
-
MCP 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_tooldecorator for specific tools orget_tools_async()for all tools.- Reference:
./mcp-tool-integration.md
- Reference:
-
Quiet 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.- Reference:
./quiet-mode.md
- Reference:
When not to use it
- →When building simple scripts without agentic requirements
Limitations
- →Specific to the Langroid framework
How it compares
It provides standardized architectural patterns for complex multi-agent systems rather than requiring custom implementation of state and task logic.
Compared to similar skills
patterns side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| patterns (this skill) | 2 | 7mo | No flags | Advanced |
| copilot-sdk | 7 | 3mo | Review | Intermediate |
| guidance | 3 | 7mo | Review | Intermediate |
| adk-engineer | 3 | 25d | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by langroid
View all by langroid →You might also like
copilot-sdk
github
Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.
guidance
davila7
Control LLM output with regex and grammars, guarantee valid JSON/XML/code generation, enforce structured formats, and build multi-step workflows with Guidance - Microsoft Research's constrained generation framework
adk-engineer
jeremylongshore
Execute software engineer specializing in creating production-ready ADK agents with best practices, code structure, testing, and deployment automation. Use when asked to "build ADK agent", "create agent code", or "engineer ADK application". Trigger with relevant phrases based on skill purpose.
llm-application-dev
skillcreatorai
Building applications with Large Language Models - prompt engineering, RAG patterns, and LLM integration. Use for AI-powered features, chatbots, or LLM-based automation.
agentica-spawn
parcadei
Spawn Agentica multi-agent patterns
fine-tuning-with-trl
davila7
Fine-tune LLMs using reinforcement learning with TRL - SFT for instruction tuning, DPO for preference alignment, PPO/GRPO for reward optimization, and reward model training. Use when need RLHF, align model with preferences, or train from human feedback. Works with HuggingFace Transformers.