Skip to content

[BUG] [v0.0.7] cortex exec JSON result uses inconsistent field naming between --output-format json (snake_case) and --output-format stream-json #48514

@vasylchow

Description

@vasylchow

Project

cortex

Description

cortex exec emits JSON output with inconsistent field naming conventions depending on the --output-format value. The json format uses snake_case keys (duration_ms, num_turns, result) while the stream-json format uses camelCase keys (durationMs, numTurns, finalText) for the same semantic data. This breaks automation scripts that switch between output formats or parse both.

Error Message

Debug Logs

System Information

Ubuntu 24.04

Screenshots

Image Image

Steps to Reproduce

  1. Run cortex exec --output-format json "hello" — observe duration_ms, num_turns in JSON output
  2. Run cortex exec --output-format stream-json "hello" — observe durationMs, numTurns in JSON output
  3. Compare the field naming conventions between the two outputs

Expected Behavior

Both output formats from the same command should use a consistent field naming convention (either snake_case or camelCase) for the same semantic fields.

Actual Behavior

--output-format json uses snake_case (duration_ms, num_turns, result, is_error) while --output-format stream-json uses camelCase (durationMs, numTurns, finalText, toolCalls). Scripts that parse exec JSON output will break when switching between formats because the field names differ.

Additional Context

At src/cortex-cli/src/exec_cmd/runner.rs lines 528–548, the Json format emits:
{
"type": "result",
"subtype": "success",
"is_error": false,
"result": "...",
"duration_ms": 1234,
"num_turns": 1,
"session_id": "..."
}
At lines 552–562, the StreamJson format emits:
{
"type": "completion",
"finalText": "...",
"numTurns": 1,
"durationMs": 1234,
"session_id": "...",
"timestamp": 1712345678000,
"toolCalls": 0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEvalidValid issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions