UAT: agents session import missing --format option — no machine-readable output support #6311

Open
opened 2026-04-09 20:09:02 +00:00 by HAL9000 · 0 comments
Owner

Summary

agents session import has no --format option. The command always renders Rich panels regardless of any global or per-command format preference. Machine-readable JSON/YAML output, as required by the spec, is completely absent.

Spec Reference

docs/specification.md §agents session import (around lines 2118–2233) defines the JSON output:

{
  "command": "agents session import --input /tmp/weekly-planning.json",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "session_import": {
      "input": "/tmp/weekly-planning.json",
      "session_id": "01HXM3D3B2W4CQYQ3P4ZB8A5T1",
      "messages": 6,
      "schema": "v3"
    },
    "validation": {
      "checksum": "verified",
      "schema": "compatible",
      "actor_ref": "resolved"
    },
    "merge": {
      "existing": "none",
      "strategy": "create new"
    }
  },
  "timing": { "duration_ms": 210 },
  "messages": [{ "level": "ok", "text": "Import completed" }]
}

Code Location

File: src/cleveragents/cli/commands/session.py
Lines 724–789 — the import_session command function signature:

@app.command("import")
def import_session(
    input_file: Annotated[
        Path,
        typer.Option("--input", "-i", help="Input JSON file path"),
    ],
) -> None:

Gap 1 (lines 724–729): No --format option is declared.

Gap 2 (lines 756–778): The success path unconditionally calls console.print(Panel(...)) for "Session Import", "Validation", and "Merge" panels. There is no branch for fmt not in (rich, color) and no call to format_output.

Steps to Reproduce

# Export a session first
agents session export --output /tmp/session.json <SESSION_ID>

# Try to import with JSON output
agents session import --input /tmp/session.json --format json
# Error: no such option --format

Expected Result

With --format json:

{
  "command": "agents session import --input /tmp/session.json",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "session_import": {
      "input": "/tmp/session.json",
      "session_id": "<NEW_SESSION_ID>",
      "messages": <N>,
      "schema": "1.0"
    },
    "validation": { "checksum": "verified", "schema": "compatible", "actor_ref": "none" },
    "merge": { "existing": "none", "strategy": "create new" }
  },
  "timing": { "duration_ms": ... },
  "messages": [{ "level": "ok", "text": "Import completed" }]
}

Actual Result

Error: No such option: --format

And without --format, always renders Rich panels — no machine-readable path.

Additional Notes

  • All data needed for the structured output is already available after a successful import: session.session_id, session.message_count, schema_version, actor_name — see lines 751–778.
  • The fix follows the same pattern as session show and session list: add fmt: str = "rich" parameter, then branch on fmt not in (OutputFormat.RICH.value, OutputFormat.COLOR.value).
  • The "Validation" panel hardcodes "verified" for checksum (line 769) and "resolved" if actor_name else "none" (line 766). The structured output should mirror these same values.
  • The "Merge" panel currently hardcodes "none" / "create new" (line 775). These are correct defaults for the current implementation.

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

## Summary `agents session import` has no `--format` option. The command always renders Rich panels regardless of any global or per-command format preference. Machine-readable JSON/YAML output, as required by the spec, is completely absent. ## Spec Reference `docs/specification.md` §agents session import (around lines 2118–2233) defines the JSON output: ```json { "command": "agents session import --input /tmp/weekly-planning.json", "status": "ok", "exit_code": 0, "data": { "session_import": { "input": "/tmp/weekly-planning.json", "session_id": "01HXM3D3B2W4CQYQ3P4ZB8A5T1", "messages": 6, "schema": "v3" }, "validation": { "checksum": "verified", "schema": "compatible", "actor_ref": "resolved" }, "merge": { "existing": "none", "strategy": "create new" } }, "timing": { "duration_ms": 210 }, "messages": [{ "level": "ok", "text": "Import completed" }] } ``` ## Code Location **File**: `src/cleveragents/cli/commands/session.py` **Lines 724–789** — the `import_session` command function signature: ```python @app.command("import") def import_session( input_file: Annotated[ Path, typer.Option("--input", "-i", help="Input JSON file path"), ], ) -> None: ``` **Gap 1** (lines 724–729): No `--format` option is declared. **Gap 2** (lines 756–778): The success path unconditionally calls `console.print(Panel(...))` for "Session Import", "Validation", and "Merge" panels. There is no branch for `fmt not in (rich, color)` and no call to `format_output`. ## Steps to Reproduce ```bash # Export a session first agents session export --output /tmp/session.json <SESSION_ID> # Try to import with JSON output agents session import --input /tmp/session.json --format json # Error: no such option --format ``` ## Expected Result With `--format json`: ```json { "command": "agents session import --input /tmp/session.json", "status": "ok", "exit_code": 0, "data": { "session_import": { "input": "/tmp/session.json", "session_id": "<NEW_SESSION_ID>", "messages": <N>, "schema": "1.0" }, "validation": { "checksum": "verified", "schema": "compatible", "actor_ref": "none" }, "merge": { "existing": "none", "strategy": "create new" } }, "timing": { "duration_ms": ... }, "messages": [{ "level": "ok", "text": "Import completed" }] } ``` ## Actual Result ``` Error: No such option: --format ``` And without `--format`, always renders Rich panels — no machine-readable path. ## Additional Notes - All data needed for the structured output is already available after a successful import: `session.session_id`, `session.message_count`, `schema_version`, `actor_name` — see lines 751–778. - The fix follows the same pattern as `session show` and `session list`: add `fmt: str = "rich"` parameter, then branch on `fmt not in (OutputFormat.RICH.value, OutputFormat.COLOR.value)`. - The "Validation" panel hardcodes `"verified"` for checksum (line 769) and `"resolved"` if `actor_name` else `"none"` (line 766). The structured output should mirror these same values. - The "Merge" panel currently hardcodes `"none"` / `"create new"` (line 775). These are correct defaults for the current implementation. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
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#6311
No description provided.