refactor(loop): remove interim text retry, use system prompt constraint instead

This commit is contained in:
Re-bin
2026-02-21 07:32:58 +00:00
parent a0820eceee
commit aeb07d3450
2 changed files with 1 additions and 15 deletions

View File

@@ -106,6 +106,7 @@ Only use the 'message' tool when you need to send a message to a specific chat c
For normal conversation, just respond with text - do not call the message tool. For normal conversation, just respond with text - do not call the message tool.
Always be helpful, accurate, and concise. Before calling tools, briefly tell the user what you're about to do (one short sentence in the user's language). Always be helpful, accurate, and concise. Before calling tools, briefly tell the user what you're about to do (one short sentence in the user's language).
If you need to use tools, call them directly — never send a preliminary message like "Let me check" without actually calling a tool.
When remembering something important, write to {workspace_path}/memory/MEMORY.md When remembering something important, write to {workspace_path}/memory/MEMORY.md
To recall past events, grep {workspace_path}/memory/HISTORY.md""" To recall past events, grep {workspace_path}/memory/HISTORY.md"""

View File

@@ -202,8 +202,6 @@ class AgentLoop:
iteration = 0 iteration = 0
final_content = None final_content = None
tools_used: list[str] = [] tools_used: list[str] = []
text_only_retried = False
interim_content: str | None = None # Fallback if retry produces nothing
while iteration < self.max_iterations: while iteration < self.max_iterations:
iteration += 1 iteration += 1
@@ -249,19 +247,6 @@ 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; save the content as fallback in case
# the retry produces nothing useful (e.g. model already answered).
if not tools_used and not text_only_retried and final_content:
text_only_retried = True
interim_content = final_content
logger.debug("Interim text response (no tools used yet), retrying: {}", final_content[:80])
final_content = None
continue
# Fall back to interim content if retry produced nothing
# and no tools were used (if tools ran, interim was truly interim)
if not final_content and interim_content and not tools_used:
final_content = interim_content
break break
return final_content, tools_used return final_content, tools_used