Repository navigation
Description
Summary
The agent consumes tools, but the built-in tools and the tool registry live inside the agent context, in internal/agent/tools. #1372 (custom tools, #1366) started a tools bounded context: custom tools live in internal/tools/custom. Move the rest, so that every tool the agent can call lives in the tools context and the agent only uses it.
Scope:
- Move
internal/agent/toolsintointernal/tools: the registry, the built-in tools, their embedded manifests andfilewriter/. The package staystools, so call sites keeptools.ToolReadandtools.NewRegistryand only their import paths change. Today's importers areinternal/agent,internal/agent/states,internal/container,cmd/tools,cmd/export,internal/presentation/headless,internal/presentation/tui/appand theinternal/tools/customtests. - Cut the tools context's dependency on the agent context.
internal/agent/toolsimportsinternal/agent/infrastructure, for example for the tool result formatters that MCP and custom tools also use. What is tool-specific moves into the tools context. - Decide where the tool model lives.
Tool,ToolManifest,ManifestTool,CallApprover,SelfGatedTool,SessionTool,ToolExecutionResultandValidateArgumentssit in theagentdomainshared kernel. They could move tointernal/tools/domain. The a2a, browser, computer and MCP contexts implement these, so the move touches them and thedomain-is-puredepguard rule. It can be a separate step. - Update the conventions:
- AGENTS.md: add
toolsto the bounded contexts and fix the manifest paths. - CONTRIBUTING.md "Adding New Tools": it names
internal/agent/toolsthroughout. - A depguard rule that keeps
internal/toolsfrom importing the agent context.
- AGENTS.md: add
Acceptance Criteria
-
internal/agent/toolsno longer exists. The registry, built-in tools, manifests andfilewriterlive ininternal/tools, next tointernal/tools/custom. - The agent context imports the tools context, never the other way round.
internal/toolsimports neitherinternal/agentnorinternal/agent/infrastructure. - The tool model's home is decided: it either moves to
internal/tools/domain, or this issue records why it stays inagentdomain. - Tool definitions are byte-identical:
internal/agent/testdata/tool_definitions.golden.jsonis unchanged. - AGENTS.md and CONTRIBUTING.md describe the tools context, and depguard enforces its import direction.
-
go test -race ./..., the e2e suite andtask precommit:runpass.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(tools): allow registering custom tools in any language (#1372)
edenreich commentedon Sep 28, 2026
@infer Can you work on this? use /ponytail:ponytail /domain-driven-design /go /go-concurrency
inference-gateway-maintainer commentedon Sep 28, 2026
Model:
ollama_cloud/glm-5.3-flash· View JobTodos
Pull Request
#1377
✅ Infer Result: Success
All 9 todos are complete, the tree is clean, everything is pushed, and PR #1377 is ready for review.
Resolved: the tools are now their own bounded context
PR: #1377 (ready for review) - branch
fix/issue-1373, 3 commits, all pushed.What changed
internal/agent/toolsis gone. The registry, all built-in tools, their embedded YAML manifests,filewriter/and the markdown-subagent helpers now live ininternal/tools, next tointernal/tools/custom. The package name stayedtools, so call sites keeptools.ToolReadandtools.NewRegistryand only import paths changed (git detected 100% renames across 153 files). The golden fileinternal/agent/testdata/tool_definitions.golden.jsonis byte-identical and its test is green.BaseFormatter/CustomFormatter(tool result formatters, also used by MCP and custom tools) moved frominternal/agent/infrastructureintointernal/tools. The a2a, computer and MCP contexts, the custom tools and the TUI tool formatter service now import them from the tools context, sointernal/toolsimports neitherinternal/agentnorinternal/agent/infrastructure. The only remaining importer ofinternal/agent/infrastructureoutside the agent context isinternal/container, the composition root.tools-do-not-import-the-agentin.golangci.yml(files underinternal/toolsmay not importinternal/agent, withinternal/agent/domainallowed as the shared kernel) - verified by a probe import that was correctly flagged and then removed. AGENTS.md liststoolsamong the bounded contexts and fixes the registry/manifest paths; CONTRIBUTING.md's "Adding New Tools" guide follows the new paths.Tool,ToolManifest,CallApprover,SelfGatedTool,SessionTool,ToolExecutionResult,ValidateArgumentsstay in theagentdomainshared kernel, because the a2a, browser, computer and MCP contexts implement these contracts and every context'sdomain/designatesagent/domainas its shared kernel; moving them tointernal/tools/domainwould ripple through those contexts and thedomain-is-purerule, so it is deliberately left as its own future step. Recorded in the PR body and AGENTS.md.Verification
go build ./..., affected unit/integration tests andgo test -race ./...(full suite): green.task precommit:run: green (0 lint issues).TestAgentWriteIsBlockedWithoutApproverandTestChatTUIViaTmuxwith byte-identical errors on cleanmain(3982850), so they are unrelated to this refactor. Root causes: a headless Write executes without an approver, and the gateway binary download from GitHub gets a credential prompt in network-restricted runners, so the TUI never sees the mock reply. Tracked in issue [BUG] tests/e2e fails on main: headless Write is not blocked without an approver, TUI tests never see the mock reply #1378 for the maintainers; the repo CI (with network access) gives the authoritative e2e verdict.The issue is on the Roadmap 2026 board with Status "QA"; it flips to Done when the PR merges.
Model:
ollama_cloud/glm-5.3-flash· Exit Code:0· Duration: 30m 18sTokens: 13,330,458 in · 83,337 out · 13,413,795 total (100 requests)
Tool calls: 137 total · 100% success rate
Traces
Stats
Triggered by edenreich · Infer Action · OSS
inference-gateway-releaser commentedon Sep 28, 2026
🎉 This issue has been resolved in version 0.216.0 🎉
The release is available on:
Your semantic-release bot 📦🚀