feat(agent): add tool call prefix stripping and assistant prefill removal for proxy provider compatibility #224
Closed
xuandung38 wants to merge 3 commits into
Closed
Conversation
0f13bea to
327f175
Compare
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)
…LM call
Some LLM providers and models do not support assistant message prefill
— requests ending with an assistant-role message get rejected with
HTTP 400 ("This model does not support assistant message prefill").
This happens when the system injects assistant messages to guide model
behavior or establish context.
Add per-agent strip_assistant_prefill toggle (stored in other_config)
that removes the trailing assistant message before constructing the
ChatRequest. The option is configurable in the LLM Configuration
section of the agent General tab.
- Add ParseStripAssistantPrefill() to AgentData (reads from other_config)
- Add stripAssistantPrefill field to Loop/LoopConfig
- Wire through resolver → loop
- Add checkbox UI in LLM Config section with i18n (en/vi/zh)
Add .gemini/, .claude/, .opencode/ to .gitignore to prevent committing user-specific AI tool configurations.
327f175 to
138162d
Compare
Contributor
Author
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
Two per-agent options to support proxy LLM providers (LiteLLM, OpenRouter, etc.):
1. Tool Call Prefix Stripping
Proxy providers may prepend a prefix to tool call names returned by the model (e.g.
proxy_execinstead ofexec),causing tool policy validation failures and registry lookup errors.
Per-agent
toolCallPrefixconfig strips the prefix before registry lookup, permission checks, andteam_tasks/spawndetection in both serial and parallel paths. Supports literal prefixes (proxy_) and templatepatterns (
proxy_{tool_name}).2. Strip Assistant Prefill
Some models/providers reject requests ending with an assistant-role message (HTTP 400: "This model does not support
assistant message prefill").
Per-agent
strip_assistant_prefilltoggle removes trailing assistant messages before sending to the LLM. Configurablein LLM Configuration (General tab), stored in
other_config.Additional Fix
Config save handler now uses spread operator instead of hardcoded field list — new fields were silently dropped on
save.