patterns
Design patterns for the Langroid multi-agent LLM framework. Covers agent configuration, tools, task control, and integrations.
Install
mkdir -p .claude/skills/patterns && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2668" && unzip -o skill.zip -d .claude/skills/patterns && rm skill.zipInstalls to .claude/skills/patterns
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:
More by langroid
View all skills by langroid →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversUnlock seamless Figma to code: streamline Figma to HTML with Framelink MCP Server for fast, accurate design-to-code work
Access shadcn/ui v4 components, blocks, and demos for rapid React UI library development. Seamless integration and sourc
Automate your figma to code workflow. Convert Figma designs to HTML, extract SVGs, analyze color, and generate CSS with
Access Tyler Forge’s design system, React UI library, component APIs, and framework guides for seamless app development
MoziChem offers process design with flash calculations and equation of state models like Soave Redlich Kwong and van der
Boost your AI code assistant with Context7: inject real-time API documentation from OpenAPI specification sources into y
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.