UAT: JSON/YAML envelope messages[].text always "ok" instead of spec-required human-readable text (e.g. "Session created", "2 sessions listed") #6457

Open
opened 2026-04-09 21:05:10 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Summary

All agents session commands that use --format json or --format yaml produce messages: [{"level": "ok", "text": "ok"}] in the output envelope. The spec requires human-readable text in the messages[].text field, such as "Session created", "2 sessions listed", "Session deleted", etc.

Spec Reference

Multiple spec sections define the expected messages text:

  • docs/specification.md line 1561: "messages": [{ "level": "ok", "text": "Session created" }]
  • docs/specification.md line 1685: "messages": [{ "level": "ok", "text": "2 sessions listed" }]
  • docs/specification.md line 1834: "messages": [{ "level": "ok", "text": "Session details loaded" }]
  • docs/specification.md line 1959: "messages": [{ "level": "ok", "text": "Session deleted" }]
  • docs/specification.md line 2085: "messages": [{ "level": "ok", "text": "Export completed" }]
  • docs/specification.md line 2205: "messages": [{ "level": "ok", "text": "Import completed" }]

Actual Behavior

All commands produce:

"messages": [{ "level": "ok", "text": "ok" }]

Root Cause

src/cleveragents/cli/formatting.py lines 222–226 (_build_envelope): When messages is None, the default message is generated as:

messages = [{"level": status, "text": f"{command} completed" if command else "ok"}]

Since command is always passed as "" (empty string) from all session commands, the fallback "ok" text is always used.

The session commands call format_output(dict(data), fmt) without passing a messages parameter (see src/cleveragents/cli/commands/session.py lines 210, 304, 370, etc.).

Fix

Session commands should pass the messages parameter to format_output() with the appropriate human-readable text. For example:

# session create
format_output(data, fmt, messages=[{"level": "ok", "text": "Session created"}])

# session list
format_output(data, fmt, messages=[{"level": "ok", "text": f"{len(sessions)} sessions listed"}])

# session show
format_output(data, fmt, messages=[{"level": "ok", "text": "Session details loaded"}])

Steps to Reproduce

agents session create --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['messages'])"
# Output: [{'level': 'ok', 'text': 'ok'}]
# Expected: [{'level': 'ok', 'text': 'Session created'}]

Code Location

  • src/cleveragents/cli/commands/session.py — all format_output() calls (lines 210, 304, 370)
  • src/cleveragents/cli/formatting.py lines 222–226 (default message generation)

Severity

Medium (Backlog) — The envelope is structurally valid but the messages[].text field is not human-readable as the spec requires. Consumers relying on this field for status messages will receive generic "ok" text.


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

## Bug Report ### Summary All `agents session` commands that use `--format json` or `--format yaml` produce `messages: [{"level": "ok", "text": "ok"}]` in the output envelope. The spec requires human-readable text in the `messages[].text` field, such as `"Session created"`, `"2 sessions listed"`, `"Session deleted"`, etc. ### Spec Reference Multiple spec sections define the expected `messages` text: - `docs/specification.md` line 1561: `"messages": [{ "level": "ok", "text": "Session created" }]` - `docs/specification.md` line 1685: `"messages": [{ "level": "ok", "text": "2 sessions listed" }]` - `docs/specification.md` line 1834: `"messages": [{ "level": "ok", "text": "Session details loaded" }]` - `docs/specification.md` line 1959: `"messages": [{ "level": "ok", "text": "Session deleted" }]` - `docs/specification.md` line 2085: `"messages": [{ "level": "ok", "text": "Export completed" }]` - `docs/specification.md` line 2205: `"messages": [{ "level": "ok", "text": "Import completed" }]` ### Actual Behavior All commands produce: ```json "messages": [{ "level": "ok", "text": "ok" }] ``` ### Root Cause `src/cleveragents/cli/formatting.py` lines 222–226 (`_build_envelope`): When `messages` is `None`, the default message is generated as: ```python messages = [{"level": status, "text": f"{command} completed" if command else "ok"}] ``` Since `command` is always passed as `""` (empty string) from all session commands, the fallback `"ok"` text is always used. The session commands call `format_output(dict(data), fmt)` without passing a `messages` parameter (see `src/cleveragents/cli/commands/session.py` lines 210, 304, 370, etc.). ### Fix Session commands should pass the `messages` parameter to `format_output()` with the appropriate human-readable text. For example: ```python # session create format_output(data, fmt, messages=[{"level": "ok", "text": "Session created"}]) # session list format_output(data, fmt, messages=[{"level": "ok", "text": f"{len(sessions)} sessions listed"}]) # session show format_output(data, fmt, messages=[{"level": "ok", "text": "Session details loaded"}]) ``` ### Steps to Reproduce ```bash agents session create --format json | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['messages'])" # Output: [{'level': 'ok', 'text': 'ok'}] # Expected: [{'level': 'ok', 'text': 'Session created'}] ``` ### Code Location - `src/cleveragents/cli/commands/session.py` — all `format_output()` calls (lines 210, 304, 370) - `src/cleveragents/cli/formatting.py` lines 222–226 (default message generation) ### Severity **Medium (Backlog)** — The envelope is structurally valid but the `messages[].text` field is not human-readable as the spec requires. Consumers relying on this field for status messages will receive generic "ok" text. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 23:20:25 +00:00
Author
Owner

Implemented spec-compliant envelope messages for the session CLI machine formats and added Behave coverage to lock the expected text for create/list/show (including the empty list case). PR #6739 is open on branch fix/issue-6457-json-envelope-messages-text; I’ll monitor CI and review feedback until merge.

Tests: nox -s unit_tests-3.13 -- features/session_cli.feature


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker

Implemented spec-compliant envelope messages for the session CLI machine formats and added Behave coverage to lock the expected text for create/list/show (including the empty list case). PR #6739 is open on branch fix/issue-6457-json-envelope-messages-text; I’ll monitor CI and review feedback until merge. Tests: nox -s unit_tests-3.13 -- features/session_cli.feature --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: implementation-worker
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#6457
No description provided.