Skip to content

Conversation

@snimu
Copy link
Contributor

@snimu snimu commented Jan 29, 2026

Description

Since tools are json-serialized, they are no longer correctly displayed in the tui:

image

This PR fixes that problem:

image

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Note

Low Risk
Low risk refactor/bugfix limited to Rich formatting utilities and call sites; main risk is minor display regressions or unexpected tool-call string shapes causing JSON decode errors.

Overview
Fixes Rich/TUI rendering of prompts/completions when tool_calls are stored as JSON strings by introducing a shared format_messages() helper that deserializes and pretty-prints tool calls.

Removes duplicated message-formatting code in eval_display.py and logging_utils.py and switches both to the new shared formatter to keep prompt/completion display consistent.

Written by Cursor Bugbot for commit c684082. This will update automatically on new commits. Configure here.


def normalize_tool_call(tc: Any) -> dict[str, str]:
if isinstance(tc, str):
tc = json.loads(tc)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unhandled JSON parse error in tool call normalization

Medium Severity

The new normalize_tool_call function calls json.loads(tc) when tc is a string, but this call is not wrapped in a try-except block. If a malformed JSON string is encountered (e.g., corrupted data, old format, or encoding issues), a json.JSONDecodeError will be raised and propagate up, potentially crashing the TUI display. This is inconsistent with the defensive handling of json.dumps(args) later in the same function, which is wrapped in a try-except.

Fix in Cursor Fix in Web

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@snimu snimu requested a review from willccbb January 29, 2026 06:35
Copy link
Member

@mikasenghaas mikasenghaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@snimu snimu merged commit 0d6cec5 into main Jan 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants