feat(cli)!: add agent-first chat / session ask output modes#1741
Open
coconut-yc wants to merge 2 commits into
Open
feat(cli)!: add agent-first chat / session ask output modes#1741coconut-yc wants to merge 2 commits into
chat / session ask output modes#1741coconut-yc wants to merge 2 commits into
Conversation
11 tasks
chat / session ask output modes
57e8e5b to
e40641c
Compare
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.
Description
Implements #1739. This PR gives JSON, text, and NDJSON distinct contracts for
chatandsession ask, with a lean default for AI-agent consumers and anexplicit raw mode for protocol consumers. The behavior comparison below uses
the PR's
mainbase,ae9038732ad2(CLI v0.9.0), not an earlier version of thisfeature branch.
This PR is stacked on #1740, which fixes the prerequisite streaming defects
from #1738. After #1740 merges, this branch should be rebased onto
mainsoonly the feature commit remains.
Behavior change from
mainmain--format json--format ndjson{ok,data:{events}}JSON envelope--format text--format ndjsoninit+ verbatim SDK eventschatreference/verboseinputssession_askreference/verboseinputs1. Bounded JSON default
Default
--format jsonbuffers the run into one success envelope containinganswer events and session/request metadata:
{"ok":true,"data":{"events":[{"response_type":"answer","content":"...","done":false}],"session_id":"..."}}Thinking, reflection, tools, and references are excluded by default instead of
being placed into the agent's context automatically.
2. Independent detail controls
--referenceadds bounded reference events without exposing the executiontrace.
--verboseadds reasoning, tool, metadata, and lifecycle events withoutimplicitly adding references. Combine both flags for both kinds of detail.
MCP
chatandsession_askexpose the same controls throughreference:trueand
verbose:true.Text renders selected events immediately for terminals and pipes. TTY detection
no longer changes which content is emitted.
3. Indexed references
Projected reference payloads contain lookup keys only:
{"kb_id":"...","chunk_id":"...","parent_chunk_id":"..."}The projector does not mutate SDK events. NDJSON therefore retains full
reference content, while JSON/text/MCP consumers fetch passages on demand with
chunk view.session askanswer events also carry inline chunk indexes forfollow-up retrieval.
4. Raw NDJSON remains available
--format ndjsonemits the CLIinitevent and then passes every SDK framethrough verbatim. Presentation flags do not alter it.
5. Shared projection and recovery metadata
JSON, text, and MCP use one projector, preventing their selection policies from
drifting. Buffered CLI JSON errors retain
session_id; chat also retainsassistant_message_idwhen supplied by the stream.Type of Change
Related Issue
Fixes #1739
Testing
Regression coverage verifies:
--referenceincludes indexed references without reasoning/tool events;--verboseincludes reasoning/tool/lifecycle events without references;chat/session_askexpose the same default, reference, and verboseprojections;
init+ verbatim SDK-frame contract;--jqcan extract or join answer fragments;Validated locally:
Checklist
git diff --checkpassescli/CHANGELOG.md,cli/README.md,cli/AGENTS.md, and bundled skillschat/session ask --format jsonnow emits one envelope withdata.eventsrather than raw JSON lines.chat/session_asknow returneventsrather than categorizedanswer/thinking/tool/reference fields.
--referencefor indexed references and--verbosefor execution detail(or the corresponding MCP booleans).
SearchResultobjects. NDJSON SDK frames remain lossless.
tool/reference events are no longer deferred to trailing summary sections.
Migration examples:
Screenshots / Recordings
N/A — CLI / MCP output only.