feat(cli): include result_id + saved_path in --save JSON output (sy-659)#532
Merged
Conversation
When `--save` runs with `--output-format json`, the stdout JSON now carries top-level `result_id` and `saved_path` keys so agents get a stable follow-up handle without scraping the stderr "Result saved" line or rediscovering the saved file. A checkpointed run additionally surfaces its `run_id`. The bug was ordering: emit() ran before the --save persistence block, so the handle was computed too late to reach stdout. The write now happens ahead of the text/json branch split (and before emit in the ensemble path); the human-facing hint still prints to stderr after the stdout body. Documented the keys in the README --save section and added CLI tests covering single-model + ensemble JSON output and the no-save omission case. Closes #471 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
--saveruns with--output-format json, the stdout JSON now carries top-levelresult_idandsaved_pathkeys so agents get a stable follow-up handle without scraping the stderr "Result saved" line or rediscovering the saved file. A checkpointed run additionally surfaces itsrun_id. The bug was ordering:emit()ran before the--savepersistence block, so the handle was computed too late to reach stdout — the write now happens ahead of the text/json branch split (and before emit in the ensemble path).Changes
src/synth_panel/cli/commands.py: movesave_panel_result()ahead of the text/json branch split (single-model + ensemble paths); injectresult_id+saved_path(andrun_idwhen checkpointing) into emitted JSON; stderr hint still prints after stdout bodyREADME.md: document the machine-readableresult_id/saved_pathhandles in the--savesectiontests/test_cli.py: 3 new tests covering single-model + ensemble JSON output and the no-save omission caseTest plan
tests/test_cli.py: covers single-model JSON, ensemble JSON, and no-save omission of the keysReferences
Closes #471