* fix(llm): nudge LLM when it expresses tool intent without calling tools
Non-Anthropic models (especially GLM-5 via NEAR AI) frequently output
text like "Let me search for X" without including tool_calls, creating
a frustrating loop where the user waits but nothing happens.
Add llm_signals_tool_intent() detection that matches intent phrases
("let me search", "I'll fetch") while excluding conversational phrases
("let me explain", "let me know") and content inside code blocks.
When detected, inject a nudge message telling the model to actually
call the tool. Cap at 2 consecutive nudges to avoid infinite loops.
Applied to all three agentic loops: dispatcher (interactive chat),
agent/worker (background jobs), and worker/runtime (sandbox containers).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(nudge): address PR #653 review comments
1. Update doc comment to match implementation (code blocks only, not quotes)
2. Use match_indices() instead of find() to check all prefix occurrences
3. Add !available_tools.is_empty() guard in dispatcher nudge check
4. Reset consecutive_tool_intent_nudges on non-intent text responses
5. Add regression test for shadowed prefix detection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(nudge): address second round of PR #653 review comments
1. Strip double-quoted strings in tool-intent detection to avoid false
positives on quoted prose like `"Let me search the database"`.
2. Only reset consecutive_tool_intent_nudges when text does NOT signal
intent — preserves the 2-nudge cap when intent is detected but cap
is already reached.
3. Fix assertion message in nudge_cap test to report correct call index.
4. Add regression test for quoted strings outside code blocks.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
950 B
JSON
42 lines
950 B
JSON
{
|
|
"model_name": "advanced-tool-intent-nudge-recovery",
|
|
"steps": [
|
|
{
|
|
"response": {
|
|
"type": "text",
|
|
"content": "Let me search for that file now.",
|
|
"input_tokens": 50,
|
|
"output_tokens": 10
|
|
}
|
|
},
|
|
{
|
|
"request_hint": { "last_user_message_contains": "tool_calls mechanism" },
|
|
"response": {
|
|
"type": "tool_calls",
|
|
"tool_calls": [
|
|
{
|
|
"id": "call_echo_1",
|
|
"name": "echo",
|
|
"arguments": { "message": "found it" }
|
|
}
|
|
],
|
|
"input_tokens": 100,
|
|
"output_tokens": 15
|
|
}
|
|
},
|
|
{
|
|
"response": {
|
|
"type": "text",
|
|
"content": "I found the file you were looking for. The job is complete.",
|
|
"input_tokens": 150,
|
|
"output_tokens": 20
|
|
}
|
|
}
|
|
],
|
|
"expects": {
|
|
"tools_used": ["echo"],
|
|
"response_contains": ["found"],
|
|
"all_tools_succeeded": true
|
|
}
|
|
}
|