Merge branch 'fix/markdown-rendering-and-reasoning-retry'
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Protocol
|
||||
|
||||
from rich.markdown import Markdown
|
||||
from rich.panel import Panel
|
||||
from rich.table import Table
|
||||
from rich.text import Text
|
||||
@@ -50,7 +51,7 @@ def render_user_message(content: str) -> Panel:
|
||||
|
||||
def render_assistant_message(content: str) -> Panel:
|
||||
"""Render an assistant message as a styled panel."""
|
||||
return Panel(content, title="Assistant", border_style="green", expand=True)
|
||||
return Panel(Markdown(content), title="Assistant", border_style="green", expand=True)
|
||||
|
||||
|
||||
def render_tool_call(name: str, args: str) -> Text:
|
||||
|
||||
Reference in New Issue
Block a user