fix: handle string results in tool renderers

Previously, tool renderers assumed result was always a dict and would
crash with AttributeError when result was a string (e.g., error messages).
Now all renderers properly check for string results and display them.
This commit is contained in:
0xallam
2026-01-09 16:32:40 -08:00
committed by Ahmed Allam
parent 226678f3f2
commit 7b7ea59a37
6 changed files with 71 additions and 17 deletions
@@ -104,7 +104,13 @@ class PythonRenderer(BaseToolRenderer):
return text
@classmethod
def _append_output(cls, text: Text, result: dict[str, Any]) -> None:
def _append_output(cls, text: Text, result: dict[str, Any] | str) -> None:
if isinstance(result, str):
if result.strip():
text.append("\n")
text.append_text(cls._format_output(result))
return
stdout = result.get("stdout", "")
stderr = result.get("stderr", "")
@@ -143,7 +149,7 @@ class PythonRenderer(BaseToolRenderer):
else:
text.append("Running...", style="dim")
if result and isinstance(result, dict):
if result:
cls._append_output(text, result)
css_classes = cls.get_css_classes(status)