feat(pi): drive the visible pane, read replies from pi's own session log - #283
Open
agnitum2009 wants to merge 1 commit into
Open
feat(pi): drive the visible pane, read replies from pi's own session log#283agnitum2009 wants to merge 1 commit into
agnitum2009 wants to merge 1 commit into
Conversation
pi seats ran headless: every job spawned its own `pi run` subprocess, so the agent pane sat at its startup banner and the seat's work was invisible, unlike claude and kimi seats. Send the prompt to the pane instead, and take the reply from the JSONL session log pi writes under its --session-dir. That log types `thinking` and `text` as separate content blocks, chains messages by parentId, and carries an explicit stopReason, so the reply and the turn boundary are both exact. Scraping the pane was tried first and rejected: pi renders its reasoning into the pane, and pane_quiet_support's parser folded that reasoning into the reply whenever the thinking text did not happen to contain the done marker. - stopReason tool_use keeps the turn open, so tool rounds are not cut short - the parentId walk stops at the next anchored user turn - CCB_PI_EXECUTION_MODE=headless restores the previous adapter - CCB_PI_NATIVE_TURN_TIMEOUT_S overrides the 300s turn budget Co-Authored-By: Claude Opus 5 <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.
What
pi seats run headless: every job spawns its own
pi runsubprocess, so the agent pane sits at its startup banner and the seat's work is invisible — unlike claude and kimi seats, which drive their pane.This sends the prompt to the pane instead, and takes the reply from the JSONL session log pi writes under its
--session-dir.Why read the session log instead of scraping the pane
I tried
pane_quiet_supportfirst. It does not hold up for pi, because pi renders its reasoning into the pane and the parser folds that reasoning into the reply whenever the thinking text does not happen to contain the done marker:Filtering that would mean another prefix blacklist like
_looks_like_kimi_non_answer. pi's own session log makes it unnecessary —thinkingandtextare separately typed content blocks, messages chain byparentId, andstopReasonis explicit:{"type":"message","id":"f0996678","parentId":"40bf081e","message":{ "role":"assistant", "content":[{"type":"thinking","thinking":"..."},{"type":"text","text":"..."}], "stopReason":"stop","model":"k3"}}So the reply and the turn boundary are both exact, with no heuristics. This mirrors what
KimiProviderAdapterdoes withnative_turn_log, where pane text is only rescue evidence.Behaviour
stopReason: tool_usekeeps the turn open, so tool rounds are not cut shortparentIdwalk stops at the next anchored user turnCCB_PI_EXECUTION_MODE=headlessrestores the previous adapterCCB_PI_NATIVE_TURN_TIMEOUT_Soverrides the 300s turn budgetOne semantic change worth calling out for review: pane mode shares a single pi session, so a pi seat now accumulates context across jobs instead of starting fresh per job. That matches claude/kimi seat behaviour, but it is a change for anyone relying on pi jobs being isolated.
Layout
execution.pykeeps the headless adapter and becomes a thin mode selector. The pane path is split so no file exceeds 400 lines:pane_native_log.pypane_execution.pypane_support.pyVerification
Ran against a live CCB project (
coder2:pi, model k3) on this branch's code:reason=pi_pane_turn_end, reply exact, 10.5sread+wc -lrounds, 30s; reply is the final assistant message, not the intermediatetool_useone. ItsLINES=54claim independently confirmed withwc -ltest/test_pi_pane_native_log.pyadds 9 unit tests covering thinking exclusion,tool_usenot completing, the tool-round chain walk, the next-turn boundary, anchor-before-reply, unknown request, sibling session files, partial trailing record, and a missing session dir.Note: the end-to-end runs above were made before the file split; the split is a pure code move verified by import checks and the unit tests, not by a second live round trip.