Skip to content

fix(native-chat): a remembered effort a saved Pi listing lacks no longer refuses new chats (carries #31576) - #33637

Merged
nwparker merged 2 commits into
mainfrom
nwparker/agint-pi-create-seed-option-rejected
Oct 25, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/agint-pi-create-seed-option-rejected

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​89
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41

ELI5

When you pick an effort for a Pi chat (say XHigh), Orca remembers it for the next chat. Pi's live chat offers XHigh, but the shorter model list Orca saves from pi --list-models stops at High. When you start the next chat, Orca checks the remembered effort against that saved list, sees it's missing, and refuses to create the chat. You then get "Chat connection could not be confirmed." on every new Pi chat, while Pi in a terminal still works.

Now a remembered effort that the saved list doesn't have moves to the nearest level it does have (XHigh → High), the same rule the Claude seed remap already uses. If no nearby level exists (e.g. the model lists no efforts), the effort is dropped. Values you pass for this one launch (--model / --effort) are still checked strictly.

Root cause

  • New chats seed the remembered selection (nativeChatSessionOptions.<agent>.valuesByModel) into the create, and assertAgentSessionOptionsAdmitted (via validateAgentSessionReservationInput) checks it against the saved catalog row before anything runs. The refusal (agent_session_operation_invalid / optionRejected) is not classified as failed-without-effects, so the launch reports agent_session_operation_unknown, and the Chat UI times out with "Chat connection could not be confirmed." The trace shows agentSession.create ending after reserve_owner with no acquire_owner.
  • For Pi, the saved row comes from pi --list-models, which prints only a thinking yes/no column (pi-mono packages/coding-agent/src/cli/list-models.ts:69). So piModelCatalogFromListing can only offer off..high (src/main/pi/rpc-model-catalog-probe.ts). The live RPC get_available_models reports thinkingLevelMap, so the live picker also offers xhigh/max when the model maps them (src/main/pi/rpc-options.ts). Live picks skip admission for Pi on purpose (pickAgentSessionOption: "Pi's probe stops at high"). The create path had no matching tolerance.
  • The catalog merge takes the newer listing's menu (mergedModels). After a restart the probe listing is newer than the live one, which is why it works until Orca restarts or updates and then fails on every new chat.
  • Pi itself clamps unsupported levels (pi-mono packages/coding-agent/src/core/agent-session.ts:2676 setThinkingLevel), so the refusal protected nothing.

What changed

  • seedOptionsAdmittedOnSavedListing (from fix(native-chat): drop a remembered model option a saved listing no longer admits #31576): fits only the remembered seed to the saved row. An effort the row lacks moves to nearestAgentEffort (reused from structured-launch-seed-listing.ts); other unlisted values drop. It runs only when the caller didn't name a model, and keys the caller named keep strict admission. Unlisted models or no saved rows admit everything, as before.
  • One prepare-level regression test file that exercises prepareStructuredAgentSessionCreateForWorktree. Two of its cases fail on origin/main.
  • The remembered setting itself is not rewritten. If the saved row later lists XHigh again, new chats use XHigh again.

How verified

Real Orca dev build + real @earendil-works/pi-coding-agent@1.3.0 (the issue's version), isolated HOME/Pi agent dir/ORCA_DEV_USER_DATA_PATH, scrubbed env, and a local fake OpenAI-compatible model server. The model was reasoning: true, thinkingLevelMap: { xhigh: "high" }.

  1. main, before: a fresh Pi chat works. In the live chat I picked model Fake One and effort XHigh (the live menu offers it) and confirmed nativeChatSessionOptions.pi = {model: fake/fake-1, valuesByModel: {fake/fake-1: {effort: xhigh}}}. After restarting Orca, the saved row was the probe's off..high. New tab → "Start a chat with Pi" showed "Chat connection could not be confirmed." with the picker on XHigh. orca agent launch --agent pi --surface chat returned agent_session_operation_unknown. The trace's agentSession.create had reserve_owner and no acquire_owner, the same signature as in the issue.
  2. this branch, after: same profile and same restart. The new Pi chat tab opened with no banner and the picker on High. Sending a message got pong from fake back from the fake server. orca agent launch --agent pi --surface chat → ok: true, "Started a structured chat session". The remembered xhigh setting is unchanged.
  3. pnpm tc:node, targeted pnpm test (new file + src/main/runtime/session-tabs), pnpm run check:code-quality:changed: all pass.

Platforms: the report is from Windows, but the cause is platform-independent. It reproduced on macOS and touches no platform-specific code. Remote: the fix runs on whichever host creates the chat, with no wire change. Mobile-created chats go through the same host create path.

Risk

Low. The change only affects create-time seeding of remembered values the saved row would otherwise refuse. Those launches always failed before. Explicit --model/--effort admission is unchanged.

Trade-off: a Pi user who remembered xhigh/max now starts new chats at high until a newer live listing offers more. Before this they got no chat at all. We could instead skip effort admission for Pi creates, since Pi clamps itself, but that would let real typos through for every provider path that shares this check.

A follow-up worth considering: classify AgentLaunchStructuredSessionRefusedError as failed-without-effects, so any remaining admission refusal shows its typed reason instead of agent_session_operation_unknown.

Credit: carries @hualong1009's #31576 (their commit is kept as-is; the follow-up commit is co-authored).

Fixes #31493

hualong1009 and others added 2 commits October 25, 2026 14:07
…onger admits

A new chat seeds the remembered model selection into its create and admits
the seed against the saved catalog rows. A remembered value its model's row
no longer admits refused the create with agent_session_operation_invalid
(optionRejected) before any effect, which the launch wraps as
agent_session_operation_unknown: every new chat for that agent then fails
after the confirmation budget, shown as a chat that could not connect.

A remembered value is now dropped instead — a launch is refused only on
options its caller named for it. Values this launch named itself keep their
refusal, and the seed's model always stays, since a listed row admits its
own id.
… level

Pi's live menu offers xhigh where its --list-models probe stops at high, so
dropping the remembered effort lost the user's intent; reuse the Claude seed
remap's nearest-effort rule instead. Keep one prepare-level regression file.

Co-authored-by: 王浩生 <22971846+hualong1009@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 18f005d4-75ad-40b6-b201-f0b42c34256c
Commits

Reviewing files that changed from the base of the PR and between e26e418 and feea31f.

Files selected for processing: 3
  • src/main/runtime/agent-session-record-options.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create-seed-admission.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-create.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

Worktree session preparation now filters remembered options against the saved model listing when catalog models exist and no model was explicitly selected. Explicitly supplied option keys remain unchanged. Unsupported effort values are replaced with the nearest listed effort when available; other unsupported values are omitted. Tests cover remembered and launch-supplied effort options across model-catalog cases.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to feea3

No actionable merge-blocking issue is established; the change is ready for normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the Pi remembered-effort admission fix and its effect on new chats. It is somewhat long, but it accurately summarizes the main change.
Description check Passed The description provides a detailed user-facing explanation, root cause, implementation details, linked issue, testing results, platform coverage, risks, and trade-offs. It omits several template head…
Linked Issues check Passed The PR addresses the coding requirement in #31493. In prepareStructuredAgentSessionCreateForWorktree, remembered options are checked against the saved catalog before create. An unlisted remembered `…
Out of Scope Changes check Passed The production changes are limited to remembered-option admission in agent-session-record-options.ts and its use during structured session preparation in structured-agent-session-create.ts. The te…
Full details: Description check

Explanation

The description provides a detailed user-facing explanation, root cause, implementation details, linked issue, testing results, platform coverage, risks, and trade-offs. It omits several template headings, including Visual Proof, Review, and Checklist, but the required information is mostly covered and the description is relevant and complete enough.

Full details: Linked Issues check

Explanation

The PR addresses the coding requirement in #31493. In prepareStructuredAgentSessionCreateForWorktree, remembered options are checked against the saved catalog before create. An unlisted remembered effort is remapped with nearestAgentEffort. Other unlisted remembered values are dropped. Explicit caller options remain protected. The added regression tests cover nearest-effort remapping, dropping an unavailable effort, preserving an explicit effort, and retaining options for an unlisted model. The PR verification also reports that a Pi Chat UI create succeeds and accepts a message with @earendil-works/pi-coding-agent@1.3.0.

Full details: Out of Scope Changes check

Explanation

The production changes are limited to remembered-option admission in agent-session-record-options.ts and its use during structured session preparation in structured-agent-session-create.ts. The test file directly verifies this behavior. These changes support #31493. No unrelated product behavior or administrative work is included.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Bug]: Pi Agent Chat UI fails with "Chat connection could not be confirmed" on Windows

2 participants