Repository navigation
Description
Summary
Groundwork for #1366 (custom tools in any language): move the definitions of the built-in tools out of Go code into manifests that use the same schema as the #1366 custom tool manifest. Execution stays in Go, in-process. Once this lands, a built-in tool and a custom tool differ only in how they run: a built-in manifest binds to its Go implementation by name, a custom one runs command. #1366 then only adds loading from ~/.infer/tools/ and the process runner.
What is hardcoded today
A tool's definition and policy are spread over five places, all keyed by tool name:
- JSON Schema: a hand-written
Definition()per tool, 49 tools in total (39 ininternal/agent/tools/, 6 ininternal/browser/, 4 ininternal/computer/). - Description: one field per tool in
PromptsToolsConfig(config/prompts.go), overridable inprompts.yaml. - Approval default: the
switch toolNameinConfig.IsApprovalRequired(config/config.go). Some tools have their own default (TodoWrite, Wait, Memoryfalse; ApproveSubagent, CreateAvatartrue), the rest fall back totools.safety.require_approval. - Read-only:
agentdomain.ReadOnlyTools(internal/agent/domain/tools.go), used for the read-only subagent toolset, thereadonlymode and concurrent execution within a batch. - Plan mode:
planModeAllowedToolsandplanOnlyTools(internal/agent/llm_tool_service.go).
Proposed shape
One embedded manifest per built-in tool, owned by the bounded context that implements it and embedded next to the Go code (internal/agent/tools/Read.yaml, internal/browser/tools/BrowserClick.yaml, internal/computer/tools/Computer.yaml), with the #1366 fields:
name: Read
description: Reads a file from the local filesystem. ...
parameters:
type: object
additionalProperties: false
properties:
file_path:
type: string
description: The path to the file to read (can be absolute or relative)
limit:
type: integer
minimum: 1
description: The number of lines to read. Only provide if the file is too large to read at once.
offset:
type: integer
minimum: 1
description: The line number to start reading from. Only provide if the file is too large to read at once
required:
- file_path
require_approval: false
modes: [standard, auto, auto-with-judge, plan, readonly]- A manifest without
commandbinds to the Go implementation registered under the same name. Manifests loaded from disk ([FEATURE] Allow registering custom tools in any language #1366) still requirecommand. Definition()is built from the manifest. The Go types keepExecute,Validateand the formatting methods.- The tool registry answers tool policy (read-only, plan mode, approval) from the manifests; the container feeds it the browser and computer tools the same way as MCP tools, so changing a computer tool touches only
internal/computer. - User config keeps winning for
tools.<name>.require_approval/enabledinconfig.yaml. The manifest is the only source of a tool's description: thetoolssection ofprompts.yamland theINFER_PROMPTS_TOOLS_*_DESCRIPTIONenv overrides are removed. - Tools whose approval depends on their arguments (computer use) decide per call through a
CallApprovercontract in their own context; tool names are referenced through per-context constants. - The Agent tool appends the Markdown subagent catalog to its description at runtime. That decoration stays in Go on top of the manifest description.
- No import cycle to manage:
configno longer holds default tool descriptions, soinfer initwrites aprompts.yamlwithout atoolssection. - The three A2A tools keep their manifests in
internal/agent/toolsuntil A2A moves into its own context ([TASK] Refactor extract A2A into its own bounded context #1368).
Schema gaps found (feed back into #1366)
The #1366 schema cannot express today's built-in behavior without two changes:
- Plan mode is not the same as read-only. WebFetch, WebSearch, ListSubagents, GetSubagentResult and ReadSubagentScreen are read-only but hidden in plan mode. TodoWrite, Wait, AskUserQuestion and A2A_QueryAgent are offered in plan mode but are not read-only. RequestPlanApproval is plan-only. Mapping everything onto one
read_onlyflag would change what the model sees. Both are really the same question - which agent modes a tool runs in - so a manifest lists them:modes: [standard, auto, auto-with-judge, plan, readonly](mode keys as inParseAgentMode); omitted means the unrestricted modes (standard, auto, auto-with-judge). A tool listingreadonlymust change nothing: read-only subagents get it and its calls run concurrently. Every mode still advertises the same tool list so a mode switch keeps the prompt cache; a call outside the tool's modes is rejected at execution with a message to the model. require_approvalneeds an "inherit" state. Most built-ins have no default of their own and followtools.safety.require_approval, so an omitted field must mean "use the global setting". Custom tools in [FEATURE] Allow registering custom tools in any language #1366 can keep defaulting totrue.
Why execution stays in-process (not moved to cmd/tools)
Also considered: moving each tool's execution behind cmd/tools so a built-in manifest could be command: [infer, tools, execute, Read], exactly like a custom tool. Not recommended:
infer tools execute <Tool> '<json>'already runs every built-in through the agent's code path. What [FEATURE] Allow registering custom tools in any language #1366 is missing is the definition side, not a CLI entry point.- Every call would spawn a process and build the full service container (
container.NewServiceContainer), on the hottest tools (Read, Grep, Edit). - Many tools depend on per-session in-memory state: the Edit/MultiEdit read-before-edit guard and file snapshots (
Registry.readToolUsed/readFiles), background shells (Bash, BashOutput, KillShell, ListShells), the subagent tracker (Agent and its six sibling tools), and the chat UI (AskUserQuestion, RequestApproval, RequestPlanApproval). - Read, Edit, Grep and TodoWrite return structured
Data(image content, diffs, matches, the todo list) that the TUI renders. The [FEATURE] Allow registering custom tools in any language #1366 contract is plain stdout text. cmd/is the Cobra and composition layer. Tool logic belongs ininternal/agent/toolsper the bounded-context layout.
If a stateless subset (Tree, Grep, WebFetch, WebSearch) should ever run out of process, that is a separate issue.
Suggested split
- Manifest type and loader, plus the file tools: Read, Write, Edit, MultiEdit, Delete, Grep, Tree, Bash.
- The remaining tools in
internal/agent/tools/, then browser and computer.
Acceptance Criteria
- A manifest type and loader that [FEATURE] Allow registering custom tools in any language #1366 reuses: it parses the fields a built-in tool needs plus
modesand validates the name and the parameters schema. The custom-tool fields (command,timeout,enabled) and rejecting a manifest from disk withoutcommandland with [FEATURE] Allow registering custom tools in any language #1366, alongside their first caller. - Every built-in tool in
internal/agent/tools/has an embedded manifest and builds itsDefinition()from it. The hand-written schema maps are deleted. - Browser and computer tools get embedded manifests in their own packages through the same loader.
-
ReadOnlyTools,planModeAllowedTools,planOnlyToolsand the hardcoded per-tool defaults inConfig.IsApprovalRequiredare derived from the manifests. Per-tool config overrides (tools.<name>.require_approval,enabled) keep working;prompts.yamltool description overrides are removed, the manifest is the only source. - No behavior change: a golden test, generated from
mainbefore the refactor, pins the JSON ofGetToolDefinitions()and the tool lists per agent mode (standard, plan, readonly), and passes unchanged after it. Byte-identical definitions also keep the provider prompt cache stable. - Existing tool tests pass; only tests of the removed
prompts.yamltool overrides and of the moved approval rules changed.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
refactor(tools): drop the custom-tool manifest parser until it has a …
refactor(tools): declare the agent modes a tool runs in
refactor(tools): define built-in tools through embedded manifests (#1369
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 📦🚀