一键导入
local-agent-builder
Complete blueprint, constraints, and scaffolding for building agentic workflows optimized for local LLMs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Complete blueprint, constraints, and scaffolding for building agentic workflows optimized for local LLMs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | local-agent-builder |
| description | Complete blueprint, constraints, and scaffolding for building agentic workflows optimized for local LLMs. |
You are instructed to build agentic workflows specifically optimized for Local LLMs (e.g., Qwen 3.5, Gemma-4). Your primary objective is strict context management, low memory bandwidth utilization, and robust parsing of LLM outputs on constrained hardware.
You MUST use Microsoft's agent-framework to implement these tasks.
You must rigorously adhere to the blueprints mapped out in the resources/docs/ directory.
Familiarize yourself with and deploy the exact recipes documented below.
You will find the scaffold project and documentation for how to create agents in the examples and resources subfolders of this skill. DO NOT edit or touch the files inside these folders. These are strictly read-only references for you.
MANDATORY CHECKLIST: Before presenting any
implementation_plan.mdor completing your final code generation, you MUST explicitly evaluate your work against CHECKLIST.md — TWICE:
- First pass (after writing
implementation_plan.md): Verify structural correctness — scaffold integrity (§1), sub-agent delegation (§2), tool quotas (§3), and optional extensions (§4).- Second pass (after writing final code): Verify data-flow integrity — agent-ID routing in prompts, filename propagation between parent/child agents, and tool consistency with the delegation model (§5: Multi-Tier Data Flow Validation).
CRITICAL PATH RESOLUTION FOR AI AGENTS: Since this skill may be loaded from a global skills directory (e.g.,
~/opencode/skills/) or local skills directory (e.g.,.opencode/skills/), all file paths mentioned below (likeresources/...andexamples/...) are relative to the folder containing thisSKILL.mdfile. You MUST resolve these to their absolute paths usingSKILL.md's location before using your tools to list, read, or copy them. Do not assume they are in the current working directory.
[!TIP] CONTEXT MANAGEMENT: AVOID READING ALL DOCS AT ONCE. Your context window is limited! Do not blindly read every
.mddocument in theresources/docs/folder. Usually, you only need to readARCHITECTURE.mdandIMPLEMENTATION.mdand possiblyTOOLS.md. Skip documents likeSHELL.mdorMAILBOX.mdunless the user explicitly requests those specific advanced capabilities.
MANDATORY STARTING STEPS FOR BUILDING NEW APPLICATIONS:
examples/basic-tui-agent/ directory to the current project directory as your primary starting point, and read its README.md. Never start from scratch or build a custom directory structure.
pyproject.toml for adding new dependencies. Do not create a requirements.txt file.name field in the [project] block of the copied pyproject.toml to reflect the agent you are building (e.g., name = "local-research-agent").[project.scripts] block in the copied pyproject.toml to name the system-wide executable command after the agent you are building (e.g. local-research-agent = "src.app:cli_main").pipx install . in the final README.md.sasori daemon (pipx install ./packages/sasori). Do NOT write from-scratch polling logic. Instead, write an [agent_name]_plugin.py file inheriting from sasori.handler.BaseMailboxHandler, and instruct the user to place it in their ~/.sasori/handlers/ directory. Remind the user they'll need to restart the sasori daemon.[!CAUTION] STRICT REUSE DIRECTIVE: DO NOT REWRITE FROM SCRATCH OR INVENT PATTERNS. You are explicitly forbidden from rewriting the core scaffold architecture. Your task is to perform LIGHT MODIFICATIONS to the provided
basic-tui-agentfiles.
- Always start by copying the basic scaffold to the current project directory. Do not write new orchestrators or custom setup files from scratch.
- Modify as little as possible of the scaffold—it works like a charm! The baseline loop, TUI system, and orchestration engine are robust and ready out-of-the-box. Avoid unnecessary refactoring or "improvement" of the existing code.
- DO NOT rewrite existing tools from scratch: Assume that if a tool exists in the scaffold (e.g., in
src/tools/), it does not require editing or only requires minor edits. Review the tool implementation and associated docs to see if it can just be used without modification, and prioritize that. If you are rewriting an entire tool that already exists, you are likely getting it wrong. Keep modifications to the absolute minimum. If modification is needed, check existing docs, guidelines, and source comments for hints on how to modify it, rather than inventing your own logic.- Preserve required engine imports/variables: The core engine (
src/engine/) imports specific variables and constants from customization files (such asORCHESTRATOR_INSTRUCTIONS,SUBAGENT_INSTRUCTIONS, andSUBAGENT_DELEGATION_INSTRUCTIONSfromsrc/prompts.py). NEVER rename, delete, or modify these variables directly without keeping the original variable names as aliases (e.g.,SUBAGENT_INSTRUCTIONS = SEARCH_SUBAGENT_INSTRUCTIONS). Doing so causes fatalImportErrorcrashes at startup.- NEVER pre-format prompts in src/app.py: Do not call
.format()on system prompt strings (such asORCHESTRATOR_INSTRUCTIONSorSUBAGENT_INSTRUCTIONS) insidesrc/app.py. Pass raw, unformatted strings to theAgentBuilderandSubAgentConfigconstructors; the orchestration engine formats runtime placeholders (like{date}or{task_name}) dynamically. Pre-formatting them at startup will throw aKeyErrorbecause runtime variables are not yet available at startup.- Focus edits strictly on customization files (mainly
src/app.pyandsrc/prompts.py): The primary aim of this skill is to translate the user-requested agent and subagent structure intosrc/app.pyandsrc/prompts.py, and update the relatedREADME.md,pyproject.toml, and config YAML (src/config_template.yaml). MOST of your edits should be contained within these specific files to configure the required agent and subagent structure.- One prompt per sub-agent type in
prompts.py(CRITICAL): When the user requests multiple sub-agent types (e.g. Searcher + Analyzer), you MUST create a separate prompt constant for each one (e.g.,SEARCH_SUBAGENT_INSTRUCTIONS,ANALYZER_SUBAGENT_INSTRUCTIONS). Do NOT reuse a single genericSUBAGENT_INSTRUCTIONSfor all sub-agent types. Do NOT try to be clever by sharing, conditionally formatting, or composing a shared prompt across roles. Each sub-agent type gets its own fully self-contained prompt. KeepSUBAGENT_INSTRUCTIONSas a backward-compatibility alias pointing to one of them.- Selective tool lists per sub-agent in
app.py(CRITICAL): EachSubAgentConfigMUST have a selective tool list. Import individual tools fromtoolsand pass only the ones that sub-agent needs. Do NOT assignWORKSPACE_TOOLSto every agent. Tool separation is what FORCES delegation — if a parent agent has the tools its child is supposed to use, the LLM will use them directly and never delegate. SeeARCHITECTURE.md§2 for the exact code pattern.- Minimize tool edits: While you might occasionally need to edit a tool's implementation, this should be minimal—mostly config adjustments or swapping specific code snippets as guided by docs and comment hints. Full rewrites of existing tool code are not recommended and will break the application.
- Avoid editing the core engine unless absolutely necessary: The
src/engine/directory handles all the complex Textual TUI and background thread orchestration. In 99% of cases you should NOT need to modify it — look for config toggles (config_template.yaml), format variables, or SDK parameters first. Only make minimal, targeted edits to engine files when there is genuinely no config-driven or SDK-level alternative.- Never invent or hallucinate architectures. If a feature is needed, the required pattern is almost certainly already established inside the
resources/docs/documents or as exemplary code within the scaffold.- Read the code, mimic its native structural patterns exactly, and only inject the specific business logic the user requested.
src/app.py! The orchestration engine already natively supports nested sub-agent delegation out-of-the-box. NEVER edit src/engine/orchestrator.py to add delegation support or custom format variables. Each SubAgentConfig declares its own children via sub_agents=[...] to form a scoped delegation chain — the engine only injects delegate_tasks into agents that have children, and each agent can only see its own declared children. The engine auto-populates prompt format variables for ALL agents (orchestrator + sub-agents): {date}, {workspace_dir}, {task_name} (sub-agents only), {delegation_instructions}, and all quota keys as {tool_name_quota} from config. The engine uses a safe formatter — unknown keys stay as literal text instead of crashing.)<think> tag scraping, TUI integrations, and Headless CLI (--prompt, --auto-approve, --resume) batch processing. Includes rules on deleting (pruning) optional features like markitdown parsers or web_search to save context if unneeded.run_shell_command from the scaffold if unused, unless the user specifically demands bash or compilation capabilities!)OptionList dropdown components and the collapsible workspace file viewers natively triggered via /files commands (dynamically reads from in-memory or on-disk based on config.yaml).src/prompts.py are pre-optimized templates. You must retain all formatting variables like {task_name} or {date} in custom instructions. If you strip {task_name}, sub-agents run blindly. Ensure the orchestrator's instructions explicitly command it to analyze the user query, break it down into specific tasks, and propagate them to the sub-agents!)eval/ harness for any agent you create. The scaffold ships with a generic evaluate.py and eval_config.yaml template in examples/basic-tui-agent/eval/. Agents are scored by running them headlessly and checking their output (stdout or a named workspace artifact) against criteria using one of three strategies: contains, regex, or llm_judge. Only read this if the user asks for evaluation or benchmarking of the built agent.You should search through and read the official Microsoft agent-framework documentation and samples before guessing APIs or mechanisms:
Agent Framework Examples (Search inside these web URLs or even pull the entire github repo is you need to have stuff locally that you can inspect):
https://github.com/microsoft/agent-framework/tree/main/python/samples/02-agents/https://github.com/microsoft/agent-framework/tree/main/python/samples/03-workflows/ (specifically checkpoint/ and control-flow/ examples)External Web Documentation: