Skip to content

fix(cli): mapToDisplay uses unbounded JSON.stringify for ErroredToolCall description #22591

@TravisHaa

Description

@TravisHaa

Bug Description

In packages/cli/src/ui/hooks/toolMapping.ts, when a tool call errors before its invocation is built, the display description falls back to the raw serialized args:

if (call.status === CoreToolCallStatus.Error) {
  description = JSON.stringify(call.request.args);
}

There is no length cap. Tools called with large payloads — write_file with a full file body, execute_code with a long script, MCP tools with structured input — produce descriptions that are hundreds of kilobytes long. This string is rendered as a single line in the tree node row, causing:

  • Layout overflow in the task tree and flat tool list
  • Excessive re-render cost as Ink tries to measure and wrap the string
  • Potential terminal emulator slowdowns from a single massive text node

Fix

Truncate to 120 characters with an ellipsis:

const rawArgs = JSON.stringify(call.request.args);
description = rawArgs.length > 120 ? rawArgs.slice(0, 117) + '...' : rawArgs;

Metadata

Metadata

Assignees

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalityhelp wantedWe will accept PRs from all issues marked as "help wanted". Thanks for your support!

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions