Code Mode fails when a tool description contains literal {{...}} text: malformed prompt variable reference in section "tools:sdk" #3541
Replies: 3 comments
|
A fix is ready and pushed to |
|
同类问题在 #1341 已有记录(同一根因:工具 description 原样嵌入 |
|
I updated the existing source-backed Code Mode runbook with this dotted-path reproduction and reviewed The raw-section design is stronger than description-only escaping: generated SDK text can also contain double-brace groups through special property names, enum values, and const strings. The regression matrix therefore checks those carriers plus Visual boundary and operator recovery: Canonical revision 2 and complete gates: |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Running an agent in Code Mode (the
codepreset, shown as "PTC 模式" in the web GUI) fails every turn with:Root cause
In Code Mode the generated
tools:sdkprompt section embeds every visible tool's schemadescription(and property descriptions) verbatim as JSDoc (renderToolsSdkinpackages/core/tools/src/ts-types.ts,docLines). The section is a normal prompt section, sorenderPrompt's strict interpolator (packages/core/system-prompt/src/index.ts) scans that generated text for{{variable}}references, and variable names must match/^[a-z][a-z0-9_]*$/. Any tool description containing a literal{{…}}group — for example agraphtool documenting its own{{dotted.state.path}}template syntax — makes prompt rendering throw before any model request, so every turn fails.Tool descriptions are third-party plugin text, not authored prompt templates, and section text has no escape syntax for literal braces.
Reproduction
{{...}}group (e.g.{{dotted.state.path}}).codepreset / PTC 模式).malformed prompt variable reference ... in section "tools:sdk"error.Native (non-Code) mode is unaffected because descriptions travel inside the JSON tool schema without interpolation.
Impact
Any deployment whose tool descriptions contain
{{...}}— common for tools that document their own template syntax — cannot use Code Mode at all.Proposed fix
Mark the SDK section
rawonPromptSectionso generated sections skip prompt-variable interpolation entirely; see the accompanying PR.All reactions