Skip to content

Show the reasoning level of the running turn - #777

Merged
agegr merged 12 commits into
agegr:mainfrom
uvforce:pr/streaming-thinking-level
Sep 18, 2026
Merged

agegr merged 12 commits into
agegr:mainfrom
uvforce:pr/streaming-thinking-level

Conversation

@uvforce

@uvforce uvforce commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

The reasoning level control is hidden while a turn is streaming, because the level cannot be changed mid-turn. That also removes the answer to the question that matters most at exactly that moment: which budget is this turn spending. A long-running turn gives no indication of whether it is on auto, low, or xhigh, and the level is only visible again once the turn is over.

Change

While streaming, the control row shows the active level as a read-only label in the same slot the dropdown normally occupies. Nothing else about the streaming controls changes.

It is deliberately not a button: the level cannot be changed until the turn ends, so a clickable control there would invite clicks that do nothing. The label reuses thinkingDisplayLabel, the existing ThinkingIcon, and the same padding, height, and mobile collapse rule as the editable control, so the row keeps its spacing next to Stop.

Tests

  • components/ChatInput.streaming-thinking.test.mjs — the streaming branch renders the level without any button or click handler, and shares padding, height, and the mobile collapse rule with the dropdown.
  • Full npm test (952), tsc --noEmit, eslint, and next build pass.
  • Verified in a production build with a real browser: during a streaming turn the level appears next to Stop, and the editable dropdown returns unchanged once the turn ends.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T09:15:03.615619Z bf76138 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf76138402

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/ChatInput.tsx Outdated
// would invite clicks that do nothing. It still answers the question
// that matters while a turn runs, which budget is this one spending.
<span
title={t("chat.currentReasoning", { level: thinkingDisplayLabel })}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show the effective reasoning level instead of auto

When an existing session previously used an explicit level and the user selects “Use pi default,” handleThinkingLevelChange sets the client state to auto but returns without updating the runtime, so the agent retains the previous level. On the next prompt this new badge therefore reports auto as the current turn's level even though, for example, high is actually being used. Capture or synchronize the runtime's effective level when the turn starts rather than rendering the selector state directly.

Useful? React with 👍 / 👎.

@uvforce

uvforce commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 37b6553. When a turn starts, the client reads the runtime's thinking level from the agent state and adopts it, so the label reports the level actually in effect even after "Use pi default" left an earlier explicit level in place. The dropdown reflects the same value once the turn ends.

wayne.luo added 2 commits September 12, 2026 21:27
The reasoning control is hidden while a turn streams because the level
cannot be changed mid-turn. That also hides the level itself, exactly when
it decides how long the turn runs and how much budget it spends.

Render the active level as a read-only label in the same slot while
streaming. It is not a button: nothing can change until the turn ends, so
a clickable control would only invite clicks that do nothing. The label
reuses the existing display label, icon, padding, height, and mobile
collapse rule, so the control row keeps its spacing next to Stop.
Choosing "Use pi default" sets the selector to "auto" without touching the
runtime, so the runtime can keep an earlier explicit level. Rendering the
selector state while streaming would then label a turn "auto" that is in
fact running at, say, "high".

When a turn starts, read the runtime's thinking level from the agent state
and adopt it, so the read-only label and the selector both reflect the
level in effect. The lookup is skipped if the turn has already ended.
@uvforce
uvforce force-pushed the pr/streaming-thinking-level branch from 37b6553 to 6898cd6 Compare September 12, 2026 13:29
agegr and others added 9 commits September 13, 2026 23:22
SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works.

Fixes agegr#806
Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in
[email protected]) and pulls sharp 0.35.4 for the libheif advisories via
npm audit fix. next/image is only used for the static logo, so the
/_next/image endpoint is turned off entirely with images.unoptimized.

Co-authored-by: Cursor <[email protected]>
scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush
against the scroll container, where whole-pixel scroll snapping left it a
fraction of a pixel outside the viewport and overflow clipping cut off its
focus ring. Give options a scroll-margin equal to the container padding so
navigation always lands them fully visible; this also unblocks the e2e
"Keyboard selection must scroll into view" assertion.

Co-authored-by: Cursor <[email protected]>
Route handlers have no reliable client address, so a per-IP limiter would
be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access.
Use one shared exponential backoff (1s doubling to 60s) for POST
/api/web-auth instead; a success or five idle minutes resets it. Return
429 with Retry-After while blocked and surface the wait on the login page.

Co-authored-by: Cursor <[email protected]>

@agegr agegr left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small, focused, and answers a real question during a long turn. Approving.

I merged current main into the branch and tightened the turn-start fetch you added in 37b6553: it now captures sid and promptRunIdRef before the request and drops the response if either changed while it was in flight — the same guard reconcileAgentState uses — so a slow reply cannot set the level for a different session or a later run. Test updated to match.

Verified: tsc, eslint, ChatInput* and hooks/* tests pass.

Show the resolved runtime level instead of the auto placeholder, and keep
the same disabled control while a turn runs. Auto stays an uncommitted
default, matching isAutoModelSelection.

Co-authored-by: Cursor <[email protected]>
@agegr
agegr merged commit 3f07a5f into agegr:main Sep 18, 2026
2 checks passed
lclichen pushed a commit to lclichen/pi-web that referenced this pull request Sep 22, 2026
* Show the reasoning level of the running turn

The reasoning control is hidden while a turn streams because the level
cannot be changed mid-turn. That also hides the level itself, exactly when
it decides how long the turn runs and how much budget it spends.

Render the active level as a read-only label in the same slot while
streaming. It is not a button: nothing can change until the turn ends, so
a clickable control would only invite clicks that do nothing. The label
reuses the existing display label, icon, padding, height, and mobile
collapse rule, so the control row keeps its spacing next to Stop.

* Address review: show the level the turn actually runs with

Choosing "Use pi default" sets the selector to "auto" without touching the
runtime, so the runtime can keep an earlier explicit level. Rendering the
selector state while streaming would then label a turn "auto" that is in
fact running at, say, "high".

When a turn starts, read the runtime's thinking level from the agent state
and adopt it, so the read-only label and the selector both reflect the
level in effect. The lookup is skipped if the turn has already ended.

* Align new session branding with chat input

* fix: preserve UNC roots in file API paths

* fix(auth): use SameSite=Lax for pi_web_session cookie (agegr#818)

SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works.

Fixes agegr#806

* fix: preserve newlines in extension dialog titles like pi's TUI

* fix(deps): upgrade Next.js to 16.3.5 and disable image optimizer

Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in
[email protected]) and pulls sharp 0.35.4 for the libheif advisories via
npm audit fix. next/image is only used for the static logo, so the
/_next/image endpoint is turned off entirely with images.unoptimized.

Co-authored-by: Cursor <[email protected]>

* fix: keep focused extension select option clear of the scroller edge

scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush
against the scroll container, where whole-pixel scroll snapping left it a
fraction of a pixel outside the viewport and overflow clipping cut off its
focus ring. Give options a scroll-margin equal to the container padding so
navigation always lands them fully visible; this also unblocks the e2e
"Keyboard selection must scroll into view" assertion.

Co-authored-by: Cursor <[email protected]>

* fix(auth): throttle web password failures with global backoff

Route handlers have no reliable client address, so a per-IP limiter would
be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access.
Use one shared exponential backoff (1s doubling to 60s) for POST
/api/web-auth instead; a success or five idle minutes resets it. Return
429 with Retry-After while blocked and surface the wait on the login page.

Co-authored-by: Cursor <[email protected]>

* Guard the turn-start thinking-level fetch against session/run races

Co-authored-by: Cursor <[email protected]>

* Align thinking-level display with model selection

Show the resolved runtime level instead of the auto placeholder, and keep
the same disabled control while a turn runs. Auto stays an uncommitted
default, matching isAutoModelSelection.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: wayne.luo <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: richardmilles <[email protected]>
Co-authored-by: Cursor <[email protected]>
(cherry picked from commit 3f07a5f)
agegr added a commit that referenced this pull request Sep 30, 2026
)

The reasoning control was disabled for the whole run on the assumption
that the level cannot change mid-turn (#777). pi-agent-core does snapshot
`reasoning` into the loop config when a run starts, but AgentSession's
prepareRequest / prepareNextTurnWithContext hooks re-read
agent.state.thinkingLevel before every model request, and pi's TUI lets
Shift+Tab change it during a run. So set_thinking_level mid-run applies
from the next request; only the response already streaming keeps its
level. The server never refused the command, only the composer did.

Keep the control usable while streaming and stop closing its menu when a
run starts. The tooltip is unchanged.

An integration test drives a real AgentSession with the faux provider
and changes the level while the first request streams: the requests go
out at low, then high. That pins the SDK behavior the control now relies
on across SDK upgrades.

Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
* Show the reasoning level of the running turn

The reasoning control is hidden while a turn streams because the level
cannot be changed mid-turn. That also hides the level itself, exactly when
it decides how long the turn runs and how much budget it spends.

Render the active level as a read-only label in the same slot while
streaming. It is not a button: nothing can change until the turn ends, so
a clickable control would only invite clicks that do nothing. The label
reuses the existing display label, icon, padding, height, and mobile
collapse rule, so the control row keeps its spacing next to Stop.

* Address review: show the level the turn actually runs with

Choosing "Use pi default" sets the selector to "auto" without touching the
runtime, so the runtime can keep an earlier explicit level. Rendering the
selector state while streaming would then label a turn "auto" that is in
fact running at, say, "high".

When a turn starts, read the runtime's thinking level from the agent state
and adopt it, so the read-only label and the selector both reflect the
level in effect. The lookup is skipped if the turn has already ended.

* Align new session branding with chat input

* fix: preserve UNC roots in file API paths

* fix(auth): use SameSite=Lax for pi_web_session cookie (agegr#818)

SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works.

Fixes agegr#806

* fix: preserve newlines in extension dialog titles like pi's TUI

* fix(deps): upgrade Next.js to 16.3.5 and disable image optimizer

Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in
[email protected]) and pulls sharp 0.35.4 for the libheif advisories via
npm audit fix. next/image is only used for the static logo, so the
/_next/image endpoint is turned off entirely with images.unoptimized.

Co-authored-by: Cursor <[email protected]>

* fix: keep focused extension select option clear of the scroller edge

scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush
against the scroll container, where whole-pixel scroll snapping left it a
fraction of a pixel outside the viewport and overflow clipping cut off its
focus ring. Give options a scroll-margin equal to the container padding so
navigation always lands them fully visible; this also unblocks the e2e
"Keyboard selection must scroll into view" assertion.

Co-authored-by: Cursor <[email protected]>

* fix(auth): throttle web password failures with global backoff

Route handlers have no reliable client address, so a per-IP limiter would
be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access.
Use one shared exponential backoff (1s doubling to 60s) for POST
/api/web-auth instead; a success or five idle minutes resets it. Return
429 with Retry-After while blocked and surface the wait on the login page.

Co-authored-by: Cursor <[email protected]>

* Guard the turn-start thinking-level fetch against session/run races

Co-authored-by: Cursor <[email protected]>

* Align thinking-level display with model selection

Show the resolved runtime level instead of the auto placeholder, and keep
the same disabled control while a turn runs. Auto stays an uncommitted
default, matching isAutoModelSelection.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: wayne.luo <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: richardmilles <[email protected]>
Co-authored-by: Cursor <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
agegr#1022)

The reasoning control was disabled for the whole run on the assumption
that the level cannot change mid-turn (agegr#777). pi-agent-core does snapshot
`reasoning` into the loop config when a run starts, but AgentSession's
prepareRequest / prepareNextTurnWithContext hooks re-read
agent.state.thinkingLevel before every model request, and pi's TUI lets
Shift+Tab change it during a run. So set_thinking_level mid-run applies
from the next request; only the response already streaming keeps its
level. The server never refused the command, only the composer did.

Keep the control usable while streaming and stop closing its menu when a
run starts. The tooltip is unchanged.

An integration test drives a real AgentSession with the faux provider
and changes the level while the first request streams: the requests go
out at low, then high. That pins the SDK behavior the control now relies
on across SDK upgrades.

Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
* Show the reasoning level of the running turn

The reasoning control is hidden while a turn streams because the level
cannot be changed mid-turn. That also hides the level itself, exactly when
it decides how long the turn runs and how much budget it spends.

Render the active level as a read-only label in the same slot while
streaming. It is not a button: nothing can change until the turn ends, so
a clickable control would only invite clicks that do nothing. The label
reuses the existing display label, icon, padding, height, and mobile
collapse rule, so the control row keeps its spacing next to Stop.

* Address review: show the level the turn actually runs with

Choosing "Use pi default" sets the selector to "auto" without touching the
runtime, so the runtime can keep an earlier explicit level. Rendering the
selector state while streaming would then label a turn "auto" that is in
fact running at, say, "high".

When a turn starts, read the runtime's thinking level from the agent state
and adopt it, so the read-only label and the selector both reflect the
level in effect. The lookup is skipped if the turn has already ended.

* Align new session branding with chat input

* fix: preserve UNC roots in file API paths

* fix(auth): use SameSite=Lax for pi_web_session cookie (agegr#818)

SameSite=Strict drops the session cookie on external top-level navigations (common on mobile), forcing a re-login while in-page XHR still works.

Fixes agegr#806

* fix: preserve newlines in extension dialog titles like pi's TUI

* fix(deps): upgrade Next.js to 16.3.5 and disable image optimizer

Patches GHSA-2xp9-vwfh-vxw4 / GHSA-p293-qw3h-jr36 (unauthenticated RCE in
[email protected]) and pulls sharp 0.35.4 for the libheif advisories via
npm audit fix. next/image is only used for the static logo, so the
/_next/image endpoint is turned off entirely with images.unoptimized.

Co-authored-by: Cursor <[email protected]>

* fix: keep focused extension select option clear of the scroller edge

scrollIntoView({ block: "nearest" }) parked the keyboard-selected option flush
against the scroll container, where whole-pixel scroll snapping left it a
fraction of a pixel outside the viewport and overflow clipping cut off its
focus ring. Give options a scroll-margin equal to the container padding so
navigation always lands them fully visible; this also unblocks the e2e
"Keyboard selection must scroll into view" assertion.

Co-authored-by: Cursor <[email protected]>

* fix(auth): throttle web password failures with global backoff

Route handlers have no reliable client address, so a per-IP limiter would
be spoofable via x-forwarded-for and empty for direct 127.0.0.1 access.
Use one shared exponential backoff (1s doubling to 60s) for POST
/api/web-auth instead; a success or five idle minutes resets it. Return
429 with Retry-After while blocked and surface the wait on the login page.

Co-authored-by: Cursor <[email protected]>

* Guard the turn-start thinking-level fetch against session/run races

Co-authored-by: Cursor <[email protected]>

* Align thinking-level display with model selection

Show the resolved runtime level instead of the auto placeholder, and keep
the same disabled control while a turn runs. Auto stays an uncommitted
default, matching isAutoModelSelection.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: wayne.luo <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: richardmilles <[email protected]>
Co-authored-by: Cursor <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
agegr#1022)

The reasoning control was disabled for the whole run on the assumption
that the level cannot change mid-turn (agegr#777). pi-agent-core does snapshot
`reasoning` into the loop config when a run starts, but AgentSession's
prepareRequest / prepareNextTurnWithContext hooks re-read
agent.state.thinkingLevel before every model request, and pi's TUI lets
Shift+Tab change it during a run. So set_thinking_level mid-run applies
from the next request; only the response already streaming keeps its
level. The server never refused the command, only the composer did.

Keep the control usable while streaming and stop closing its menu when a
run starts. The tooltip is unchanged.

An integration test drives a real AgentSession with the faux provider
and changes the level while the first request streams: the requests go
out at low, then high. That pins the SDK behavior the control now relies
on across SDK upgrades.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

3 participants