Repository navigation
refactor(tools): move the tools into their own bounded context - #1377
Conversation
…ools internal/agent/tools becomes the tools bounded context's home next to internal/tools/custom: the registry, the built-in tools, their embedded manifests and filewriter/ move, while the package stays tools so call sites keep tools.ToolRead and tools.NewRegistry and only their import paths change. internal/agent/testdata/tool_definitions.golden.json is byte-identical.
BaseFormatter and CustomFormatter move from internal/agent/infrastructure into the tools context: they format tool results, and the MCP and custom tools use them too. The a2a, computer and MCP contexts, the custom tools and the UI tool formatter service now import the formatter from internal/tools, so the tools context imports neither internal/agent nor internal/agent/infrastructure.
A depguard rule keeps internal/tools from importing the agent context: the agent consumes the tools, never the other way round, with agent/domain excepted as the shared kernel. AGENTS.md lists tools among the bounded contexts, points at internal/tools for the registry and manifests, and CONTRIBUTING.md's Adding New Tools guide follows the new paths. The tool model stays in the agentdomain shared kernel for now, since the a2a, browser, computer and MCP tools implement it.
|
@infer /model ollama_cloud/deepseek-v4.1-flash CI is failing and the PR is not ready for review, can you fix the work of glm-5.3-flash? use /ponytail:ponytail /domain-driven-design /go /go-concurrency once the migration is complete and ready and the examples all are working as expected - there is no regression, then we can review this PR. |
|
Model: Todos
Pull Request✅ Infer Result: SuccessCI is green and the tree is clean. Here is my report. What I changedOne commit, The
The fix moves the description onto the deny entry and aligns the block with Verification (all run on this branch after the fix)
Review findings on the migration (nothing changed here)
The branch is pushed and the working tree is clean, so the PR is ready for your review. Model: Tokens: 3,323,501 in · 38,947 out · 3,362,448 total (50 requests) Tool calls: 70 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
golangci-lint's depguard schema rejects a rule-level desc key, and the added rule body was indented four spaces too deep, which made the YAML unparseable. Move the desc onto the deny entry and align the block with its siblings.
# Conflicts: # AGENTS.md # cmd/export/export.go # internal/agent/tool_definitions_golden_test.go # internal/protocols/a2a/query_agent.go # internal/protocols/mcp/tool.go
|
🎉 This PR is included in version 0.216.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #1373
Summary
The built-in tools and the tool registry move out of the agent context into the tools bounded context, next to
internal/tools/customfrom PR 1372. The agent consumes the tools context, never the other way round: the tool result formatters moved into the tools context as well, sointernal/toolsimports neitherinternal/agentnorinternal/agent/infrastructure, and a depguard rule now enforces that boundary. Tool definitions are byte-identical (internal/agent/testdata/tool_definitions.golden.jsonis unchanged).Tool model home:
Tool,ToolManifest,ManifestTool,CallApprover,SelfGatedTool,SessionTool,ToolExecutionResultandValidateArgumentsstay in theagentdomainshared kernel. It is the designated shared kernel (every context'sdomain/imports exactlyagent/domainas its shared kernel), and the a2a, browser, computer and MCP contexts implement these contracts, so moving them tointernal/tools/domainwould ripple through those contexts plus thedomain-is-puredepguard allow-list. That deserves its own step; this PR records the decision.Changes
internal/agent/toolsintointernal/tools(git-detected 100% renames; package staystools): the registry, the built-in tools, their embedded YAML manifests,filewriter/, and the markdown-subagent helpers. Call sites keeptools.ToolReadandtools.NewRegistryand only import paths changed:internal/agent,internal/agent/states,internal/container,cmd/tools,cmd/export,internal/presentation/headless,internal/presentation/tuiand theinternal/tools/customtests.BaseFormatter/CustomFormatter(plus their unit tests) frominternal/agent/infrastructuretointernal/tools, since what they format is a tool result: the a2a, computer, MCP and custom tools and the TUI tool formatter service now import the formatter frominternal/tools.internal/toolsimports neitherinternal/agentnorinternal/agent/infrastructure; the only remaining importer ofinternal/agent/infrastructureoutside the agent context isinternal/container, the composition root that builds the services.tools-do-not-import-the-agent(.golangci.yml): files underinternal/toolsmay not importgithub.com/inference-gateway/cli/internal/agent(which prefix-coversinternal/agent/infrastructureand friends), withinternal/agent/domainexplicitly allowed as the shared kernel. Verified by probing: a temporary import ofinternal/agent/infrastructurefrominternal/toolsis flagged astools-do-not-import-the-agent.toolsamong the bounded contexts, points atinternal/toolsfor the registry and manifest paths, records that the tools contracts stay in theagentdomainshared kernel, and documents the import direction. CONTRIBUTING.md's "Adding New Tools" guide follows the new paths.internal/agent/toolspaths.no docs ticket: internal-only refactor
Verification
go build ./...and the affected package tests pass after every commit; the tool-definitions golden test is unchanged and green.go test -race ./...: green (full suite, ~4 min).task precommit:run: green (mod:tidy, mocks, fmt, lint:imports, golangci-lint 0 issues, markdownlint).task test:e2e): 6 failures in this runner, all pre-existing - verified by running the suite on clean main (3982850), whereTestAgentWriteIsBlockedWithoutApproverandTestChatTUIViaTmuxfail with byte-identical errors (headless Write executes without an approver; the TUI panes show a "Username for 'https://github.com':" credential prompt from the gateway binary download and never see the mock reply). Tracked in issue 1378.