Repository navigation
Conversation
With verbose on, `claude -p --output-format json` prints a list of the session's events (system/init, assistant, rate_limit_event, result) rather than the result object alone. The default command loads user settings, so `"verbose": true` there is enough. envelope() discarded the list, so every default-command call raised InferenceError and assess.py and distill.py failed. It now takes the last "result" event from a list, and still reads the object form. The envelope tests run against both shapes. Checked live on 2.1.310 with and without --verbose: main fails on the verbose output, this reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fwereade
force-pushed
the
fwereade/fix/claude-output-shape
branch
from
November 4, 2026 17:18
8aa3f4d to
30fe9c0
Compare
ajkerrigan
approved these changes
Nov 4, 2026
ajkerrigan
left a comment
There was a problem hiding this comment.
Thanks for the better explanation and fix 🍻
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.
what
_inference.envelope()now accepts both shapes ofclaude -p --output-format json: the resultobject alone, or a list of the session's events, from which it takes the last
type: "result"event. A list with no result event (or any other non-object JSON) is still "no result envelope".
why
ENG-9655: with verbose on,
claude -p --output-format jsonprints a JSON array of events (system/init,assistant,rate_limit_event,result) instead of the bare result object. The ticket blamed Claude Code2.1.318, but the cause is verbose: the default command loads user settings (
--setting-sources user), so"verbose": truethere is enough.envelope()discarded the list, so everydefault-command model call raised
InferenceError, breakingassess.py ... showanddistill.py ... show. The only workaround was acustom
STACKLET_GUARDRAILS_INFERENCE_CMDwith text output, which marks the output as made by acustom command and loses token and cost stats.
testing
tests/test_inference.py: the envelope tests (answer/tokens/cost, and the error reported onstdout with a non-zero exit) now run against both the object and event-list shapes. The
no-envelope test also covers plain text,
[], an event list with no result, and a bare JSONstring.
just test(963 passed) andjust lintpass.and
_inference.runreturns the answer with tokens and cost.--verbose(and with--settings '{"verbose":true}'): the output is theevent list. On
main,run()raises "wrote no result envelope", as in the ticket. On thisbranch it returns
OKwith tokens and cost.docs
None needed: no docs describe the envelope's shape. The new code comment says why it can be a list.