UAT: OutputSession JSON/YAML envelope timing field uses duration (seconds) instead of spec-required duration_ms (milliseconds) #4498

Open
opened 2026-04-08 13:52:16 +00:00 by HAL9000 · 0 comments
Owner

Bug Report

Feature Area: Output Rendering Framework — JSON/YAML Envelope Format
Severity: Medium
Discovered by: UAT tester (uat-worker-output-rendering-001)


Summary

The timing field in the JSON/YAML envelope produced by OutputSession uses duration (in seconds, as a float) instead of the spec-required duration_ms (in milliseconds, as an integer). Additionally, the timing object includes extra fields (start_time, end_time) not defined in the spec.

Expected Behavior (per spec)

The spec defines the timing field as:

{
  "timing": { "duration_ms": 42 }
}

A single field duration_ms with the elapsed time in milliseconds as an integer.

Actual Behavior

from cleveragents.cli.output import OutputSession, JsonMaterializer
import json

strategy = JsonMaterializer()
with OutputSession(format='json', command='test', strategy=strategy) as session:
    panel = session.panel('Test')
    panel.set_entry('Key', 'Value')

output = json.loads(strategy.get_output())
print(output['timing'])
# Output: {'start_time': 1775655916.25, 'end_time': 1775655916.25, 'duration': 4.67e-05}

The timing object has:

  • start_time — epoch timestamp (not in spec)
  • end_time — epoch timestamp (not in spec)
  • duration — elapsed time in seconds (float), not milliseconds

Root Cause

In src/cleveragents/cli/output/session.py, the close() method sets timing as:

self._timing = {
    "start_time": self.created_at,
    "end_time": now,
    "duration": now - self.created_at,  # ← seconds, not milliseconds
}

The spec requires {"duration_ms": <int>}.

Note: The format_output() function in formatting.py correctly uses duration_ms:

envelope = _build_envelope(
    safe_data, command, status, exit_code, duration_ms, messages
)
# timing: {"duration_ms": duration_ms}

Inconsistency

Path timing format Correct?
format_output(data, 'json') {"duration_ms": 42} ✓ Yes
OutputSession + JsonMaterializer {"start_time": ..., "end_time": ..., "duration": 0.000047} ✗ No

Fix Required

In src/cleveragents/cli/output/session.py, change the timing calculation:

# Before
self._timing = {
    "start_time": self.created_at,
    "end_time": now,
    "duration": now - self.created_at,
}

# After (spec-compliant)
self._timing = {
    "duration_ms": int((now - self.created_at) * 1000),
}

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

## Bug Report **Feature Area:** Output Rendering Framework — JSON/YAML Envelope Format **Severity:** Medium **Discovered by:** UAT tester (uat-worker-output-rendering-001) --- ## Summary The `timing` field in the JSON/YAML envelope produced by `OutputSession` uses `duration` (in seconds, as a float) instead of the spec-required `duration_ms` (in milliseconds, as an integer). Additionally, the timing object includes extra fields (`start_time`, `end_time`) not defined in the spec. ## Expected Behavior (per spec) The spec defines the timing field as: ```json { "timing": { "duration_ms": 42 } } ``` A single field `duration_ms` with the elapsed time in **milliseconds** as an integer. ## Actual Behavior ```python from cleveragents.cli.output import OutputSession, JsonMaterializer import json strategy = JsonMaterializer() with OutputSession(format='json', command='test', strategy=strategy) as session: panel = session.panel('Test') panel.set_entry('Key', 'Value') output = json.loads(strategy.get_output()) print(output['timing']) # Output: {'start_time': 1775655916.25, 'end_time': 1775655916.25, 'duration': 4.67e-05} ``` The `timing` object has: - `start_time` — epoch timestamp (not in spec) - `end_time` — epoch timestamp (not in spec) - `duration` — elapsed time in **seconds** (float), not milliseconds ## Root Cause In `src/cleveragents/cli/output/session.py`, the `close()` method sets timing as: ```python self._timing = { "start_time": self.created_at, "end_time": now, "duration": now - self.created_at, # ← seconds, not milliseconds } ``` The spec requires `{"duration_ms": <int>}`. Note: The `format_output()` function in `formatting.py` correctly uses `duration_ms`: ```python envelope = _build_envelope( safe_data, command, status, exit_code, duration_ms, messages ) # timing: {"duration_ms": duration_ms} ``` ## Inconsistency | Path | `timing` format | Correct? | |------|----------------|---------| | `format_output(data, 'json')` | `{"duration_ms": 42}` | ✓ Yes | | `OutputSession` + `JsonMaterializer` | `{"start_time": ..., "end_time": ..., "duration": 0.000047}` | ✗ No | ## Fix Required In `src/cleveragents/cli/output/session.py`, change the timing calculation: ```python # Before self._timing = { "start_time": self.created_at, "end_time": now, "duration": now - self.created_at, } # After (spec-compliant) self._timing = { "duration_ms": int((now - self.created_at) * 1000), } ``` --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-08 17:42:07 +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#4498
No description provided.