[AUTO-BUG-2] TDD: session tell --stream writes directly to sys.stdout bypassing redaction #10458

Open
opened 2026-04-18 09:50:08 +00:00 by HAL9000 · 0 comments
Owner

Metadata

  • Commit Message: test(cli): add failing TDD test for session tell --stream bypassing redaction
  • Branch Name: test/tdd-session-tell-stream-redaction

Background and Context

session tell --stream in src/cleveragents/cli/commands/session.py (lines 843–848) writes the assistant response directly to sys.stdout using sys.stdout.write(char) in a character-by-character loop. This bypasses the Rich console and the redaction layer (_redact_data() in formatting.py).

The spec requires that all CLI output passes through the redaction layer before being written to stdout. The streaming path is the only code path in the CLI that writes directly to sys.stdout without redaction.

Code showing the bug (src/cleveragents/cli/commands/session.py, lines 843–848):

if stream:
    # Simulate streaming by printing character by character
    for char in assistant_content:
        sys.stdout.write(char)  # ← DIRECT STDOUT, NO REDACTION
        sys.stdout.flush()
    sys.stdout.write("\n")

This TDD issue captures the failing test that must be written before the fix is applied.

Expected Behavior

When --stream is used, the assistant response should be written through the Rich console (or at minimum through the redaction layer) so that sensitive values are masked before being written to stdout.

Acceptance Criteria

  • A failing test is written that verifies session tell --stream does NOT write directly to sys.stdout bypassing redaction
  • The test is tagged with @tdd_issue, @tdd_issue_N, @tdd_expected_fail
  • The test fails before the fix is applied
  • The test passes after the fix is applied (see parent bug issue)

Subtasks

  • Write failing BDD scenario tagged @tdd_issue, @tdd_expected_fail asserting streaming output goes through redaction
  • Confirm test fails before fix
  • Confirm test passes after fix is applied

Definition of Done

  • Failing test written and committed
  • Test is marked @tdd_expected_fail
  • Test fails for the right reason (direct sys.stdout.write, not an import error)

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `test(cli): add failing TDD test for session tell --stream bypassing redaction` - **Branch Name**: `test/tdd-session-tell-stream-redaction` ## Background and Context `session tell --stream` in `src/cleveragents/cli/commands/session.py` (lines 843–848) writes the assistant response directly to `sys.stdout` using `sys.stdout.write(char)` in a character-by-character loop. This bypasses the Rich console and the redaction layer (`_redact_data()` in `formatting.py`). The spec requires that all CLI output passes through the redaction layer before being written to stdout. The streaming path is the only code path in the CLI that writes directly to `sys.stdout` without redaction. **Code showing the bug** (`src/cleveragents/cli/commands/session.py`, lines 843–848): ```python if stream: # Simulate streaming by printing character by character for char in assistant_content: sys.stdout.write(char) # ← DIRECT STDOUT, NO REDACTION sys.stdout.flush() sys.stdout.write("\n") ``` This TDD issue captures the failing test that must be written before the fix is applied. ## Expected Behavior When `--stream` is used, the assistant response should be written through the Rich console (or at minimum through the redaction layer) so that sensitive values are masked before being written to stdout. ## Acceptance Criteria - [ ] A failing test is written that verifies `session tell --stream` does NOT write directly to `sys.stdout` bypassing redaction - [ ] The test is tagged with `@tdd_issue`, `@tdd_issue_N`, `@tdd_expected_fail` - [ ] The test fails before the fix is applied - [ ] The test passes after the fix is applied (see parent bug issue) ## Subtasks - [ ] Write failing BDD scenario tagged `@tdd_issue`, `@tdd_expected_fail` asserting streaming output goes through redaction - [ ] Confirm test fails before fix - [ ] Confirm test passes after fix is applied ## Definition of Done - [ ] Failing test written and committed - [ ] Test is marked `@tdd_expected_fail` - [ ] Test fails for the right reason (direct sys.stdout.write, not an import error) --- **Automated by CleverAgents Bot** Agent: new-issue-creator
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#10458
No description provided.