fix: render markdown in assistant panels and speed up reasoning-only recovery

Assistant message panels now use Markdown() instead of raw strings, so
bold/italic/lists render properly. Also nudge the model immediately after
tool errors instead of wasting 2 retry iterations in reasoning-only mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 18:21:51 -05:00
parent 90a38f12d1
commit cc03f76593
2 changed files with 11 additions and 3 deletions

View File

@@ -153,7 +153,14 @@ class AgentLoop:
reasoning_only_streak += 1
self._ctx.pop_last_message()
if reasoning_only_streak >= _MAX_REASONING_RETRIES:
# If the last context messages are tool errors, nudge immediately
# rather than wasting retries — the model is likely confused by the error.
has_recent_tool_error = any(
m.role == "tool" and m.content and m.content.startswith("Unknown ")
for m in self._ctx.get_history()[-3:]
)
if has_recent_tool_error or reasoning_only_streak >= _MAX_REASONING_RETRIES:
# Nudge the model by injecting a user hint
if self._display:
self._display.write_warning(
@@ -162,7 +169,7 @@ class AgentLoop:
)
self._ctx.add_message(
"user",
"Please respond with your answer. Do not just think — provide your actual response.",
"Please respond with your answer. If a tool call failed, briefly explain what happened and continue.",
)
reasoning_only_streak = 0
else: