Skip to content

Tool card args preview shows full JSON regardless of length, making cards unreadable #9

Description

@FernandoCelmer

Problem

In media/chat-tools.js, the argsPreview() function dumps the entire serialized arguments object into the tool card header:

function argsPreview(args) {
  try {
    return JSON.stringify(args);
  } catch {
    return String(args);
  }
}

When the agent calls write_file or edit_file with a large file body, or bash with a long script, the one-line preview in the collapsed card header becomes hundreds of characters — the tool name is pushed off-screen and the preview is meaningless.

Steps to reproduce / context

  1. Ask CodeLoop to write a file with more than ~50 lines.
  2. Watch the write_file tool card — the header overflows with the full file content serialized as JSON.

Expected behavior

The args preview in the header (collapsed state) should be truncated to a short summary (e.g. 80 characters) with an ellipsis. The full JSON is already visible in the expanded card body (argsPre), so no information is lost.

Suggested fix

const MAX_PREVIEW = 80;
function argsPreview(args) {
  try {
    const s = JSON.stringify(args);
    return s.length > MAX_PREVIEW ? s.slice(0, MAX_PREVIEW) + "…" : s;
  } catch {
    return String(args).slice(0, MAX_PREVIEW);
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions