Suppress structuredContent when visible Content is present (#240)
## Summary Refines the human-readable output formatting for tool call results to avoid redundant information. When a tool result contains both `content` (with visible text blocks) and `structuredContent`, the structured content is now suppressed since it duplicates information already conveyed by the content blocks. The full payload remains available via `--json` mode. ## Changes - **Output logic**: Modified `formatCallToolResultHuman()` to only display `structuredContent` when there is no visible `content`. This reduces noise in human-readable output while preserving all information in JSON mode. - **Test updates**: Updated and added test cases to reflect the new behavior: - `structuredContent` is shown only when `content` is empty - `structuredContent` is suppressed when visible content blocks are present - Verified correct section ordering: Content → Metadata (when content present) or Structured content → Metadata (when content empty) - **Documentation**: Updated JSDoc comments in `output.ts` to clarify that `structuredContent` is shown only when there is no visible Content, and that the full payload is available via `--json`. ## Implementation Details - Introduced `visibleContent` variable to track content blocks after filtering out duplicates, making the logic clearer and more maintainable - The suppression applies consistently: any visible content (even a single text block) causes `structuredContent` to be hidden - This aligns with the design principle of avoiding unnecessary verbose output for LLM consumers while maintaining full transparency in structured output modes https://claude.ai/code/session_01V9qveFdBMjXQAb1wcZnE9b Co-authored-by: Claude <noreply@anthropic.com>
J
Jan Curn committed
d368c4d47e6569ca86ee039c8de437e20e500833
Parent: cfd3add
Committed by GitHub <noreply@github.com>
on 5/20/2026, 10:34:02 PM