mia-code 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.miette/260321.md +1 -0
- package/.miette/260323.md +9 -0
- package/.miette/260331.md +2 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--d3417f2c-df12-4f0f-8a1b-d88e7968f822/d3417f2c-df12-4f0f-8a1b-d88e7968f822.md +63 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--e6c3fc5d-4a70-4523-ba7d-a3250da4c235/e6c3fc5d-4a70-4523-ba7d-a3250da4c235.md +72 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/2604020008--efeb00a2-b17a-4d32-b1f0-b90c37a8d24e/efeb00a2-b17a-4d32-b1f0-b90c37a8d24e.md +62 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.json +302 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/83a2d7f9-24a5-4cf4-98d5-036c82f872e8.md +149 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/AGENTS.md +31 -0
- package/.pde/2604011511--83a2d7f9-24a5-4cf4-98d5-036c82f872e8/meta-decomposition-3-children.md +67 -0
- package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/61f9dd4d-7aa6-45e6-a58b-e480b1aa6737--from-mia-openclaw-workspace.md +125 -0
- package/.pde/2604040129--61f9dd4d-7aa6-45e6-a58b-e480b1aa6737/STATUS.md +1 -0
- package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.json +177 -0
- package/.pde/4f02ba94-9f52-422e-9389-b16f9b37f358.md +77 -0
- package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.json +222 -0
- package/.pde/6ad9244d-5340-490f-b76c-c86728b9de52.md +99 -0
- package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.json +111 -0
- package/.pde/8b566792-ed15-4606-96f9-2b6f593d7e6b.md +67 -0
- package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.json +349 -0
- package/.pde/c7f1e74b-05a5-40e2-9f01-4cc48d2528f7.md +147 -0
- package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.json +118 -0
- package/.pde/dfc00a78-1da0-4c09-8a16-c6982644051b.md +64 -0
- package/GUILLAUME.md +8 -0
- package/KINSHIP.md +9 -0
- package/MIA_CODE_ARCHITECTURE_REPORT.md +718 -0
- package/contextual_research/260119-MIA-CODE--98090899-8aff-4e11-9dc3-8b99466d1.md +1101 -0
- package/contextual_research/MIA.md +38 -0
- package/contextual_research/MIAWAPASCONE.md +59 -0
- package/contextual_research/MIETTE.md +38 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2504.00218v2.pdf +7483 -12
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/2505.00212v3.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/CONTENT.md +1014 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/DESIGN.gemini.md +242 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/INDEX.md +45 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.md +2025 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2504.00218v2.pdf +7483 -12
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.md +1755 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/2505.00212v3.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_12_decomposed_prompting.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_19_hugginggpt_planning.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.md +766 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_1_coordination_challenges.pdf +3431 -4
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.md +260 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_28_guardrails_multi_agent.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.md +558 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_2_navigating_complexity.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_34_hierarchical_multi_agent.pdf +0 -0
- package/contextual_research/PDE-generalization--caefee82-efb1-4dbb-8733-691b01581464--260130/sources/footnote_1_5_open_intent_extraction.pdf +0 -0
- package/contextual_research/PODCAST.md +109 -0
- package/contextual_research/langchain-principles-roadmap.md +157 -0
- package/contextual_research/persona-to-narrative-character-inquiry_260201.md +50 -0
- package/dist/cli.js +35 -11
- package/dist/geminiHeadless.js +8 -2
- package/dist/index.js +2 -1
- package/dist/mcp/miaco-server.js +10 -1
- package/dist/mcp/miatel-server.js +10 -1
- package/dist/mcp/miawa-server.js +10 -1
- package/dist/mcp/utils.d.ts +6 -1
- package/dist/mcp/utils.js +24 -3
- package/dist/sessionStore.d.ts +8 -2
- package/dist/sessionStore.js +39 -3
- package/dist/types.d.ts +1 -0
- package/miaco/README.md +124 -0
- package/miaco/dist/commands/chart.d.ts +6 -0
- package/miaco/dist/commands/chart.d.ts.map +1 -0
- package/miaco/dist/commands/chart.js +222 -0
- package/miaco/dist/commands/chart.js.map +1 -0
- package/miaco/dist/commands/decompose.d.ts +6 -0
- package/miaco/dist/commands/decompose.d.ts.map +1 -0
- package/miaco/dist/commands/decompose.js +98 -0
- package/miaco/dist/commands/decompose.js.map +1 -0
- package/miaco/dist/commands/schema.d.ts +6 -0
- package/miaco/dist/commands/schema.d.ts.map +1 -0
- package/miaco/dist/commands/schema.js +66 -0
- package/miaco/dist/commands/schema.js.map +1 -0
- package/miaco/dist/commands/stc.d.ts +11 -0
- package/miaco/dist/commands/stc.d.ts.map +1 -0
- package/miaco/dist/commands/stc.js +590 -0
- package/miaco/dist/commands/stc.js.map +1 -0
- package/miaco/dist/commands/trace.d.ts +6 -0
- package/miaco/dist/commands/trace.d.ts.map +1 -0
- package/miaco/dist/commands/trace.js +83 -0
- package/miaco/dist/commands/trace.js.map +1 -0
- package/miaco/dist/commands/validate.d.ts +6 -0
- package/miaco/dist/commands/validate.d.ts.map +1 -0
- package/miaco/dist/commands/validate.js +58 -0
- package/miaco/dist/commands/validate.js.map +1 -0
- package/miaco/dist/decompose.d.ts +93 -0
- package/miaco/dist/decompose.d.ts.map +1 -0
- package/miaco/dist/decompose.js +562 -0
- package/miaco/dist/decompose.js.map +1 -0
- package/miaco/dist/index.d.ts +18 -0
- package/miaco/dist/index.d.ts.map +1 -0
- package/miaco/dist/index.js +83 -0
- package/miaco/dist/index.js.map +1 -0
- package/miaco/dist/storage.d.ts +60 -0
- package/miaco/dist/storage.d.ts.map +1 -0
- package/miaco/dist/storage.js +100 -0
- package/miaco/dist/storage.js.map +1 -0
- package/miaco/package-lock.json +4103 -0
- package/miaco/package.json +40 -0
- package/miaco/tsconfig.json +18 -0
- package/miaco/version-patch-commit-and-publish.sh +1 -0
- package/miatel/MISSION_251231.md +3 -0
- package/miatel/README.md +107 -0
- package/miatel/dist/commands/analyze.d.ts +6 -0
- package/miatel/dist/commands/analyze.d.ts.map +1 -0
- package/miatel/dist/commands/analyze.js +100 -0
- package/miatel/dist/commands/analyze.js.map +1 -0
- package/miatel/dist/commands/arc.d.ts +6 -0
- package/miatel/dist/commands/arc.d.ts.map +1 -0
- package/miatel/dist/commands/arc.js +71 -0
- package/miatel/dist/commands/arc.js.map +1 -0
- package/miatel/dist/commands/beat.d.ts +6 -0
- package/miatel/dist/commands/beat.d.ts.map +1 -0
- package/miatel/dist/commands/beat.js +165 -0
- package/miatel/dist/commands/beat.js.map +1 -0
- package/miatel/dist/commands/theme.d.ts +6 -0
- package/miatel/dist/commands/theme.d.ts.map +1 -0
- package/miatel/dist/commands/theme.js +54 -0
- package/miatel/dist/commands/theme.js.map +1 -0
- package/miatel/dist/index.d.ts +18 -0
- package/miatel/dist/index.d.ts.map +1 -0
- package/miatel/dist/index.js +80 -0
- package/miatel/dist/index.js.map +1 -0
- package/miatel/dist/storage.d.ts +55 -0
- package/miatel/dist/storage.d.ts.map +1 -0
- package/miatel/dist/storage.js +100 -0
- package/miatel/dist/storage.js.map +1 -0
- package/miatel/package-lock.json +4103 -0
- package/miatel/package.json +35 -0
- package/miatel/src/commands/analyze.ts +109 -0
- package/miatel/src/commands/arc.ts +78 -0
- package/miatel/src/commands/beat.ts +176 -0
- package/miatel/src/commands/theme.ts +60 -0
- package/miatel/src/index.ts +94 -0
- package/miatel/src/storage.ts +156 -0
- package/miatel/tsconfig.json +18 -0
- package/miawa/MISSION_251231.md +144 -0
- package/miawa/README.md +133 -0
- package/miawa/dist/commands/beat.d.ts +6 -0
- package/miawa/dist/commands/beat.d.ts.map +1 -0
- package/miawa/dist/commands/beat.js +69 -0
- package/miawa/dist/commands/beat.js.map +1 -0
- package/miawa/dist/commands/ceremony.d.ts +6 -0
- package/miawa/dist/commands/ceremony.d.ts.map +1 -0
- package/miawa/dist/commands/ceremony.js +239 -0
- package/miawa/dist/commands/ceremony.js.map +1 -0
- package/miawa/dist/commands/circle.d.ts +6 -0
- package/miawa/dist/commands/circle.d.ts.map +1 -0
- package/miawa/dist/commands/circle.js +75 -0
- package/miawa/dist/commands/circle.js.map +1 -0
- package/miawa/dist/commands/eva.d.ts +6 -0
- package/miawa/dist/commands/eva.d.ts.map +1 -0
- package/miawa/dist/commands/eva.js +73 -0
- package/miawa/dist/commands/eva.js.map +1 -0
- package/miawa/dist/commands/wound.d.ts +6 -0
- package/miawa/dist/commands/wound.d.ts.map +1 -0
- package/miawa/dist/commands/wound.js +74 -0
- package/miawa/dist/commands/wound.js.map +1 -0
- package/miawa/dist/index.d.ts +19 -0
- package/miawa/dist/index.d.ts.map +1 -0
- package/miawa/dist/index.js +91 -0
- package/miawa/dist/index.js.map +1 -0
- package/miawa/dist/storage.d.ts +73 -0
- package/miawa/dist/storage.d.ts.map +1 -0
- package/miawa/dist/storage.js +100 -0
- package/miawa/dist/storage.js.map +1 -0
- package/miawa/package-lock.json +4103 -0
- package/miawa/package.json +36 -0
- package/miawa/src/commands/beat.ts +74 -0
- package/miawa/src/commands/ceremony.ts +256 -0
- package/miawa/src/commands/circle.ts +83 -0
- package/miawa/src/commands/eva.ts +84 -0
- package/miawa/src/commands/wound.ts +79 -0
- package/miawa/src/index.ts +108 -0
- package/miawa/src/storage.ts +179 -0
- package/miawa/tsconfig.json +18 -0
- package/package.json +7 -5
- package/references/acp/CLAUDE.md +7 -0
- package/references/acp/agent-plan.md +84 -0
- package/references/acp/clients.md +31 -0
- package/references/acp/extensibility.md +137 -0
- package/references/acp/initialization.md +225 -0
- package/references/acp/prompt-turn.md +321 -0
- package/references/acp/proxy-chains.md +562 -0
- package/references/acp/schema.md +3171 -0
- package/references/acp/session-list.md +334 -0
- package/references/acp/session-modes.md +170 -0
- package/references/acp/slash-commands.md +99 -0
- package/references/acp/terminals.md +281 -0
- package/references/acp/tool-calls.md +311 -0
- package/references/acp/typescript.md +29 -0
- package/references/claude/agent-teams.md +399 -0
- package/references/claude/chrome.md +231 -0
- package/references/claude/headless.md +158 -0
- package/references/claude/hooks-guide.md +708 -0
- package/references/claude/output-styles.md +112 -0
- package/references/claude/plugins.md +432 -0
- package/references/claude/skills.md +693 -0
- package/references/claude/sub-agents.md +816 -0
- package/references/copilot/acp/agents.md +32 -0
- package/references/copilot/acp/architecture.md +37 -0
- package/references/copilot/acp/clients.md +31 -0
- package/references/copilot/acp/introduction.md +42 -0
- package/references/copilot/acp/registry.md +339 -0
- package/references/copilot/acp-server.md +117 -0
- package/references/copilot/create-copilot-instructions.md +840 -0
- package/references/langchain/llms.txt +833 -0
- package/references/langchain/python/agents.md +677 -0
- package/references/langchain/python/context-engineering.md +1195 -0
- package/references/langchain/python/human-in-the-loop.md +326 -0
- package/references/langchain/python/long-term-memory.md +168 -0
- package/references/langchain/python/mcp.md +949 -0
- package/references/langchain/python/multi-agents/custom-workflow.md +187 -0
- package/references/langchain/python/multi-agents/handoffs.md +436 -0
- package/references/langchain/python/multi-agents/overview.md +295 -0
- package/references/langchain/python/multi-agents/router.md +150 -0
- package/references/langchain/python/multi-agents/skills.md +92 -0
- package/references/langchain/python/multi-agents/subagents.md +486 -0
- package/references/langchain/python/retrieval.md +320 -0
- package/references/langchain/python/runtime.md +141 -0
- package/references/langchain/python/short-term-memory.md +658 -0
- package/references/langchain/python/structured-output.md +712 -0
- package/references/langfuse/llms.txt +148 -0
- package/references/langgraph/javascript/llms.txt +275 -0
- package/references/skills/home.md +259 -0
- package/references/skills/integrate-skills.md +103 -0
- package/references/skills/specification.md +254 -0
- package/references/skills/what-are-skills.md +74 -0
- package/rispecs/README.md +164 -0
- package/rispecs/_sync_/miadi-code/SPEC.md +313 -0
- package/rispecs/_sync_/miadi-code/STATUS.md +177 -0
- package/rispecs/_sync_/miadi-code/dashboard/SPEC.md +465 -0
- package/rispecs/_sync_/miadi-code/dashboard/STATUS.md +212 -0
- package/rispecs/_sync_/miadi-code/multiline-input/SPEC.md +232 -0
- package/rispecs/_sync_/miadi-code/multiline-input/STATUS.md +108 -0
- package/rispecs/_sync_/miadi-code/pde/SPEC.md +253 -0
- package/rispecs/_sync_/miadi-code/pde/STATUS.md +56 -0
- package/rispecs/_sync_/miadi-code/stc/SPEC.md +397 -0
- package/rispecs/_sync_/miadi-code/stc/STATUS.md +70 -0
- package/rispecs/ava-langstack/inquiry-routing-upgrade.spec.md +119 -0
- package/rispecs/borrowed_from_opencode/001-client-server-architecture.rispec.md +98 -0
- package/rispecs/borrowed_from_opencode/002-event-bus-system.rispec.md +125 -0
- package/rispecs/borrowed_from_opencode/003-instance-state-pattern.rispec.md +136 -0
- package/rispecs/borrowed_from_opencode/004-namespace-module-pattern.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/005-zod-schema-validation.rispec.md +139 -0
- package/rispecs/borrowed_from_opencode/006-named-error-system.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/007-structured-logging.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/008-lazy-initialization.rispec.md +127 -0
- package/rispecs/borrowed_from_opencode/009-multi-agent-system.rispec.md +97 -0
- package/rispecs/borrowed_from_opencode/010-agent-definition-config.rispec.md +135 -0
- package/rispecs/borrowed_from_opencode/011-agent-permission-rulesets.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/012-agent-prompt-templates.rispec.md +141 -0
- package/rispecs/borrowed_from_opencode/013-agent-generation.rispec.md +142 -0
- package/rispecs/borrowed_from_opencode/014-plan-build-mode-toggle.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/015-subagent-task-delegation.rispec.md +146 -0
- package/rispecs/borrowed_from_opencode/016-agent-model-selection.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/017-compaction-agent.rispec.md +150 -0
- package/rispecs/borrowed_from_opencode/018-session-persistence.rispec.md +125 -0
- package/rispecs/borrowed_from_opencode/019-session-compaction.rispec.md +132 -0
- package/rispecs/borrowed_from_opencode/020-session-forking.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/021-session-revert-snapshot.rispec.md +135 -0
- package/rispecs/borrowed_from_opencode/022-session-sharing.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/023-session-summary-diffs.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/024-child-sessions.rispec.md +164 -0
- package/rispecs/borrowed_from_opencode/025-session-title-generation.rispec.md +162 -0
- package/rispecs/borrowed_from_opencode/026-message-parts-model.rispec.md +201 -0
- package/rispecs/borrowed_from_opencode/027-streaming-message-deltas.rispec.md +212 -0
- package/rispecs/borrowed_from_opencode/028-multi-provider-architecture.rispec.md +184 -0
- package/rispecs/borrowed_from_opencode/029-provider-authentication.rispec.md +225 -0
- package/rispecs/borrowed_from_opencode/030-model-registry.rispec.md +222 -0
- package/rispecs/borrowed_from_opencode/031-cost-tracking.rispec.md +243 -0
- package/rispecs/borrowed_from_opencode/032-provider-transform-pipeline.rispec.md +282 -0
- package/rispecs/borrowed_from_opencode/033-provider-sdk-abstraction.rispec.md +338 -0
- package/rispecs/borrowed_from_opencode/034-tool-registry.rispec.md +110 -0
- package/rispecs/borrowed_from_opencode/035-tool-context-injection.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/036-tool-output-truncation.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/037-batch-tool.rispec.md +129 -0
- package/rispecs/borrowed_from_opencode/038-multi-edit-tool.rispec.md +167 -0
- package/rispecs/borrowed_from_opencode/039-apply-patch-tool.rispec.md +161 -0
- package/rispecs/borrowed_from_opencode/040-code-search-tool.rispec.md +143 -0
- package/rispecs/borrowed_from_opencode/041-web-fetch-tool.rispec.md +131 -0
- package/rispecs/borrowed_from_opencode/042-web-search-tool.rispec.md +159 -0
- package/rispecs/borrowed_from_opencode/043-todo-tool.rispec.md +156 -0
- package/rispecs/borrowed_from_opencode/044-plan-mode-tool.rispec.md +139 -0
- package/rispecs/borrowed_from_opencode/045-task-tool.rispec.md +146 -0
- package/rispecs/borrowed_from_opencode/046-question-tool.rispec.md +170 -0
- package/rispecs/borrowed_from_opencode/047-external-directory-tool.rispec.md +166 -0
- package/rispecs/borrowed_from_opencode/048-file-read-write-tools.rispec.md +205 -0
- package/rispecs/borrowed_from_opencode/049-lsp-server-management.rispec.md +104 -0
- package/rispecs/borrowed_from_opencode/050-lsp-hover-completion.rispec.md +102 -0
- package/rispecs/borrowed_from_opencode/051-lsp-diagnostics.rispec.md +86 -0
- package/rispecs/borrowed_from_opencode/052-lsp-root-detection.rispec.md +109 -0
- package/rispecs/borrowed_from_opencode/053-remote-mcp-servers.rispec.md +119 -0
- package/rispecs/borrowed_from_opencode/054-mcp-oauth-flow.rispec.md +107 -0
- package/rispecs/borrowed_from_opencode/055-mcp-tool-conversion.rispec.md +118 -0
- package/rispecs/borrowed_from_opencode/056-mcp-connection-monitoring.rispec.md +106 -0
- package/rispecs/borrowed_from_opencode/057-local-mcp-servers.rispec.md +116 -0
- package/rispecs/borrowed_from_opencode/058-rich-tui.rispec.md +108 -0
- package/rispecs/borrowed_from_opencode/059-streaming-display.rispec.md +116 -0
- package/rispecs/borrowed_from_opencode/060-permission-prompts.rispec.md +130 -0
- package/rispecs/borrowed_from_opencode/061-session-navigation.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/062-syntax-highlighting.rispec.md +151 -0
- package/rispecs/borrowed_from_opencode/063-keybinding-system.rispec.md +181 -0
- package/rispecs/borrowed_from_opencode/064-multi-level-config.rispec.md +155 -0
- package/rispecs/borrowed_from_opencode/065-jsonc-config.rispec.md +190 -0
- package/rispecs/borrowed_from_opencode/066-config-env-variables.rispec.md +153 -0
- package/rispecs/borrowed_from_opencode/067-config-deep-merging.rispec.md +178 -0
- package/rispecs/borrowed_from_opencode/068-remote-org-config.rispec.md +183 -0
- package/rispecs/borrowed_from_opencode/069-config-markdown-frontmatter.rispec.md +206 -0
- package/rispecs/borrowed_from_opencode/070-managed-config-directory.rispec.md +232 -0
- package/rispecs/borrowed_from_opencode/071-plugin-architecture.rispec.md +104 -0
- package/rispecs/borrowed_from_opencode/072-plugin-hooks.rispec.md +123 -0
- package/rispecs/borrowed_from_opencode/073-plugin-auto-install.rispec.md +115 -0
- package/rispecs/borrowed_from_opencode/074-permission-system.rispec.md +133 -0
- package/rispecs/borrowed_from_opencode/075-git-worktree-management.rispec.md +126 -0
- package/rispecs/borrowed_from_opencode/076-snapshot-system.rispec.md +124 -0
- package/rispecs/borrowed_from_opencode/077-snapshot-diff.rispec.md +117 -0
- package/rispecs/borrowed_from_opencode/078-snapshot-restore.rispec.md +128 -0
- package/rispecs/borrowed_from_opencode/079-worktree-branch-naming.rispec.md +122 -0
- package/rispecs/borrowed_from_opencode/080-sqlite-storage.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/081-database-migrations.rispec.md +148 -0
- package/rispecs/borrowed_from_opencode/082-database-transactions.rispec.md +138 -0
- package/rispecs/borrowed_from_opencode/083-deferred-effects.rispec.md +148 -0
- package/rispecs/borrowed_from_opencode/084-permission-rules.rispec.md +123 -0
- package/rispecs/borrowed_from_opencode/085-permission-glob-patterns.rispec.md +113 -0
- package/rispecs/borrowed_from_opencode/086-permission-merging.rispec.md +134 -0
- package/rispecs/borrowed_from_opencode/087-permission-modes.rispec.md +145 -0
- package/rispecs/borrowed_from_opencode/088-http-api-server.rispec.md +165 -0
- package/rispecs/borrowed_from_opencode/089-openapi-spec-generation.rispec.md +164 -0
- package/rispecs/borrowed_from_opencode/090-websocket-support.rispec.md +136 -0
- package/rispecs/borrowed_from_opencode/091-sse-streaming.rispec.md +168 -0
- package/rispecs/borrowed_from_opencode/092-mdns-discovery.rispec.md +145 -0
- package/rispecs/borrowed_from_opencode/093-javascript-sdk.rispec.md +200 -0
- package/rispecs/borrowed_from_opencode/094-skill-system.rispec.md +187 -0
- package/rispecs/borrowed_from_opencode/095-skill-discovery.rispec.md +182 -0
- package/rispecs/borrowed_from_opencode/096-desktop-remote-driving.rispec.md +175 -0
- package/rispecs/borrowed_from_opencode/INDEX.md +255 -0
- package/rispecs/core.rispecs.md +261 -0
- package/rispecs/engines.rispecs.md +241 -0
- package/rispecs/formatting.rispecs.md +252 -0
- package/rispecs/living-specifications.rispecs.md +361 -0
- package/rispecs/mcp.rispecs.md +197 -0
- package/rispecs/pde.rispecs.md +399 -0
- package/rispecs/pi-mono-envisionning/ENVISIONING.md +366 -0
- package/rispecs/pi-mono-envisionning/storytelling-horizon.rispecs.md +76 -0
- package/rispecs/pi-mono-envisionning/widget.rispecs.md +2 -0
- package/rispecs/relation-to-mcp-structural-thinking.kin.md +72 -0
- package/rispecs/research-for-better-framework/CLAUDE.md +7 -0
- package/rispecs/research-for-better-framework/survey-pi-openclaw-opencode-openhands.md +210 -0
- package/rispecs/session.rispecs.md +277 -0
- package/rispecs/stc.rispecs.md +138 -0
- package/rispecs/unifier.rispecs.md +317 -0
- package/scripts/LAUNCH--mcp-mia-code--testing--2603141315--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +2 -0
- package/scripts/RESUME--mia-code--mcps--260313--ac705a66-2c15-4a1c-a26d-9491018c5ba8.sh +1 -0
- package/scripts/install-widget-in-home-pi-agent-extensions.sh +4 -0
- package/scripts/sample-decompose--2604011535-prompt.sh +1 -0
- package/skills/deep-search/AGENTS.md +17 -0
- package/skills/deep-search/SKILL.md +281 -0
- package/skills/deep-search/agent-templates.md +224 -0
- package/skills/deep-search/orchestration-patterns.md +95 -0
- package/skills/miaco-pde-inquiry-routing-deep-search/AGENTS.md +13 -0
- package/skills/miaco-pde-inquiry-routing-deep-search/SKILL.md +136 -0
- package/skills/miaco-pde-inquiry-routing-internal-external-relationship/AGENTS.md +4 -0
- package/skills/miaco-pde-inquiry-routing-internal-external-relationship/SKILL.md +157 -0
- package/skills/miaco-pde-inquiry-routing-local-qmd/AGENTS.md +42 -0
- package/skills/miaco-pde-inquiry-routing-local-qmd/SKILL.md +135 -0
- package/skills/qmd/AGENTS.md +3 -0
- package/skills/qmd/SKILL.md +144 -0
- package/skills/qmd/references/mcp-setup.md +102 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/SKILL.md +234 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/agent-templates.md +436 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/orchestration-patterns.md +197 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/ceremonial-technology.md +102 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/creative-orientation.md +99 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/prompt-decomposition.md +73 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/rise-framework.md +74 -0
- package/skills/rise-pde-inquiry-session-multi-agents-v3/references/structural-tension.md +82 -0
- package/src/cli.ts +35 -11
- package/src/geminiHeadless.ts +7 -2
- package/src/index.ts +2 -1
- package/src/mcp/miaco-server.ts +13 -1
- package/src/mcp/miatel-server.ts +13 -1
- package/src/mcp/miawa-server.ts +13 -1
- package/src/mcp/utils.ts +41 -8
- package/src/sessionStore.ts +44 -4
- package/src/types.ts +2 -1
- package/widget/mia-ceremony/README.md +36 -0
- package/widget/mia-ceremony/index.ts +143 -0
- package/widget/mia-interceptor/README.md +39 -0
- package/widget/mia-interceptor/index.ts +221 -0
- package/widget/mia-tools/README.md +37 -0
- package/widget/mia-tools/index.ts +569 -0
- package/widget/miette-echo/README.md +44 -0
- package/widget/miette-echo/index.ts +164 -0
- package/.claude/settings.local.json +0 -9
- package/.hch/issue_.env +0 -4
- package/.hch/issue_add__2601211715.json +0 -77
- package/.hch/issue_add__2601211715.md +0 -4
- package/.hch/issue_add__2602242020.json +0 -78
- package/.hch/issue_add__2602242020.md +0 -7
- package/.hch/issues.json +0 -2312
- package/.hch/issues.md +0 -30
- package/WS__mia-code__260214__IAIP_PDE.code-workspace +0 -29
- package/WS__mia-code__src332__260122.code-workspace +0 -23
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/checkpoints/index.md +0 -6
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/events.jsonl +0 -213
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/plan.md +0 -243
- package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/workspace.yaml +0 -5
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
> ## Documentation Index
|
|
2
|
+
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
|
|
3
|
+
> Use this file to discover all available pages before exploring further.
|
|
4
|
+
|
|
5
|
+
# Agents
|
|
6
|
+
|
|
7
|
+
Agents combine language models with [tools](/oss/python/langchain/tools) to create systems that can reason about tasks, decide which tools to use, and iteratively work towards solutions.
|
|
8
|
+
|
|
9
|
+
[`create_agent`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent) provides a production-ready agent implementation.
|
|
10
|
+
|
|
11
|
+
[An LLM Agent runs tools in a loop to achieve a goal](https://simonwillison.net/2025/Sep/18/agents/).
|
|
12
|
+
An agent runs until a stop condition is met - i.e., when the model emits a final output or an iteration limit is reached.
|
|
13
|
+
|
|
14
|
+
```mermaid theme={null}
|
|
15
|
+
%%{
|
|
16
|
+
init: {
|
|
17
|
+
"fontFamily": "monospace",
|
|
18
|
+
"flowchart": {
|
|
19
|
+
"curve": "curve"
|
|
20
|
+
},
|
|
21
|
+
"themeVariables": {"edgeLabelBackground": "transparent"}
|
|
22
|
+
}
|
|
23
|
+
}%%
|
|
24
|
+
graph TD
|
|
25
|
+
%% Outside the agent
|
|
26
|
+
QUERY([input])
|
|
27
|
+
LLM{model}
|
|
28
|
+
TOOL(tools)
|
|
29
|
+
ANSWER([output])
|
|
30
|
+
|
|
31
|
+
%% Main flows (no inline labels)
|
|
32
|
+
QUERY --> LLM
|
|
33
|
+
LLM --"action"--> TOOL
|
|
34
|
+
TOOL --"observation"--> LLM
|
|
35
|
+
LLM --"finish"--> ANSWER
|
|
36
|
+
|
|
37
|
+
classDef blueHighlight fill:#0a1c25,stroke:#0a455f,color:#bae6fd;
|
|
38
|
+
classDef greenHighlight fill:#0b1e1a,stroke:#0c4c39,color:#9ce4c4;
|
|
39
|
+
class QUERY blueHighlight;
|
|
40
|
+
class ANSWER blueHighlight;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<Info>
|
|
44
|
+
[`create_agent`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent) builds a **graph**-based agent runtime using [LangGraph](/oss/python/langgraph/overview). A graph consists of nodes (steps) and edges (connections) that define how your agent processes information. The agent moves through this graph, executing nodes like the model node (which calls the model), the tools node (which executes tools), or middleware.
|
|
45
|
+
|
|
46
|
+
Learn more about the [Graph API](/oss/python/langgraph/graph-api).
|
|
47
|
+
</Info>
|
|
48
|
+
|
|
49
|
+
## Core components
|
|
50
|
+
|
|
51
|
+
### Model
|
|
52
|
+
|
|
53
|
+
The [model](/oss/python/langchain/models) is the reasoning engine of your agent. It can be specified in multiple ways, supporting both static and dynamic model selection.
|
|
54
|
+
|
|
55
|
+
#### Static model
|
|
56
|
+
|
|
57
|
+
Static models are configured once when creating the agent and remain unchanged throughout execution. This is the most common and straightforward approach.
|
|
58
|
+
|
|
59
|
+
To initialize a static model from a <Tooltip tip="A string that follows the format `provider:model` (e.g. openai:gpt-5)" cta="See mappings" href="https://reference.langchain.com/python/langchain/models/#langchain.chat_models.init_chat_model(model)">model identifier string</Tooltip>:
|
|
60
|
+
|
|
61
|
+
```python wrap theme={null}
|
|
62
|
+
from langchain.agents import create_agent
|
|
63
|
+
|
|
64
|
+
agent = create_agent("openai:gpt-5", tools=tools)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
<Tip>
|
|
68
|
+
Model identifier strings support automatic inference (e.g., `"gpt-5"` will be inferred as `"openai:gpt-5"`). Refer to the [reference](https://reference.langchain.com/python/langchain/models/#langchain.chat_models.init_chat_model\(model\)) to see a full list of model identifier string mappings.
|
|
69
|
+
</Tip>
|
|
70
|
+
|
|
71
|
+
For more control over the model configuration, initialize a model instance directly using the provider package. In this example, we use [`ChatOpenAI`](https://reference.langchain.com/python/integrations/langchain_openai/ChatOpenAI). See [Chat models](/oss/python/integrations/chat) for other available chat model classes.
|
|
72
|
+
|
|
73
|
+
```python wrap theme={null}
|
|
74
|
+
from langchain.agents import create_agent
|
|
75
|
+
from langchain_openai import ChatOpenAI
|
|
76
|
+
|
|
77
|
+
model = ChatOpenAI(
|
|
78
|
+
model="gpt-5",
|
|
79
|
+
temperature=0.1,
|
|
80
|
+
max_tokens=1000,
|
|
81
|
+
timeout=30
|
|
82
|
+
# ... (other params)
|
|
83
|
+
)
|
|
84
|
+
agent = create_agent(model, tools=tools)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Model instances give you complete control over configuration. Use them when you need to set specific [parameters](/oss/python/langchain/models#parameters) like `temperature`, `max_tokens`, `timeouts`, `base_url`, and other provider-specific settings. Refer to the [reference](/oss/python/integrations/providers/all_providers) to see available params and methods on your model.
|
|
88
|
+
|
|
89
|
+
#### Dynamic model
|
|
90
|
+
|
|
91
|
+
Dynamic models are selected at <Tooltip tip="The execution environment of your agent, containing immutable configuration and contextual data that persists throughout the agent's execution (e.g., user IDs, session details, or application-specific configuration).">runtime</Tooltip> based on the current <Tooltip tip="The data that flows through your agent's execution, including messages, custom fields, and any information that needs to be tracked and potentially modified during processing (e.g., user preferences or tool usage stats).">state</Tooltip> and context. This enables sophisticated routing logic and cost optimization.
|
|
92
|
+
|
|
93
|
+
To use a dynamic model, create middleware using the [`@wrap_model_call`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.wrap_model_call) decorator that modifies the model in the request:
|
|
94
|
+
|
|
95
|
+
```python theme={null}
|
|
96
|
+
from langchain_openai import ChatOpenAI
|
|
97
|
+
from langchain.agents import create_agent
|
|
98
|
+
from langchain.agents.middleware import wrap_model_call, ModelRequest, ModelResponse
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
basic_model = ChatOpenAI(model="gpt-4.1-mini")
|
|
102
|
+
advanced_model = ChatOpenAI(model="gpt-4.1")
|
|
103
|
+
|
|
104
|
+
@wrap_model_call
|
|
105
|
+
def dynamic_model_selection(request: ModelRequest, handler) -> ModelResponse:
|
|
106
|
+
"""Choose model based on conversation complexity."""
|
|
107
|
+
message_count = len(request.state["messages"])
|
|
108
|
+
|
|
109
|
+
if message_count > 10:
|
|
110
|
+
# Use an advanced model for longer conversations
|
|
111
|
+
model = advanced_model
|
|
112
|
+
else:
|
|
113
|
+
model = basic_model
|
|
114
|
+
|
|
115
|
+
return handler(request.override(model=model))
|
|
116
|
+
|
|
117
|
+
agent = create_agent(
|
|
118
|
+
model=basic_model, # Default model
|
|
119
|
+
tools=tools,
|
|
120
|
+
middleware=[dynamic_model_selection]
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
<Warning>
|
|
125
|
+
Pre-bound models (models with [`bind_tools`](https://reference.langchain.com/python/langchain_core/language_models/#langchain_core.language_models.chat_models.BaseChatModel.bind_tools) already called) are not supported when using structured output. If you need dynamic model selection with structured output, ensure the models passed to the middleware are not pre-bound.
|
|
126
|
+
</Warning>
|
|
127
|
+
|
|
128
|
+
<Tip>
|
|
129
|
+
For model configuration details, see [Models](/oss/python/langchain/models). For dynamic model selection patterns, see [Dynamic model in middleware](/oss/python/langchain/middleware#dynamic-model).
|
|
130
|
+
</Tip>
|
|
131
|
+
|
|
132
|
+
### Tools
|
|
133
|
+
|
|
134
|
+
Tools give agents the ability to take actions. Agents go beyond simple model-only tool binding by facilitating:
|
|
135
|
+
|
|
136
|
+
* Multiple tool calls in sequence (triggered by a single prompt)
|
|
137
|
+
* Parallel tool calls when appropriate
|
|
138
|
+
* Dynamic tool selection based on previous results
|
|
139
|
+
* Tool retry logic and error handling
|
|
140
|
+
* State persistence across tool calls
|
|
141
|
+
|
|
142
|
+
For more information, see [Tools](/oss/python/langchain/tools).
|
|
143
|
+
|
|
144
|
+
#### Defining tools
|
|
145
|
+
|
|
146
|
+
Pass a list of tools to the agent.
|
|
147
|
+
|
|
148
|
+
<Tip>
|
|
149
|
+
Tools can be specified as plain Python functions or <Tooltip tip="A method that can suspend execution and resume at a later time">coroutines</Tooltip>.
|
|
150
|
+
|
|
151
|
+
The [tool decorator](/oss/python/langchain/tools#create-tools) can be used to customize tool names, descriptions, argument schemas, and other properties.
|
|
152
|
+
</Tip>
|
|
153
|
+
|
|
154
|
+
```python wrap theme={null}
|
|
155
|
+
from langchain.tools import tool
|
|
156
|
+
from langchain.agents import create_agent
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@tool
|
|
160
|
+
def search(query: str) -> str:
|
|
161
|
+
"""Search for information."""
|
|
162
|
+
return f"Results for: {query}"
|
|
163
|
+
|
|
164
|
+
@tool
|
|
165
|
+
def get_weather(location: str) -> str:
|
|
166
|
+
"""Get weather information for a location."""
|
|
167
|
+
return f"Weather in {location}: Sunny, 72°F"
|
|
168
|
+
|
|
169
|
+
agent = create_agent(model, tools=[search, get_weather])
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
If an empty tool list is provided, the agent will consist of a single LLM node without tool-calling capabilities.
|
|
173
|
+
|
|
174
|
+
#### Tool error handling
|
|
175
|
+
|
|
176
|
+
To customize how tool errors are handled, use the [`@wrap_tool_call`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.wrap_tool_call) decorator to create middleware:
|
|
177
|
+
|
|
178
|
+
```python wrap theme={null}
|
|
179
|
+
from langchain.agents import create_agent
|
|
180
|
+
from langchain.agents.middleware import wrap_tool_call
|
|
181
|
+
from langchain.messages import ToolMessage
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@wrap_tool_call
|
|
185
|
+
def handle_tool_errors(request, handler):
|
|
186
|
+
"""Handle tool execution errors with custom messages."""
|
|
187
|
+
try:
|
|
188
|
+
return handler(request)
|
|
189
|
+
except Exception as e:
|
|
190
|
+
# Return a custom error message to the model
|
|
191
|
+
return ToolMessage(
|
|
192
|
+
content=f"Tool error: Please check your input and try again. ({str(e)})",
|
|
193
|
+
tool_call_id=request.tool_call["id"]
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
agent = create_agent(
|
|
197
|
+
model="gpt-4.1",
|
|
198
|
+
tools=[search, get_weather],
|
|
199
|
+
middleware=[handle_tool_errors]
|
|
200
|
+
)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The agent will return a [`ToolMessage`](https://reference.langchain.com/python/langchain/messages/#langchain.messages.ToolMessage) with the custom error message when a tool fails:
|
|
204
|
+
|
|
205
|
+
```python theme={null}
|
|
206
|
+
[
|
|
207
|
+
...
|
|
208
|
+
ToolMessage(
|
|
209
|
+
content="Tool error: Please check your input and try again. (division by zero)",
|
|
210
|
+
tool_call_id="..."
|
|
211
|
+
),
|
|
212
|
+
...
|
|
213
|
+
]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Tool use in the ReAct loop
|
|
217
|
+
|
|
218
|
+
Agents follow the ReAct ("Reasoning + Acting") pattern, alternating between brief reasoning steps with targeted tool calls and feeding the resulting observations into subsequent decisions until they can deliver a final answer.
|
|
219
|
+
|
|
220
|
+
<Accordion title="Example of ReAct loop">
|
|
221
|
+
**Prompt:** Identify the current most popular wireless headphones and verify availability.
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
================================ Human Message =================================
|
|
225
|
+
|
|
226
|
+
Find the most popular wireless headphones right now and check if they're in stock
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
* **Reasoning**: "Popularity is time-sensitive, I need to use the provided search tool."
|
|
230
|
+
* **Acting**: Call `search_products("wireless headphones")`
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
================================== Ai Message ==================================
|
|
234
|
+
Tool Calls:
|
|
235
|
+
search_products (call_abc123)
|
|
236
|
+
Call ID: call_abc123
|
|
237
|
+
Args:
|
|
238
|
+
query: wireless headphones
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
================================= Tool Message =================================
|
|
243
|
+
|
|
244
|
+
Found 5 products matching "wireless headphones". Top 5 results: WH-1000XM5, ...
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
* **Reasoning**: "I need to confirm availability for the top-ranked item before answering."
|
|
248
|
+
* **Acting**: Call `check_inventory("WH-1000XM5")`
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
================================== Ai Message ==================================
|
|
252
|
+
Tool Calls:
|
|
253
|
+
check_inventory (call_def456)
|
|
254
|
+
Call ID: call_def456
|
|
255
|
+
Args:
|
|
256
|
+
product_id: WH-1000XM5
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
================================= Tool Message =================================
|
|
261
|
+
|
|
262
|
+
Product WH-1000XM5: 10 units in stock
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
* **Reasoning**: "I have the most popular model and its stock status. I can now answer the user's question."
|
|
266
|
+
* **Acting**: Produce final answer
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
================================== Ai Message ==================================
|
|
270
|
+
|
|
271
|
+
I found wireless headphones (model WH-1000XM5) with 10 units in stock...
|
|
272
|
+
```
|
|
273
|
+
</Accordion>
|
|
274
|
+
|
|
275
|
+
#### Dynamic tools
|
|
276
|
+
|
|
277
|
+
In some scenarios, you need to modify the set of tools available to the agent at runtime rather than defining them all upfront. There are two approaches depending on whether tools are known ahead of time:
|
|
278
|
+
|
|
279
|
+
<Tabs>
|
|
280
|
+
<Tab title="Filtering pre-registered tools">
|
|
281
|
+
When all possible tools are known at agent creation time, you can pre-register them and dynamically filter which ones are exposed to the model based on state, permissions, or context.
|
|
282
|
+
|
|
283
|
+
```python theme={null}
|
|
284
|
+
from langchain.agents import create_agent
|
|
285
|
+
from langchain.agents.middleware import wrap_model_call, ModelRequest, ModelResponse
|
|
286
|
+
from typing import Callable
|
|
287
|
+
|
|
288
|
+
@wrap_model_call
|
|
289
|
+
def filter_tools(
|
|
290
|
+
request: ModelRequest,
|
|
291
|
+
handler: Callable[[ModelRequest], ModelResponse],
|
|
292
|
+
) -> ModelResponse:
|
|
293
|
+
"""Filter tools based on user permissions."""
|
|
294
|
+
user_role = request.runtime.context.user_role
|
|
295
|
+
|
|
296
|
+
if user_role == "admin":
|
|
297
|
+
# Admins get all tools
|
|
298
|
+
tools = request.tools
|
|
299
|
+
else:
|
|
300
|
+
# Regular users get read-only tools
|
|
301
|
+
tools = [t for t in request.tools if t.name.startswith("read_")]
|
|
302
|
+
|
|
303
|
+
return handler(request.override(tools=tools))
|
|
304
|
+
|
|
305
|
+
agent = create_agent(
|
|
306
|
+
model="gpt-4o",
|
|
307
|
+
tools=[read_data, write_data, delete_data], # All tools pre-registered
|
|
308
|
+
middleware=[filter_tools],
|
|
309
|
+
)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
This approach is best when:
|
|
313
|
+
|
|
314
|
+
* All possible tools are known at compile/startup time
|
|
315
|
+
* You want to filter based on permissions, feature flags, or conversation state
|
|
316
|
+
* Tools are static but their availability is dynamic
|
|
317
|
+
|
|
318
|
+
See [Dynamically selecting tools](/oss/python/langchain/middleware/custom#dynamically-selecting-tools) for more examples.
|
|
319
|
+
</Tab>
|
|
320
|
+
|
|
321
|
+
<Tab title="Runtime tool registration">
|
|
322
|
+
When tools are discovered or created at runtime (e.g., loaded from an MCP server, generated based on user data, or fetched from a remote registry), you need to both register the tools and handle their execution dynamically.
|
|
323
|
+
|
|
324
|
+
This requires two middleware hooks:
|
|
325
|
+
|
|
326
|
+
1. `wrap_model_call` - Add the dynamic tools to the request
|
|
327
|
+
2. `wrap_tool_call` - Handle execution of the dynamically added tools
|
|
328
|
+
|
|
329
|
+
```python theme={null}
|
|
330
|
+
from langchain.tools import tool
|
|
331
|
+
from langchain.agents import create_agent
|
|
332
|
+
from langchain.agents.middleware import AgentMiddleware, ModelRequest, ToolCallRequest
|
|
333
|
+
|
|
334
|
+
# A tool that will be added dynamically at runtime
|
|
335
|
+
@tool
|
|
336
|
+
def calculate_tip(bill_amount: float, tip_percentage: float = 20.0) -> str:
|
|
337
|
+
"""Calculate the tip amount for a bill."""
|
|
338
|
+
tip = bill_amount * (tip_percentage / 100)
|
|
339
|
+
return f"Tip: ${tip:.2f}, Total: ${bill_amount + tip:.2f}"
|
|
340
|
+
|
|
341
|
+
class DynamicToolMiddleware(AgentMiddleware):
|
|
342
|
+
"""Middleware that registers and handles dynamic tools."""
|
|
343
|
+
|
|
344
|
+
def wrap_model_call(self, request: ModelRequest, handler):
|
|
345
|
+
# Add dynamic tool to the request
|
|
346
|
+
# This could be loaded from an MCP server, database, etc.
|
|
347
|
+
updated = request.override(tools=[*request.tools, calculate_tip])
|
|
348
|
+
return handler(updated)
|
|
349
|
+
|
|
350
|
+
def wrap_tool_call(self, request: ToolCallRequest, handler):
|
|
351
|
+
# Handle execution of the dynamic tool
|
|
352
|
+
if request.tool_call["name"] == "calculate_tip":
|
|
353
|
+
return handler(request.override(tool=calculate_tip))
|
|
354
|
+
return handler(request)
|
|
355
|
+
|
|
356
|
+
agent = create_agent(
|
|
357
|
+
model="gpt-4o",
|
|
358
|
+
tools=[get_weather], # Only static tools registered here
|
|
359
|
+
middleware=[DynamicToolMiddleware()],
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
# The agent can now use both get_weather AND calculate_tip
|
|
363
|
+
result = agent.invoke({
|
|
364
|
+
"messages": [{"role": "user", "content": "Calculate a 20% tip on $85"}]
|
|
365
|
+
})
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
This approach is best when:
|
|
369
|
+
|
|
370
|
+
* Tools are discovered at runtime (e.g., from an MCP server)
|
|
371
|
+
* Tools are generated dynamically based on user data or configuration
|
|
372
|
+
* You're integrating with external tool registries
|
|
373
|
+
|
|
374
|
+
<Note>
|
|
375
|
+
The `wrap_tool_call` hook is required for runtime-registered tools because the agent needs to know how to execute tools that weren't in the original tool list. Without it, the agent won't know how to invoke the dynamically added tool.
|
|
376
|
+
</Note>
|
|
377
|
+
</Tab>
|
|
378
|
+
</Tabs>
|
|
379
|
+
|
|
380
|
+
<Tip>
|
|
381
|
+
To learn more about tools, see [Tools](/oss/python/langchain/tools).
|
|
382
|
+
</Tip>
|
|
383
|
+
|
|
384
|
+
### System prompt
|
|
385
|
+
|
|
386
|
+
You can shape how your agent approaches tasks by providing a prompt. The [`system_prompt`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent\(system_prompt\)) parameter can be provided as a string:
|
|
387
|
+
|
|
388
|
+
```python wrap theme={null}
|
|
389
|
+
agent = create_agent(
|
|
390
|
+
model,
|
|
391
|
+
tools,
|
|
392
|
+
system_prompt="You are a helpful assistant. Be concise and accurate."
|
|
393
|
+
)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
When no [`system_prompt`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent\(system_prompt\)) is provided, the agent will infer its task from the messages directly.
|
|
397
|
+
|
|
398
|
+
The [`system_prompt`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent\(system_prompt\)) parameter accepts either a `str` or a [`SystemMessage`](https://reference.langchain.com/python/langchain/messages/#langchain.messages.SystemMessage). Using a `SystemMessage` gives you more control over the prompt structure, which is useful for provider-specific features like [Anthropic's prompt caching](/oss/python/integrations/chat/anthropic#prompt-caching):
|
|
399
|
+
|
|
400
|
+
```python wrap theme={null}
|
|
401
|
+
from langchain.agents import create_agent
|
|
402
|
+
from langchain.messages import SystemMessage, HumanMessage
|
|
403
|
+
|
|
404
|
+
literary_agent = create_agent(
|
|
405
|
+
model="anthropic:claude-sonnet-4-5",
|
|
406
|
+
system_prompt=SystemMessage(
|
|
407
|
+
content=[
|
|
408
|
+
{
|
|
409
|
+
"type": "text",
|
|
410
|
+
"text": "You are an AI assistant tasked with analyzing literary works.",
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"type": "text",
|
|
414
|
+
"text": "<the entire contents of 'Pride and Prejudice'>",
|
|
415
|
+
"cache_control": {"type": "ephemeral"}
|
|
416
|
+
}
|
|
417
|
+
]
|
|
418
|
+
)
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
result = literary_agent.invoke(
|
|
422
|
+
{"messages": [HumanMessage("Analyze the major themes in 'Pride and Prejudice'.")]}
|
|
423
|
+
)
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
The `cache_control` field with `{"type": "ephemeral"}` tells Anthropic to cache that content block, reducing latency and costs for repeated requests that use the same system prompt.
|
|
427
|
+
|
|
428
|
+
#### Dynamic system prompt
|
|
429
|
+
|
|
430
|
+
For more advanced use cases where you need to modify the system prompt based on runtime context or agent state, you can use [middleware](/oss/python/langchain/middleware).
|
|
431
|
+
|
|
432
|
+
The [`@dynamic_prompt`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.dynamic_prompt) decorator creates middleware that generates system prompts based on the model request:
|
|
433
|
+
|
|
434
|
+
```python wrap theme={null}
|
|
435
|
+
from typing import TypedDict
|
|
436
|
+
|
|
437
|
+
from langchain.agents import create_agent
|
|
438
|
+
from langchain.agents.middleware import dynamic_prompt, ModelRequest
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
class Context(TypedDict):
|
|
442
|
+
user_role: str
|
|
443
|
+
|
|
444
|
+
@dynamic_prompt
|
|
445
|
+
def user_role_prompt(request: ModelRequest) -> str:
|
|
446
|
+
"""Generate system prompt based on user role."""
|
|
447
|
+
user_role = request.runtime.context.get("user_role", "user")
|
|
448
|
+
base_prompt = "You are a helpful assistant."
|
|
449
|
+
|
|
450
|
+
if user_role == "expert":
|
|
451
|
+
return f"{base_prompt} Provide detailed technical responses."
|
|
452
|
+
elif user_role == "beginner":
|
|
453
|
+
return f"{base_prompt} Explain concepts simply and avoid jargon."
|
|
454
|
+
|
|
455
|
+
return base_prompt
|
|
456
|
+
|
|
457
|
+
agent = create_agent(
|
|
458
|
+
model="gpt-4.1",
|
|
459
|
+
tools=[web_search],
|
|
460
|
+
middleware=[user_role_prompt],
|
|
461
|
+
context_schema=Context
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
# The system prompt will be set dynamically based on context
|
|
465
|
+
result = agent.invoke(
|
|
466
|
+
{"messages": [{"role": "user", "content": "Explain machine learning"}]},
|
|
467
|
+
context={"user_role": "expert"}
|
|
468
|
+
)
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
<Tip>
|
|
472
|
+
For more details on message types and formatting, see [Messages](/oss/python/langchain/messages). For comprehensive middleware documentation, see [Middleware](/oss/python/langchain/middleware).
|
|
473
|
+
</Tip>
|
|
474
|
+
|
|
475
|
+
## Invocation
|
|
476
|
+
|
|
477
|
+
You can invoke an agent by passing an update to its [`State`](/oss/python/langgraph/graph-api#state). All agents include a [sequence of messages](/oss/python/langgraph/use-graph-api#messagesstate) in their state; to invoke the agent, pass a new message:
|
|
478
|
+
|
|
479
|
+
```python theme={null}
|
|
480
|
+
result = agent.invoke(
|
|
481
|
+
{"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]}
|
|
482
|
+
)
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
For streaming steps and / or tokens from the agent, refer to the [streaming](/oss/python/langchain/streaming) guide.
|
|
486
|
+
|
|
487
|
+
Otherwise, the agent follows the LangGraph [Graph API](/oss/python/langgraph/use-graph-api) and supports all associated methods, such as `stream` and `invoke`.
|
|
488
|
+
|
|
489
|
+
## Advanced concepts
|
|
490
|
+
|
|
491
|
+
### Structured output
|
|
492
|
+
|
|
493
|
+
In some situations, you may want the agent to return an output in a specific format. LangChain provides strategies for structured output via the [`response_format`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent\(response_format\)) parameter.
|
|
494
|
+
|
|
495
|
+
#### ToolStrategy
|
|
496
|
+
|
|
497
|
+
`ToolStrategy` uses artificial tool calling to generate structured output. This works with any model that supports tool calling. `ToolStrategy` should be used when provider-native structured output (via [`ProviderStrategy`](#ProviderStrategy)) is not available or reliable.
|
|
498
|
+
|
|
499
|
+
```python wrap theme={null}
|
|
500
|
+
from pydantic import BaseModel
|
|
501
|
+
from langchain.agents import create_agent
|
|
502
|
+
from langchain.agents.structured_output import ToolStrategy
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
class ContactInfo(BaseModel):
|
|
506
|
+
name: str
|
|
507
|
+
email: str
|
|
508
|
+
phone: str
|
|
509
|
+
|
|
510
|
+
agent = create_agent(
|
|
511
|
+
model="gpt-4.1-mini",
|
|
512
|
+
tools=[search_tool],
|
|
513
|
+
response_format=ToolStrategy(ContactInfo)
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
result = agent.invoke({
|
|
517
|
+
"messages": [{"role": "user", "content": "Extract contact info from: John Doe, john@example.com, (555) 123-4567"}]
|
|
518
|
+
})
|
|
519
|
+
|
|
520
|
+
result["structured_response"]
|
|
521
|
+
# ContactInfo(name='John Doe', email='john@example.com', phone='(555) 123-4567')
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
#### ProviderStrategy
|
|
525
|
+
|
|
526
|
+
`ProviderStrategy` uses the model provider's native structured output generation. This is more reliable but only works with providers that support native structured output:
|
|
527
|
+
|
|
528
|
+
```python wrap theme={null}
|
|
529
|
+
from langchain.agents.structured_output import ProviderStrategy
|
|
530
|
+
|
|
531
|
+
agent = create_agent(
|
|
532
|
+
model="gpt-4.1",
|
|
533
|
+
response_format=ProviderStrategy(ContactInfo)
|
|
534
|
+
)
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
<Note>
|
|
538
|
+
As of `langchain 1.0`, simply passing a schema (e.g., `response_format=ContactInfo`) will default to `ProviderStrategy` if the model supports native structured output. It will fall back to `ToolStrategy` otherwise.
|
|
539
|
+
</Note>
|
|
540
|
+
|
|
541
|
+
<Tip>
|
|
542
|
+
To learn about structured output, see [Structured output](/oss/python/langchain/structured-output).
|
|
543
|
+
</Tip>
|
|
544
|
+
|
|
545
|
+
### Memory
|
|
546
|
+
|
|
547
|
+
Agents maintain conversation history automatically through the message state. You can also configure the agent to use a custom state schema to remember additional information during the conversation.
|
|
548
|
+
|
|
549
|
+
Information stored in the state can be thought of as the [short-term memory](/oss/python/langchain/short-term-memory) of the agent:
|
|
550
|
+
|
|
551
|
+
Custom state schemas must extend [`AgentState`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.AgentState) as a `TypedDict`.
|
|
552
|
+
|
|
553
|
+
There are two ways to define custom state:
|
|
554
|
+
|
|
555
|
+
1. Via [middleware](/oss/python/langchain/middleware) (preferred)
|
|
556
|
+
2. Via [`state_schema`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.AgentMiddleware.state_schema) on [`create_agent`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent)
|
|
557
|
+
|
|
558
|
+
#### Defining state via middleware
|
|
559
|
+
|
|
560
|
+
Use middleware to define custom state when your custom state needs to be accessed by specific middleware hooks and tools attached to said middleware.
|
|
561
|
+
|
|
562
|
+
```python theme={null}
|
|
563
|
+
from langchain.agents import AgentState
|
|
564
|
+
from langchain.agents.middleware import AgentMiddleware
|
|
565
|
+
from typing import Any
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
class CustomState(AgentState):
|
|
569
|
+
user_preferences: dict
|
|
570
|
+
|
|
571
|
+
class CustomMiddleware(AgentMiddleware):
|
|
572
|
+
state_schema = CustomState
|
|
573
|
+
tools = [tool1, tool2]
|
|
574
|
+
|
|
575
|
+
def before_model(self, state: CustomState, runtime) -> dict[str, Any] | None:
|
|
576
|
+
...
|
|
577
|
+
|
|
578
|
+
agent = create_agent(
|
|
579
|
+
model,
|
|
580
|
+
tools=tools,
|
|
581
|
+
middleware=[CustomMiddleware()]
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
# The agent can now track additional state beyond messages
|
|
585
|
+
result = agent.invoke({
|
|
586
|
+
"messages": [{"role": "user", "content": "I prefer technical explanations"}],
|
|
587
|
+
"user_preferences": {"style": "technical", "verbosity": "detailed"},
|
|
588
|
+
})
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
#### Defining state via `state_schema`
|
|
592
|
+
|
|
593
|
+
Use the [`state_schema`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.AgentMiddleware.state_schema) parameter as a shortcut to define custom state that is only used in tools.
|
|
594
|
+
|
|
595
|
+
```python theme={null}
|
|
596
|
+
from langchain.agents import AgentState
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
class CustomState(AgentState):
|
|
600
|
+
user_preferences: dict
|
|
601
|
+
|
|
602
|
+
agent = create_agent(
|
|
603
|
+
model,
|
|
604
|
+
tools=[tool1, tool2],
|
|
605
|
+
state_schema=CustomState
|
|
606
|
+
)
|
|
607
|
+
# The agent can now track additional state beyond messages
|
|
608
|
+
result = agent.invoke({
|
|
609
|
+
"messages": [{"role": "user", "content": "I prefer technical explanations"}],
|
|
610
|
+
"user_preferences": {"style": "technical", "verbosity": "detailed"},
|
|
611
|
+
})
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
<Note>
|
|
615
|
+
As of `langchain 1.0`, custom state schemas **must** be `TypedDict` types. Pydantic models and dataclasses are no longer supported. See the [v1 migration guide](/oss/python/migrate/langchain-v1#state-type-restrictions) for more details.
|
|
616
|
+
</Note>
|
|
617
|
+
|
|
618
|
+
<Note>
|
|
619
|
+
Defining custom state via middleware is preferred over defining it via [`state_schema`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.AgentMiddleware.state_schema) on [`create_agent`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent) because it allows you to keep state extensions conceptually scoped to the relevant middleware and tools.
|
|
620
|
+
|
|
621
|
+
[`state_schema`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.AgentMiddleware.state_schema) is still supported for backwards compatibility on [`create_agent`](https://reference.langchain.com/python/langchain/agents/#langchain.agents.create_agent).
|
|
622
|
+
</Note>
|
|
623
|
+
|
|
624
|
+
<Tip>
|
|
625
|
+
To learn more about memory, see [Memory](/oss/python/concepts/memory). For information on implementing long-term memory that persists across sessions, see [Long-term memory](/oss/python/langchain/long-term-memory).
|
|
626
|
+
</Tip>
|
|
627
|
+
|
|
628
|
+
### Streaming
|
|
629
|
+
|
|
630
|
+
We've seen how the agent can be called with `invoke` to get a final response. If the agent executes multiple steps, this may take a while. To show intermediate progress, we can stream back messages as they occur.
|
|
631
|
+
|
|
632
|
+
```python theme={null}
|
|
633
|
+
from langchain.messages import AIMessage, HumanMessage
|
|
634
|
+
|
|
635
|
+
for chunk in agent.stream({
|
|
636
|
+
"messages": [{"role": "user", "content": "Search for AI news and summarize the findings"}]
|
|
637
|
+
}, stream_mode="values"):
|
|
638
|
+
# Each chunk contains the full state at that point
|
|
639
|
+
latest_message = chunk["messages"][-1]
|
|
640
|
+
if latest_message.content:
|
|
641
|
+
if isinstance(latest_message, HumanMessage):
|
|
642
|
+
print(f"User: {latest_message.content}")
|
|
643
|
+
elif isinstance(latest_message, AIMessage):
|
|
644
|
+
print(f"Agent: {latest_message.content}")
|
|
645
|
+
elif latest_message.tool_calls:
|
|
646
|
+
print(f"Calling tools: {[tc['name'] for tc in latest_message.tool_calls]}")
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
<Tip>
|
|
650
|
+
For more details on streaming, see [Streaming](/oss/python/langchain/streaming).
|
|
651
|
+
</Tip>
|
|
652
|
+
|
|
653
|
+
### Middleware
|
|
654
|
+
|
|
655
|
+
[Middleware](/oss/python/langchain/middleware) provides powerful extensibility for customizing agent behavior at different stages of execution. You can use middleware to:
|
|
656
|
+
|
|
657
|
+
* Process state before the model is called (e.g., message trimming, context injection)
|
|
658
|
+
* Modify or validate the model's response (e.g., guardrails, content filtering)
|
|
659
|
+
* Handle tool execution errors with custom logic
|
|
660
|
+
* Implement dynamic model selection based on state or context
|
|
661
|
+
* Add custom logging, monitoring, or analytics
|
|
662
|
+
|
|
663
|
+
Middleware integrates seamlessly into the agent's execution, allowing you to intercept and modify data flow at key points without changing the core agent logic.
|
|
664
|
+
|
|
665
|
+
<Tip>
|
|
666
|
+
For comprehensive middleware documentation including decorators like [`@before_model`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.before_model), [`@after_model`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.after_model), and [`@wrap_tool_call`](https://reference.langchain.com/python/langchain/middleware/#langchain.agents.middleware.wrap_tool_call), see [Middleware](/oss/python/langchain/middleware).
|
|
667
|
+
</Tip>
|
|
668
|
+
|
|
669
|
+
***
|
|
670
|
+
|
|
671
|
+
<Callout icon="pen-to-square" iconType="regular">
|
|
672
|
+
[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/langchain/agents.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
|
|
673
|
+
</Callout>
|
|
674
|
+
|
|
675
|
+
<Tip icon="terminal" iconType="regular">
|
|
676
|
+
[Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
|
|
677
|
+
</Tip>
|