diff --git a/internal/promptcompat/prompt_build_test.go b/internal/promptcompat/prompt_build_test.go index 23ec237..0c9b87b 100644 --- a/internal/promptcompat/prompt_build_test.go +++ b/internal/promptcompat/prompt_build_test.go @@ -74,7 +74,7 @@ func TestBuildOpenAIFinalPrompt_VercelPreparePathKeepsFinalAnswerInstruction(t * } finalPrompt, _ := buildOpenAIFinalPrompt(messages, tools, "", false) - if !strings.Contains(finalPrompt, "Remember: The ONLY valid way to use tools is the <|DSML|tool_calls>...<|/DSML|tool_calls> block at the end of your response.") { + if !strings.Contains(finalPrompt, "Remember: The ONLY valid way to use tools is the <|DSML|tool_calls>... block at the end of your response.") { t.Fatalf("vercel prepare finalPrompt missing final tool-call anchor instruction: %q", finalPrompt) } if !strings.Contains(finalPrompt, "TOOL CALL FORMAT") { diff --git a/internal/toolcall/tool_prompt.go b/internal/toolcall/tool_prompt.go index 8be9ee3..a327261 100644 --- a/internal/toolcall/tool_prompt.go +++ b/internal/toolcall/tool_prompt.go @@ -13,43 +13,43 @@ func BuildToolCallInstructions(toolNames []string) string { <|DSML|tool_calls> <|DSML|invoke name="TOOL_NAME_HERE"> - <|DSML|parameter name="PARAMETER_NAME"><|/DSML|parameter> - <|/DSML|invoke> -<|/DSML|tool_calls> + <|DSML|parameter name="PARAMETER_NAME"> + + RULES: 1) Use the <|DSML|tool_calls> wrapper format. 2) Put one or more <|DSML|invoke> entries under a single <|DSML|tool_calls> root. 3) Put the tool name in the invoke name attribute: <|DSML|invoke name="TOOL_NAME">. 4) All string values must use , even short ones. This includes code, scripts, file contents, prompts, paths, names, and queries. -5) Every top-level argument must be a <|DSML|parameter name="ARG_NAME">...<|/DSML|parameter> node. +5) Every top-level argument must be a <|DSML|parameter name="ARG_NAME">... node. 6) Objects use nested XML elements inside the parameter body. Arrays may repeat children. 7) Numbers, booleans, and null stay plain text. 8) Use only the parameter names in the tool schema. Do not invent fields. 9) Do NOT wrap XML in markdown fences. Do NOT output explanations, role markers, or internal monologue. 10) If you call a tool, the first non-whitespace characters of that tool block must be exactly <|DSML|tool_calls>. -11) Never omit the opening <|DSML|tool_calls> tag, even if you already plan to close with <|/DSML|tool_calls>. +11) Never omit the opening <|DSML|tool_calls> tag, even if you already plan to close with . 12) Compatibility note: the runtime also accepts the legacy XML tags / / , but prefer the DSML-prefixed form above. PARAMETER SHAPES: -- string => <|DSML|parameter name="x"><|/DSML|parameter> -- object => <|DSML|parameter name="x">...<|/DSML|parameter> -- array => <|DSML|parameter name="x">......<|/DSML|parameter> -- number/bool/null => <|DSML|parameter name="x">plain_text<|/DSML|parameter> +- string => <|DSML|parameter name="x"> +- object => <|DSML|parameter name="x">... +- array => <|DSML|parameter name="x">...... +- number/bool/null => <|DSML|parameter name="x">plain_text 【WRONG — Do NOT do these】: Wrong 1 — mixed text after XML: - <|DSML|tool_calls>...<|/DSML|tool_calls> I hope this helps. + <|DSML|tool_calls>... I hope this helps. Wrong 2 — Markdown code fences: ` + "```xml" + ` - <|DSML|tool_calls>...<|/DSML|tool_calls> + <|DSML|tool_calls>... ` + "```" + ` Wrong 3 — missing opening wrapper: - <|DSML|invoke name="TOOL_NAME">...<|/DSML|invoke> - <|/DSML|tool_calls> + <|DSML|invoke name="TOOL_NAME">... + -Remember: The ONLY valid way to use tools is the <|DSML|tool_calls>...<|/DSML|tool_calls> block at the end of your response. +Remember: The ONLY valid way to use tools is the <|DSML|tool_calls>... block at the end of your response. ` + buildCorrectToolExamples(toolNames) }