Merge PR #825: allow one retry for models that send interim text before tool calls
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
⚡️ Delivers core agent functionality in just **~4,000** lines of code — **99% smaller** than Clawdbot's 430k+ lines.
|
⚡️ Delivers core agent functionality in just **~4,000** lines of code — **99% smaller** than Clawdbot's 430k+ lines.
|
||||||
|
|
||||||
📏 Real-time line count: **3,781 lines** (run `bash core_agent_lines.sh` to verify anytime)
|
📏 Real-time line count: **3,793 lines** (run `bash core_agent_lines.sh` to verify anytime)
|
||||||
|
|
||||||
## 📢 News
|
## 📢 News
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ class AgentLoop:
|
|||||||
iteration = 0
|
iteration = 0
|
||||||
final_content = None
|
final_content = None
|
||||||
tools_used: list[str] = []
|
tools_used: list[str] = []
|
||||||
|
text_only_retried = False
|
||||||
|
|
||||||
while iteration < self.max_iterations:
|
while iteration < self.max_iterations:
|
||||||
iteration += 1
|
iteration += 1
|
||||||
@@ -226,6 +227,17 @@ class AgentLoop:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
final_content = self._strip_think(response.content)
|
final_content = self._strip_think(response.content)
|
||||||
|
# Some models send an interim text response before tool calls.
|
||||||
|
# Give them one retry; don't forward the text to avoid duplicates.
|
||||||
|
if not tools_used and not text_only_retried and final_content:
|
||||||
|
text_only_retried = True
|
||||||
|
logger.debug("Interim text response (no tools used yet), retrying: {}", final_content[:80])
|
||||||
|
messages = self.context.add_assistant_message(
|
||||||
|
messages, response.content,
|
||||||
|
reasoning_content=response.reasoning_content,
|
||||||
|
)
|
||||||
|
final_content = None
|
||||||
|
continue
|
||||||
break
|
break
|
||||||
|
|
||||||
return final_content, tools_used
|
return final_content, tools_used
|
||||||
|
|||||||
Reference in New Issue
Block a user