Skip to content

feat(cli): expose result_id + saved_path in --save --output-format json (sy-659)#480

Open
openclaw-dv wants to merge 1 commit into
mainfrom
polecat/opal-sy-659
Open

feat(cli): expose result_id + saved_path in --save --output-format json (sy-659)#480
openclaw-dv wants to merge 1 commit into
mainfrom
polecat/opal-sy-659

Conversation

@openclaw-dv
Copy link
Copy Markdown
Collaborator

Closes #471

Summary

  • --save --output-format json now emits a stable result_id + saved_path on stdout so agents can drive follow-up commands without scraping stderr.
  • Added a public get_result_path() helper in synth_panel.mcp.data for canonical path derivation.
  • Same behavior in the ensemble (--models a,b) path.
  • Human-oriented Result saved: <id> line on stderr is preserved.

Shape

{
  "message": "Panel complete",
  "rounds": [...],
  "result_id": "result-20260522-211748-a1b2c3",
  "saved_path": "/Users/you/.synthpanel/results/result-20260522-211748-a1b2c3.json"
}

Keys are omitted entirely when --save is not set, so the no-save JSON shape is unchanged.

Why

GH issue #471 (P0, hermes-filed): agents running panels with --save need a stable handle for report / inspect / analyze / MCP calls. Machine-readable output should not require scraping stderr or terminal prose.

Implementation notes

The persistence call moved ahead of emit() in both handle_panel_run() paths (main + ensemble) so the handle lands in extra before serialization. The path is computed via the new get_result_path() helper rather than duplicating _results_dir() / f"{rid}.json" at call sites — keeps the layout authoritative in one place.

Test plan

  • ruff check . clean
  • ruff format --check . clean
  • pytest tests/test_cli.py — 175 passed (8 in TestPanelRunSave, 3 new for sy-659)
  • pytest tests/test_cli.py tests/test_mcp_data.py tests/test_mcp_server.py tests/test_sdk.py — 258 passed, 1 skipped
  • Full suite: 2723 passed, 8 skipped (2 unrelated preexisting failures in tests/test_seed.py require OPENROUTER_API_KEY)
  • python scripts/check_site_cli_sync.py — OK
  • python scripts/render_site_markdown.py produces no diff

New tests:

  • test_save_json_output_includes_result_id_and_saved_path — single-model
  • test_save_json_output_in_ensemble_mode_includes_handle — ensemble
  • test_json_output_without_save_omits_result_id_and_saved_path — negative case

…on (sy-659)

Closes #471

Panel runs with --save and --output-format json now include a stable
machine-readable handle on stdout:

  {
    "result_id": "result-...",
    "saved_path": "/.../.synthpanel/results/result-....json",
    ...
  }

Agents driving follow-up commands (report/inspect/analyze, MCP tools)
can read the handle directly from the JSON payload instead of scraping
the "Result saved: <id>" line from stderr. Human-oriented stderr output
is unchanged.

The persistence call moved ahead of emit() in both the main panel-run
path and the ensemble (--models a,b) path so the handle can land in the
JSON payload before it ships. Added a public get_result_path() helper
in synth_panel.mcp.data so call sites derive the path through the
canonical layout function instead of duplicating it.

Tests: 3 new in TestPanelRunSave covering --save+json (single model and
ensemble) and the no-save baseline. All 175 CLI tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[agent-ready] Include result_id and saved path in machine-readable CLI output

1 participant