UAT: format_output() renders color format as plain text — no ANSI color codes emitted #2101

Closed
opened 2026-04-03 04:04:09 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/format-output-color-no-ansi
  • Commit Message: fix(cli): format_output() color format should emit ANSI color codes
  • Milestone: v3.7.0
  • Parent Epic: #936

Subtasks

  • Update format_output() in src/cleveragents/cli/formatting.py to use _format_color() (or equivalent) for the color format
  • Implement _format_color() using the existing ColorMaterializer or _color_renderers.py functions
  • Add unit tests (Behave) for format_output(data, 'color') producing ANSI codes
  • Verify that agents version --format color emits ANSI-colored output

Definition of Done

  • format_output(data, 'color') returns a string containing ANSI escape codes
  • agents version --format color outputs colored text with ANSI codes
  • agents session list --format color outputs colored text with ANSI codes
  • Tests pass at ≥97% coverage

Bug Report

What Was Tested

The spec (§Output Rendering Framework, §Format Descriptions) defines the color format as:

color: Plain scrolling text enhanced with ANSI color codes for readability. For terminals that support color but not advanced rendering features like those in rich.

Expected Behavior (from spec)

format_output(data, 'color') should return a string with ANSI color codes applied to keys, values, and structural elements.

Actual Behavior

format_output(data, 'color') returns plain text with no ANSI codes — identical to the plain format output:

from cleveragents.cli.formatting import format_output
data = {'key': 'value', 'status': 'active'}
result = format_output(data, 'color')
# Result: 'key: value\nstatus: active'
# Expected: '\033[1m\033[36mkey\033[0m: value\n\033[1m\033[36mstatus\033[0m: active'

Running agents version --format color outputs plain text without any ANSI color codes.

Root Cause

In src/cleveragents/cli/formatting.py, the format_output() function has this code:

if fmt == OutputFormat.COLOR.value:
    return _format_plain(safe_data)  # BUG: uses plain renderer, not color renderer

The color format falls through to _format_plain() instead of using a color-aware renderer. The ColorMaterializer and _color_renderers.py module exist and correctly produce ANSI-colored output, but format_output() does not use them.

Code Location

  • src/cleveragents/cli/formatting.pyformat_output() function, the color branch (line ~175)
  • The fix should use _format_color() (to be implemented) or delegate to ColorMaterializer

Steps to Reproduce

from cleveragents.cli.formatting import format_output
data = {'key': 'value', 'status': 'active'}
result = format_output(data, 'color')
has_ansi = '\033[' in result
print(has_ansi)  # False — should be True

Severity

Medium — The color format is one of the 6 spec-required output formats. Users who explicitly request --format color expect ANSI-colored output but receive plain text instead.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/format-output-color-no-ansi` - **Commit Message**: `fix(cli): format_output() color format should emit ANSI color codes` - **Milestone**: v3.7.0 - **Parent Epic**: #936 ## Subtasks - [ ] Update `format_output()` in `src/cleveragents/cli/formatting.py` to use `_format_color()` (or equivalent) for the `color` format - [ ] Implement `_format_color()` using the existing `ColorMaterializer` or `_color_renderers.py` functions - [ ] Add unit tests (Behave) for `format_output(data, 'color')` producing ANSI codes - [ ] Verify that `agents version --format color` emits ANSI-colored output ## Definition of Done - `format_output(data, 'color')` returns a string containing ANSI escape codes - `agents version --format color` outputs colored text with ANSI codes - `agents session list --format color` outputs colored text with ANSI codes - Tests pass at ≥97% coverage ## Bug Report ### What Was Tested The spec (§Output Rendering Framework, §Format Descriptions) defines the `color` format as: > **`color`**: Plain scrolling text enhanced with ANSI color codes for readability. For terminals that support color but not advanced rendering features like those in `rich`. ### Expected Behavior (from spec) `format_output(data, 'color')` should return a string with ANSI color codes applied to keys, values, and structural elements. ### Actual Behavior `format_output(data, 'color')` returns plain text with no ANSI codes — identical to the `plain` format output: ```python from cleveragents.cli.formatting import format_output data = {'key': 'value', 'status': 'active'} result = format_output(data, 'color') # Result: 'key: value\nstatus: active' # Expected: '\033[1m\033[36mkey\033[0m: value\n\033[1m\033[36mstatus\033[0m: active' ``` Running `agents version --format color` outputs plain text without any ANSI color codes. ### Root Cause In `src/cleveragents/cli/formatting.py`, the `format_output()` function has this code: ```python if fmt == OutputFormat.COLOR.value: return _format_plain(safe_data) # BUG: uses plain renderer, not color renderer ``` The `color` format falls through to `_format_plain()` instead of using a color-aware renderer. The `ColorMaterializer` and `_color_renderers.py` module exist and correctly produce ANSI-colored output, but `format_output()` does not use them. ### Code Location - `src/cleveragents/cli/formatting.py` — `format_output()` function, the `color` branch (line ~175) - The fix should use `_format_color()` (to be implemented) or delegate to `ColorMaterializer` ### Steps to Reproduce ```python from cleveragents.cli.formatting import format_output data = {'key': 'value', 'status': 'active'} result = format_output(data, 'color') has_ansi = '\033[' in result print(has_ansi) # False — should be True ``` ### Severity **Medium** — The `color` format is one of the 6 spec-required output formats. Users who explicitly request `--format color` expect ANSI-colored output but receive plain text instead. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Closing as duplicate of #1827. Both issues describe the same bug: format_output() color format returns plain text without ANSI color codes. Issue #1827 was filed earlier (milestone v3.5.0) and is the canonical bug report with State/Verified.

Please track this work in #1827.


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Closing as duplicate of #1827. Both issues describe the same bug: `format_output()` `color` format returns plain text without ANSI color codes. Issue #1827 was filed earlier (milestone v3.5.0) and is the canonical bug report with `State/Verified`. Please track this work in #1827. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#2101
No description provided.