Repository navigation
feat(config): move the tools policy into a protected userspace tools.yaml - #1507
Conversation
…yaml The tools section decides whether a tool needs approval, so it gets the sandbox.yaml treatment: its own userspace file that no config.yaml layer can carry. ToolsFileName, DefaultToolsConfig, LoadTools, SaveTools and UserToolsPath land in config/tools.go mirroring config/sandbox.go, DefaultConfig() pulls from DefaultToolsConfig(), and the Config.Tools field drops out of config.yaml round-trips. The config package round-trip tests now pin the new invariant: a tools: block in config.yaml is ignored, and tools settings are not written back into it.
|
@infer /model deepseek/deepseek-v4-pro can you finalise this PR? finish the todos and make it ready for review? use /cobra-viper /go |
|
Model: Todos
Pull Request✅ Infer Result: SuccessThe PR is now finalized and pushed. All acceptance criteria from #1501 are implemented and the full test suite passes ( What I completedThe original diff covered the core split ( 1. Protected
2.
3.
4. Docs (
Commits
Working tree is clean and Model: Tokens: 13,186,562 in · 45,265 out · 13,231,827 total (54 requests) Cost: $0.4359 in · $0.0394 out · $0.4753 total Tool calls: 105 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
The migration read the layered config, so infer init copied a project .infer/config.yaml tools block into the userspace tools.yaml. It also only ran under --overwrite and dropped a block that failed to decode. tools.yaml is now seeded from the defaults the way sandbox.yaml is, and a tools: block in config.yaml simply has no effect. The legacy-block warning goes too, matching the other sidecar files.
DefaultToolsConfig said every tool was enabled, but schedule is off. The doc comment also ran past five lines, injectTools carried a semicolon and Config.Tools had a trailing comment its sibling sidecar fields do not.
tools.yaml holds the tools keys at its root, so the examples that wrapped them in a tools: key would have been silently ignored. The tools block moves out of the config.yaml samples into its own tools.yaml sample, the custom tools trust model no longer says a project can set the approval policy, and the infer config set tools.* examples are gone.
… under tools: tools.yaml now opens with the keys that apply to every tool (enabled, custom_dir, max_result_bytes and safety) and holds each tool's section under tools:. ToolsConfig keeps its flat Go shape, so cfg.Tools.Bash, the INFER_TOOLS_* names and infer config get tools.bash are unchanged.
The examples put the keys for every tool first and each tool's section under tools:, matching the file infer init seeds.
|
🎉 This PR is included in version 0.223.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #1501
Summary
Moves the whole
tools:section out ofconfig.yamlinto a userspace-only~/.infer/tools.yamlthat infer's file tools andinfer config setnever write, the same waysandbox.yamlalready works. Nothing that decides whether a tool needs approval can be flipped by a single approved file write or by a project.infer/config.yamlany more. This unblocks the/configskill (#1499), whose prerequisite this is. #1502 remains open for sidecar reload in chat.Changes
config/tools.go(new):ToolsFileName,DefaultToolsConfig(),LoadToolsviaconfigutils.LoadYAMLMerged,SaveToolsandUserToolsPath(), mirroringconfig/sandbox.go.tools.yamlopens with the keys that apply to every tool (enabled,custom_dir,max_result_bytes,safety) and holds each tool's section undertools:.ToolsConfigkeeps its flat Go shape (a small YAML codec does the nesting), socfg.Tools.Bash, theINFER_TOOLS_*names andconfig get tools.bashstay the same.Config.Toolsis nowyaml:"-" mapstructure:"-". The runtime loads it from~/.infer/tools.yamlonly, next toloadSandboxConfig. Atools:block in anyconfig.yamland a project.infer/tools.yamlhave no effect.INFER_TOOLS_*env overrides keep working throughapplySidecarEnv(&cfg.Tools, "tools"). Like the other sidecars, a set-but-emptyINFER_TOOLS_*value now wins (for exampleINFER_TOOLS_WEB_FETCH_ALLOWED_DOMAINS=empties the list).--tools-bash-allow-appendflag andINFER_TOOLS_BASH_ALLOW_APPENDenv append directly onto the loaded tools config instead of a viper key.sandbox.ValidateWriterefuses~/.infer/tools.yamlunconditionally, in the same message style assandbox.yaml. The guard is one list of protected policy files.infer config set tools.*fails with an error namingtools.yaml.infer config get tools.bashstill prints the effective value (the tools section is injected into the get dump).infer initseedstools.yamlfrom the defaults exactly likesandbox.yaml, and--overwriteregenerates it.configuration-reference.mdgets atools.yamlsample under Tool Settings in place of thetools:block in theconfig.yamlsample. Thetools-reference.mdandscheduling.mdexamples aretools.yamlsnippets in the same layout.custom-tools.mdno longer says a project config can set the approval policy.tool-approval.md,directory-structure.md,commands-reference.mdandexamples/basic/README.mddrop theinfer config set tools.*examples.Docs follow-up
inference-gateway/docs#914 updates
cli.mdandcli-judge-mode.md, which still showinfer config set tools.*.