feat(agent): tool call prefix stripping for proxy providers#259
Merged
viettranx merged 3 commits intoMar 20, 2026
Merged
Conversation
Proxy providers like LiteLLM and OpenRouter may prepend a prefix to
tool call names returned by the model (e.g. "proxy_exec" instead of
"exec"). This broke tool policy validation, registry lookup, and
hardcoded name checks for "team_tasks" and "spawn" in both serial
and parallel execution paths.
Add per-agent toolCallPrefix configuration that strips the configured
prefix from incoming tool call names before registry resolution. The
stripping is applied at resolveToolCallName() which is called before
permission checks, registry execution, and spawn/team_tasks detection.
- Add StripToolPrefix() supporting literal ("proxy_") and template
("{tool_name}") patterns
- Add toolCallPrefix to ToolPolicySpec with backward compat from old
"toolPrefix" JSON key
- Fix config save using spread operator to prevent dropping new fields
- Add UI input in Tool Policy section with i18n (en/vi/zh)
Add .gemini/, .claude/, .opencode/ to .gitignore to prevent committing user-specific AI tool configurations.
…-stripping # Conflicts: # internal/agent/loop.go # ui/web/src/pages/agents/agent-detail/agent-config-tab.tsx
viettranx
added a commit
that referenced
this pull request
Mar 20, 2026
- Fix TrimLeft → TrimPrefix to strip only one underscore separator - Add registryName to indexedResult for parallel path cache - Use registryName for bootstrapToolAllowlist and loopDetector checks - Add server-side sanitization for ToolCallPrefix input - Remove dead chatMessages alias and unrelated ParseStripAssistantPrefill - Remove orphaned stripAssistantPrefill i18n keys - Add 13 unit tests for StripToolPrefix
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.
Summary
Proxy LLM providers like LiteLLM and OpenRouter may prepend a configurable prefix to tool call names returned by the model. For example, if the prefix template is
proxy_{tool_name}, the model returnsproxy_execinstead ofexec.This broke multiple systems:
proxy_execnot in the allow list → blockedproxy_exec→ execution failedteam_tasksandspawndetection in serial/parallel paths failed when prefixedChanges
StripToolPrefix()ininternal/tools/policy.goproxy_) and template pattern (proxy_{tool_name})resolveToolCallName()ininternal/agent/loop.goregistryName(stripped) for all downstream operations while preserving originaltc.Namein logs/spansAgent config persistence (
internal/store/agent_store.go)ParseToolCallPrefix()reads fromtool_policy_config.toolCallPrefixtoolPrefixJSON keyFrontend (
ui/web)prefix_{tool_name}Files Changed
internal/agent/loop.goresolveToolCallName(), useregistryNamein serial + parallel pathsinternal/config/config_channels.goToolCallPrefixtoToolPolicySpecinternal/store/agent_store.goParseToolCallPrefix()with backward compatinternal/tools/policy.goStripToolPrefix()functionui/web/.../tool-policy-section.tsxui/web/.../agent-config-tab.tsxui/web/src/types/agent.tstoolCallPrefixtoToolPolicyConfigui/web/src/i18n/locales/{en,vi,zh}/agents.json.gitignoreHow It Works
Test Plan
toolCallPrefix: "proxy_{tool_name}"team_tasksandspawndetection works with prefixed names