UAT: CLEVERAGENTS_FORMAT environment variable is not checked by CLI commands — format resolution chain is incomplete #2100

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

Metadata

  • Branch: fix/cleveragents-format-env-var-not-checked
  • Commit Message: fix(cli): check CLEVERAGENTS_FORMAT env var in format resolution chain for all commands
  • Milestone: v3.7.0
  • Parent Epic: #936

Subtasks

  • Implement format resolution helper that checks CLEVERAGENTS_FORMAT env var (via ConfigService.resolve('core.format'))
  • Apply the resolution helper as the default value for all per-command --format options
  • Ensure the precedence chain is: CLI flag > CLEVERAGENTS_FORMAT env var > core.format config > rich default
  • Add unit tests (Behave) for CLEVERAGENTS_FORMAT env var resolution
  • Add integration tests (Robot Framework) for env var format override

Definition of Done

  • Setting CLEVERAGENTS_FORMAT=json causes all commands to output JSON by default
  • Setting CLEVERAGENTS_FORMAT=table causes all commands to output table format by default
  • A per-command --format flag overrides CLEVERAGENTS_FORMAT
  • Tests pass at ≥97% coverage

Bug Report

What Was Tested

The spec (§Output Rendering Framework, §Format Resolution, line 26693-26695) defines a three-level format resolution chain:

1. CLI flag: --format <value> on the command line (highest priority).
2. Environment variable: CLEVERAGENTS_FORMAT=<value>.
3. Config file: The core.format key in the global config.

The ConfigService correctly registers CLEVERAGENTS_FORMAT as the env var for core.format (confirmed in src/cleveragents/application/services/config_service.py, line 154).

Expected Behavior (from spec)

When CLEVERAGENTS_FORMAT=json is set, running agents version (without --format) should output JSON format.

Actual Behavior

Setting CLEVERAGENTS_FORMAT=json has no effect on CLI command output. Commands always use their hardcoded default (rich) regardless of the environment variable.

Test verification:

import os
os.environ['CLEVERAGENTS_FORMAT'] = 'json'
from cleveragents.cli.main import main
# Run version without --format flag
main(['version'])
# Output: Rich terminal panels (not JSON)
# Expected: JSON output

Root Cause

All per-command --format options use a hardcoded default of "rich":

# In session.py, plan.py, etc.:
fmt: str = typer.Option("rich", "--format", "-f", help=_FORMAT_HELP)

None of these commands call ConfigService.resolve('core.format') to check the env var or config file. The CLEVERAGENTS_FORMAT env var is registered in the config catalog but never consulted during command execution.

Code Location

  • src/cleveragents/cli/commands/session.py — all --format options
  • src/cleveragents/cli/commands/plan.py — all --format options
  • src/cleveragents/cli/commands/action.py — all --format options
  • src/cleveragents/cli/main.pyversion, info, diagnostics commands
  • All other command files with --format options

Note

This is related to but distinct from issue #2075 (core.format config key not applied). Both issues stem from the same root cause — the format resolution chain is not implemented — but this issue specifically covers the CLEVERAGENTS_FORMAT environment variable tier (level 2 in the spec's priority chain).

Severity

High — The spec explicitly defines CLEVERAGENTS_FORMAT as the second-highest priority in the format resolution chain. This is essential for CI/CD pipelines and scripting use cases where users set the env var to get machine-readable output without modifying every command invocation.


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

