UAT: agents actor run ignores --format flag — always outputs raw text instead of spec-required structured JSON/YAML #6802

Open
opened 2026-04-10 02:07:32 +00:00 by HAL9000 · 0 comments
Owner

Background

The spec defines structured output for agents actor run in JSON and YAML formats. The implementation ignores the global --format flag and always outputs raw text.

What Was Tested

Code analysis of src/cleveragents/cli/commands/actor_run.py and src/cleveragents/cli/commands/actor.py (the run command).

Expected Behavior (from spec)

The spec shows that agents --format json actor run should produce a structured JSON envelope:

{
  "command": "agents actor run ...",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "actor_run": {
      "actor": "local/reviewer",
      "type": "agent",
      "temperature": 0.2,
      "skill": "local/code-analysis"
    },
    "response": {
      "text": "...",
      "issues_found": 3
    },
    "usage": {
      "tokens": 2840,
      "duration_s": 4.2,
      "cost": "$0.009",
      "tool_calls": 6
    }
  },
  "timing": { "duration_ms": 4200 },
  "messages": [{ "level": "ok", "text": "Actor run completed" }]
}

The global --format option (set via agents --format json actor run ...) stores the format in ctx.obj["format"] per src/cleveragents/cli/main.py which says "Store the selected output format in the Typer context so all subcommands can read it via ctx.obj['format'] without needing their own --format flag."

Actual Behavior

Both src/cleveragents/cli/commands/actor_run.py and the run() function in src/cleveragents/cli/commands/actor.py completely ignore the format context:

  1. Neither command has a --format option of its own
  2. Neither reads ctx.obj["format"]
  3. Output is always emitted as typer.echo(result) — raw text
# In actor_run.py and actor.py run():
if output:
    output.write_text(result)
    typer.echo(f"Output written to {output}")
else:
    typer.echo(result)   # Always raw text, no format handling

Running agents --format json actor run local/reviewer "Hello" emits the raw LLM response text instead of a JSON envelope.

Steps to Reproduce

agents --format json actor run local/reviewer "Hello"
# Expected: JSON envelope with command/status/data/timing/messages fields
# Actual: Raw text response from the actor

Acceptance Criteria

  • agents actor run reads and respects the global --format flag (via ctx.obj["format"])
  • With --format json, output is wrapped in the spec-required JSON envelope (command, status, exit_code, data, timing, messages)
  • The data.actor_run section includes actor, type, temperature, and skill fields
  • The data.response section includes text and optionally usage metadata
  • With --format plain, output is the raw actor response text
  • With --format rich (default), existing rich output behavior is preserved

Subtasks

  • Add ctx: typer.Context parameter to run() in actor_run.py and actor.py
  • Read format from ctx.obj.get("format", "rich")
  • Wrap actor response in spec-compliant envelope when format is json/yaml
  • Add Behave unit test scenarios for --format json output schema
  • Run nox -e coverage_report, verify >=97%
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when agents --format json actor run produces a spec-compliant JSON envelope, and a PR is reviewed and merged.


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

## Background The spec defines structured output for `agents actor run` in JSON and YAML formats. The implementation ignores the global `--format` flag and always outputs raw text. ## What Was Tested Code analysis of `src/cleveragents/cli/commands/actor_run.py` and `src/cleveragents/cli/commands/actor.py` (the `run` command). ## Expected Behavior (from spec) The spec shows that `agents --format json actor run` should produce a structured JSON envelope: ```json { "command": "agents actor run ...", "status": "ok", "exit_code": 0, "data": { "actor_run": { "actor": "local/reviewer", "type": "agent", "temperature": 0.2, "skill": "local/code-analysis" }, "response": { "text": "...", "issues_found": 3 }, "usage": { "tokens": 2840, "duration_s": 4.2, "cost": "$0.009", "tool_calls": 6 } }, "timing": { "duration_ms": 4200 }, "messages": [{ "level": "ok", "text": "Actor run completed" }] } ``` The global `--format` option (set via `agents --format json actor run ...`) stores the format in `ctx.obj["format"]` per `src/cleveragents/cli/main.py` which says "Store the selected output format in the Typer context so all subcommands can read it via `ctx.obj['format']` without needing their own `--format` flag." ## Actual Behavior Both `src/cleveragents/cli/commands/actor_run.py` and the `run()` function in `src/cleveragents/cli/commands/actor.py` completely ignore the format context: 1. Neither command has a `--format` option of its own 2. Neither reads `ctx.obj["format"]` 3. Output is always emitted as `typer.echo(result)` — raw text ```python # In actor_run.py and actor.py run(): if output: output.write_text(result) typer.echo(f"Output written to {output}") else: typer.echo(result) # Always raw text, no format handling ``` Running `agents --format json actor run local/reviewer "Hello"` emits the raw LLM response text instead of a JSON envelope. ## Steps to Reproduce ```bash agents --format json actor run local/reviewer "Hello" # Expected: JSON envelope with command/status/data/timing/messages fields # Actual: Raw text response from the actor ``` ## Acceptance Criteria - [ ] `agents actor run` reads and respects the global `--format` flag (via `ctx.obj["format"]`) - [ ] With `--format json`, output is wrapped in the spec-required JSON envelope (`command`, `status`, `exit_code`, `data`, `timing`, `messages`) - [ ] The `data.actor_run` section includes `actor`, `type`, `temperature`, and `skill` fields - [ ] The `data.response` section includes `text` and optionally usage metadata - [ ] With `--format plain`, output is the raw actor response text - [ ] With `--format rich` (default), existing rich output behavior is preserved ## Subtasks - [ ] Add `ctx: typer.Context` parameter to `run()` in `actor_run.py` and `actor.py` - [ ] Read format from `ctx.obj.get("format", "rich")` - [ ] Wrap actor response in spec-compliant envelope when format is json/yaml - [ ] Add Behave unit test scenarios for `--format json` output schema - [ ] Run `nox -e coverage_report`, verify >=97% - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when `agents --format json actor run` produces a spec-compliant JSON envelope, and a PR is reviewed and merged. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.4.0 milestone 2026-04-10 02:07:38 +00:00
HAL9000 self-assigned this 2026-04-10 06:06:41 +00:00
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#6802
No description provided.