Repository navigation
fix(tools): refuse an unserved subagent model up front and report an overridden one - #1940
Merged
Merged
Conversation
…overridden one A chat that messaged an agent whose file pins a model the gateway does not serve got a dispatched Agent call reporting success, then a subagent failure listing every gateway model, with nothing saying the model came from the agent's file. Retrying with an explicit model ran the pinned model again, as docs/subagents.md documents, but silently. - The Agent tool lists the served models once per call and refuses a task whose model is not among them before anything is dispatched. For a model an agent file pins, the error names the file and says a task's model cannot override it. An unknown list never blocks a spawn. - When an agent file's model replaces a task's explicit model, the tool result says so. - The container builds the model service before the tool registry and hands it to the Agent tool through RegistryDeps.Models. - resolveModel's comment and docs/subagents.md describe the behavior. Resolves #1939
Contributor
|
🎉 This PR is included in version 0.266.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1939
Summary
A desktop chat was asked to message the
testeragent, whose file pinnedmodel: mock/openai/gpt-4o, a model that only exists in mock mode. TheAgentcall reportedStatus: Success, then the subagent failed withopening the subagent's thread: model "mock/openai/gpt-4o" not available. Available: [...], listing about forty gateway models and never mentioning the agent's file. The calling agent retried with an explicitmodel: anthropic/claude-haiku-5-5, which ran the pinned model again (docs/subagents.md says the file's model wins) but silently. It told the user the retry ran on Haiku, and finally invented a stand-in agent. The precedence rule stays as documented. What changes is that the tool now says what happens. no docs ticket: the CLI docs are updated in this PRChanges
internal/tools/agent.go:Agenttool lists the served models once per call (ListModels, cached with its TTL) and refuses a task whose resolved model is not among them, before anything is dispatched. For a model an agent file pins, the error names the agent and its file and says a task'smodelcannot override it, for exampleagent tester cannot run: its file ~/.infer/agents/tester.md pins model "mock/openai/gpt-4o", which the gateway does not serve.... Any other unserved model suggests the chat's own model. A failed or empty list never blocks a spawn.model, the result carries a note:model "anthropic/claude-haiku-5-5" not used for agent tester - its file pins "mock/openai/gpt-4o", and an agent file's model wins over a task's.resolveModel's comment no longer claims the per-task model always comes first.internal/tools/registry.go:RegistryDeps.Models(convdomain.ModelService) reaches theAgenttool. A nil value skips the check.internal/container/container.go: the model service is built just before the tool registry instead of just after, so the registry can take it. It depends only on the daemon thread and the SDK client, both of which exist by then.docs/subagents.md: the Model section describes the note and the up-front refusal.Verification
TestAgentTool_UnservedModelFailsBeforeDispatch, using theFakeModelServicefromtests/mocks/conversation. Four cases: a pinned unserved model is refused with the file path and nothing dispatched, an unserved task model suggests the chat's model, a served pinned model runs, and a list error never blocks.TestAgentTool_NamedAgentModelOverrideIsReported, and the existingTestAgentTool_NamedAgentModelPrecedencestill pins "file model beats per-task model".go test ./...: 129 packages pass.task precommit:run: 0 lint issues.