## Metadata - **Branch**: `fix/cleveragents-format-env-var-not-checked` - **Commit Message**: `fix(cli): check CLEVERAGENTS_FORMAT env var in format resolution chain for all commands` - **Milestone**: v3.7.0 - **Parent Epic**: #936 ## Subtasks - [ ] Implement format resolution helper that checks `CLEVERAGENTS_FORMAT` env var (via `ConfigService.resolve('core.format')`) - [ ] Apply the resolution helper as the default value for all per-command `--format` options - [ ] Ensure the precedence chain is: CLI flag > `CLEVERAGENTS_FORMAT` env var > `core.format` config > `rich` default - [ ] Add unit tests (Behave) for `CLEVERAGENTS_FORMAT` env var resolution - [ ] Add integration tests (Robot Framework) for env var format override ## Definition of Done - Setting `CLEVERAGENTS_FORMAT=json` causes all commands to output JSON by default - Setting `CLEVERAGENTS_FORMAT=table` causes all commands to output table format by default - A per-command `--format` flag overrides `CLEVERAGENTS_FORMAT` - Tests pass at ≥97% coverage ## Bug Report ### What Was Tested The spec (§Output Rendering Framework, §Format Resolution, line 26693-26695) defines a three-level format resolution chain: ``` 1. CLI flag: --format <value> on the command line (highest priority). 2. Environment variable: CLEVERAGENTS_FORMAT=<value>. 3. Config file: The core.format key in the global config. ``` The `ConfigService` correctly registers `CLEVERAGENTS_FORMAT` as the env var for `core.format` (confirmed in `src/cleveragents/application/services/config_service.py`, line 154). ### Expected Behavior (from spec) When `CLEVERAGENTS_FORMAT=json` is set, running `agents version` (without `--format`) should output JSON format. ### Actual Behavior Setting `CLEVERAGENTS_FORMAT=json` has no effect on CLI command output. Commands always use their hardcoded default (`rich`) regardless of the environment variable. **Test verification:** ```python import os os.environ['CLEVERAGENTS_FORMAT'] = 'json' from cleveragents.cli.main import main # Run version without --format flag main(['version']) # Output: Rich terminal panels (not JSON) # Expected: JSON output ``` ### Root Cause All per-command `--format` options use a hardcoded default of `"rich"`: ```python # In session.py, plan.py, etc.: fmt: str = typer.Option("rich", "--format", "-f", help=_FORMAT_HELP) ``` None of these commands call `ConfigService.resolve('core.format')` to check the env var or config file. The `CLEVERAGENTS_FORMAT` env var is registered in the config catalog but never consulted during command execution. ### Code Location - `src/cleveragents/cli/commands/session.py` — all `--format` options - `src/cleveragents/cli/commands/plan.py` — all `--format` options - `src/cleveragents/cli/commands/action.py` — all `--format` options - `src/cleveragents/cli/main.py` — `version`, `info`, `diagnostics` commands - All other command files with `--format` options ### Note This is related to but distinct from issue #2075 (`core.format` config key not applied). Both issues stem from the same root cause — the format resolution chain is not implemented — but this issue specifically covers the `CLEVERAGENTS_FORMAT` environment variable tier (level 2 in the spec's priority chain). ### Severity **High** — The spec explicitly defines `CLEVERAGENTS_FORMAT` as the second-highest priority in the format resolution chain. This is essential for CI/CD pipelines and scripting use cases where users set the env var to get machine-readable output without modifying every command invocation. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Duplicate of #1982.

This issue describes the same problem as #1982 ("UAT: CLEVERAGENTS_FORMAT environment variable not supported — spec requires it as second-highest priority in format resolution chain"). Both issues report that the CLEVERAGENTS_FORMAT env var is not checked by CLI commands, and both reference the same spec section (§Format Resolution).

#1982 was triaged and verified in cycle 1 with MoSCoW: Should Have, milestone v3.5.0. Closing this as a duplicate.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

**Duplicate of #1982.** This issue describes the same problem as #1982 ("UAT: `CLEVERAGENTS_FORMAT` environment variable not supported — spec requires it as second-highest priority in format resolution chain"). Both issues report that the `CLEVERAGENTS_FORMAT` env var is not checked by CLI commands, and both reference the same spec section (§Format Resolution). #1982 was triaged and verified in cycle 1 with MoSCoW: Should Have, milestone v3.5.0. Closing this as a duplicate. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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#2100
No description provided.