Skip to content

fix(chat): show inherited reasoning in transcripts - #128249

Closed
gaoanze888 wants to merge 28 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/reasoning-inherited-visibility
Closed

gaoanze888 wants to merge 28 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/reasoning-inherited-visibility

Conversation

@gaoanze888

@gaoanze888 gaoanze888 commented Aug 23, 2026 •

Copy link
Copy Markdown

Closes #79469

What Problem This Solves

Fixes an issue where completed assistant reasoning could stay hidden in Control UI when reasoning was enabled through an inherited agent/global default or through the selected model's reasoning capability instead of a session-specific reasoningLevel override.

Why This Change Was Made

Gateway session rows now project the effective reasoning level separately from the stored override, session-change events carry that value, and the chat transcript renderer uses it when deciding whether saved thinking blocks may be shown.

The Gateway projection consumes the per-agent prepared model catalog supplied by the Gateway session-list/read boundary without starting provider discovery. Runtime reply resolution and Gateway projection share shouldUseModelReasoningDefault(...), so model defaults apply only when reasoning is not explicit, thinking is inactive, and thinking was not explicitly disabled. Explicit session/agent settings still win, including legacy stored non-off values such as high. Completed saved reasoning is shown for non-off effective levels except stream, which remains transient-only.

User Impact

When View -> Reasoning is enabled, completed messages with saved thinking are visible for inherited reasoning-on and model-default sessions. Inherited stream-mode sessions continue to hide completed reasoning while preserving the final answer.

Evidence

Verified against commit 8dade94e203e61c586791de594ed5e6f084e0a51 using a real loopback openclaw gateway run, isolated SQLite session/transcript stores, and the real Control UI in headless Google Chrome. No mock Gateway and no model request were used; transcripts contain fixed non-sensitive proof markers.

{"id":"on","thinkingCount":1,"thinkingTextCount":1,"finalVisible":true,"reasoningVisible":true}
{"id":"stream","thinkingCount":0,"thinkingTextCount":0,"finalVisible":true,"reasoningVisible":false}
{"id":"model","thinkingCount":1,"thinkingTextCount":1,"finalVisible":true,"reasoningVisible":true}

The on agent inherited reasoningDefault: "on"; stream inherited reasoningDefault: "stream"; model had no session or agent reasoning override and consumed the reasoning-capable prepared model catalog default.

Inherited on: completed reasoning visible

Inherited on proof

Inherited stream: final visible, completed reasoning absent

Inherited stream proof

Model default: completed reasoning visible

Model default proof

Proof manifest and reproduction details

Validation

  • pnpm test src/agents/model-selection.test.ts src/gateway/session-utils-row.test.ts src/gateway/server.chat.gateway-server-chat.test.ts src/auto-reply/reply/get-reply-directives.target-session.test.ts src/gateway/session-event-payload.test.ts src/gateway/session-utils-owners.test.ts ui/src/pages/chat/components/chat-transcript-render.test.ts -> 259 passed
  • pnpm check:changed -- src/agents/model-selection.ts src/agents/model-selection.test.ts src/auto-reply/reply/get-reply-directives.ts src/gateway/session-utils-reasoning.ts src/gateway/session-utils-row.ts src/gateway/session-utils-row.test.ts src/gateway/session-event-payload.ts src/gateway/session-event-payload.test.ts src/gateway/session-utils-owners.test.ts src/gateway/session-utils.types.ts ui/src/api/types.ts ui/src/pages/chat/components/chat-transcript-projection.ts ui/src/pages/chat/components/chat-transcript-render.test.ts -> passed after rebase to current main
  • autoreview --mode local --engine pi --thinking high -> clean, correctness 0.98
  • TruffleHog -> clean

AI-assisted implementation; I reviewed the prepared model-runtime boundary, shared runtime/Gateway reasoning-default policy, session-change event projection, Control UI visibility gate, real Gateway/Control UI proof, and validation output.

Exact-head lifecycle proof

Repeated after the required main rebase on current functional head 49ad9dc4c9b903b2e53314be87ec5c29de7ca7ec:

  • real loopback Gateway and isolated SQLite state;
  • Gateway-accepted Control UI build 2026.8.1-49ad9dc4c9b9-2026-08-30T06-40-52.027Z;
  • real Control UI in headless Chrome for Testing at 1440x1000;
  • real sessions.patch RPC while capturing sessions.changed WebSocket frames;
  • inherited on: completed reasoning visible before and after the lifecycle patch;
  • inherited stream: completed reasoning hidden before and after the lifecycle patch;
  • model capability default: completed reasoning visible before and after the lifecycle patch;
  • two matching events per case, no event contained destructive effectiveReasoningLevel:"off", every RPC succeeded, and every updated label rendered.

Exact-head artifacts at immutable proof commit 2eadb12cf5457cdaf38af06cf015e1a7c4179d93:

Exact-head bounded fence validation

The current head uses an active session-key fence only while a lifecycle projection awaits the prepared model catalog. The fence is released in a finally block, so historical session churn is not retained in process-global state.

  • Same-session identity reset during catalog loading invalidates and discards the event.
  • An unrelated session reset does not suppress the event.
  • 100 released fences across distinct churn keys remain current after later mutations, covering release and bounded-state behavior.
  • Focused lifecycle and Gateway suites passed 45/45 on the exact head.
  • pnpm check:changed passed for the bounded fence and Gateway event files.

Latest head: cron listener isolation + main rebase

Exact head 0254438945f904aea41ba17a262bae677536fcaf.

  • Rebased onto current origin/main; the single sessions-read.ts conflict was resolved by retaining main's agentId projection alongside the extracted sessions.describe handler and prepared-catalog reasoning metadata.
  • Fixed the ClawSweeper P2: broadcastCronBoundSessionChanges is synchronous again, so a row-load or broadcast throw stays inside CronService.emit's synchronous isolation instead of becoming a discarded rejected promise.
  • Focused suites pass: server-cron, sessions-read, session-utils-row, session-event-payload, server-session-events, server-session-lifecycle-events, session-lifecycle-events, and chat-transcript-render (235 tests across the rebased head).
  • check:changed passed production typecheck, formatting, boundaries, i18n catalog, ratchets, and all other gates through core-test typecheck; the only remaining local gate failure is unchanged ui/vite.config.ts missing a pako declaration in the reused dependency tree, outside this diff.
  • Latest origin/main merge-tree is clean.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S labels Aug 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed September 2, 2026, 2:14 PM ET / 18:14 UTC.

ClawSweeper review

What this changes

This PR derives inherited/model reasoning visibility into session rows so Control UI transcripts can show saved reasoning when the effective setting enables it.

Merge readiness

⚠️ Needs maintainer review before merge - 4 items remain

Keep open: the branch exposes saved reasoning for arbitrary noncanonical persisted values, contradicting the documented and recently merged rule that only explicit on may reveal it.

Priority: P1
Reviewed head: 8fa73f3a0f1b63ec6dc6081f41983ada9b59241f

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The intended UI behavior has credible proof, but a source-proven visibility-contract regression must be corrected before this is merge-ready.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Prepared Control UI screenshots credibly demonstrate the central inherited-on, model-default, and stream-hidden transcript behavior through the rendered product surface; the source-proven legacy-value regression remains unexercised by that proof.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Prepared Control UI screenshots credibly demonstrate the central inherited-on, model-default, and stream-hidden transcript behavior through the rendered product surface; the source-proven legacy-value regression remains unexercised by that proof.
Evidence reviewed 6 items Introduced visibility gate: The PR computes display visibility as true for every effective value other than off or stream, so an arbitrary stored nonempty value becomes an opt-in.
Unknown stored values are preserved: The new Gateway resolver deliberately retains a noncanonical stored reasoning value when normalization fails, feeding that value to the UI gate.
Regression is intentionally exercised: New tests assert that a legacy stored value of high remains effective and visible, confirming the introduced path is deliberate rather than unreachable.
Findings 1 actionable finding [P1] Keep saved reasoning behind the canonical on state
Security Needs attention Unknown reasoning states bypass display opt-in: Arbitrary persisted values become display-enabled even though the supported contract has only on, off, and stream; saved reasoning should remain hidden unless canonical on is established.

How this fits together

Gateway session projection combines a session override, configured defaults, and model metadata into a row consumed by Control UI. The transcript renderer then decides whether completed thinking content is visible alongside the final answer.

flowchart LR
  A[Session override and defaults] --> B[Gateway reasoning projection]
  B --> C[Session row]
  C --> D[Control UI visibility decision]
  D --> E[Completed transcript]
Loading

Before merge

  • Keep saved reasoning behind the canonical `on` state (P1) - resolveGatewaySessionReasoningLevel preserves any unknown stored value (for example "high"), and this gate then treats every value except off and stream as permission to render completed thinking. Current main and the docs make on the sole saved-history opt-in, so malformed or legacy session rows can disclose reasoning without that opt-in. Normalize the display state or fail closed for unknown values; update the new legacy-value tests accordingly.
  • Resolve security concern: Unknown reasoning states bypass display opt-in - Arbitrary persisted values become display-enabled even though the supported contract has only on, off, and stream; saved reasoning should remain hidden unless canonical on is established.
  • Resolve merge risk (P1) - Merging could reveal completed saved reasoning for legacy, malformed, or otherwise noncanonical persisted values even though the user has not selected the documented on state.
  • Complete next step (P2) - Restrict completed transcript reasoning to canonical effective on and add regression coverage for invalid or legacy stored values.

Findings

  • [P1] Keep saved reasoning behind the canonical on state — ui/src/pages/chat/components/chat-transcript-projection.ts:97
  • [medium] Unknown reasoning states bypass display opt-in — ui/src/pages/chat/components/chat-transcript-projection.ts:97
Agent review details

Security

Needs attention: The introduced unknown-value path weakens the explicit reasoning-visibility boundary and can expose saved model reasoning.

PR surface

Source +493, Tests +1058. Total +1551 across 39 files.

View PR surface stats
Area Files Added Removed Net
Source 21 632 139 +493
Tests 18 1086 28 +1058
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 39 1718 167 +1551

Review metrics

Metric Value Why it matters
Change size 39 files; +1,718/-167 total The PR reaches Gateway event/session projection and Control UI rather than only the transcript gate.
Judged production versus test delta production approximately +500; tests/support approximately +1,200 Substantial production growth expands the review surface beyond the UI behavior, while most added coverage is test/support code.

Merge-risk options

Maintainer options:

  1. Fail closed for unknown values (recommended)
    Normalize the effective display state to on|off|stream and keep unknown persisted values hidden before merging.
  2. Accept legacy-value disclosure
    Merge the current behavior only if maintainers intentionally redefine noncanonical stored values as an enabled reasoning-display contract.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Normalize effective reasoning visibility to canonical on/off/stream values; unknown persisted values must remain hidden, with a legacy-value regression case.

Technical review

Best possible solution:

Keep completed reasoning behind the canonical effective on state; normalize or fail closed on unknown persisted values and remove the tests that treat them as enabled.

Do we have a high-confidence way to reproduce the issue?

Yes—source reproduction is high confidence: a stored reasoningLevel: "high" reaches the introduced non-off/non-stream UI gate and the PR includes tests asserting that visibility; no untrusted contributor code was executed.

Is this the best way to solve the issue?

No—the effective-state projection is useful, but treating an unrecognized persisted string as enabled conflicts with the current canonical and documented visibility contract.

Full review comments:

  • [P1] Keep saved reasoning behind the canonical on state — ui/src/pages/chat/components/chat-transcript-projection.ts:97
    resolveGatewaySessionReasoningLevel preserves any unknown stored value (for example "high"), and this gate then treats every value except off and stream as permission to render completed thinking. Current main and the docs make on the sole saved-history opt-in, so malformed or legacy session rows can disclose reasoning without that opt-in. Normalize the display state or fail closed for unknown values; update the new legacy-value tests accordingly.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1212f991db46.

Labels

Label changes:

  • add P1: The introduced condition can display saved reasoning despite the documented user visibility setting.
  • add merge-risk: 🚨 compatibility: Existing persisted session rows with noncanonical values change from hidden on current main to visible after merge.
  • add merge-risk: 🚨 security-boundary: The visibility control is a boundary around potentially sensitive saved reasoning, and unknown values bypass its explicit opt-in.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): Prepared Control UI screenshots credibly demonstrate the central inherited-on, model-default, and stream-hidden transcript behavior through the rendered product surface; the source-proven legacy-value regression remains unexercised by that proof.
  • remove P2: Current review triage priority is P1, so this older priority label is no longer current.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The introduced condition can display saved reasoning despite the documented user visibility setting.
  • merge-risk: 🚨 compatibility: Existing persisted session rows with noncanonical values change from hidden on current main to visible after merge.
  • merge-risk: 🚨 security-boundary: The visibility control is a boundary around potentially sensitive saved reasoning, and unknown values bypass its explicit opt-in.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): Prepared Control UI screenshots credibly demonstrate the central inherited-on, model-default, and stream-hidden transcript behavior through the rendered product surface; the source-proven legacy-value regression remains unexercised by that proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. Prepared Control UI screenshots credibly demonstrate the central inherited-on, model-default, and stream-hidden transcript behavior through the rendered product surface; the source-proven legacy-value regression remains unexercised by that proof.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Prepared Control UI screenshots credibly demonstrate the central inherited-on, model-default, and stream-hidden transcript behavior through the rendered product surface; the source-proven legacy-value regression remains unexercised by that proof.

Evidence

Security concerns:

  • [medium] Unknown reasoning states bypass display opt-in — ui/src/pages/chat/components/chat-transcript-projection.ts:97
    Arbitrary persisted values become display-enabled even though the supported contract has only on, off, and stream; saved reasoning should remain hidden unless canonical on is established.
    Confidence: 0.91

Acceptance criteria:

  • [P1] Add renderer and Gateway projection coverage showing an unknown persisted reasoning value remains hidden.
  • [P1] Run the focused Gateway session-row and Control UI transcript-render suites.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Fail closed for noncanonical persisted reasoning values and add a regression case proving they remain hidden.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (51 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-30T06:17:45.358Z sha 3a73fee56c28e3673d75c939db7300d42e32f13b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T06:48:20.032Z sha 49ad9dc4c9b903b2e53314be87ec5c29de7ca7ec :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T06:57:57.449Z sha 49ad9dc4c9b903b2e53314be87ec5c29de7ca7ec :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T08:41:54.474Z sha 49ad9dc4c9b903b2e53314be87ec5c29de7ca7ec :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T01:58:06.331Z sha 5bc118b1f76058f9acbc78fdfc874f27691d417e :: needs changes before merge. :: [P2] Keep cron listener failures inside the scheduler isolation boundary
  • reviewed 2026-08-31T19:39:39.709Z sha 346c58b779895c8070f227b3cba619a686884b53 :: needs changes before merge. :: [P2] Keep cron listener failures inside scheduler isolation
  • reviewed 2026-09-01T05:33:38.529Z sha 0254438945f904aea41ba17a262bae677536fcaf :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T21:52:18.849Z sha 8fa73f3 :: needs maintainer review before merge. :: none

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Aug 23, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 24, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 24, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 24, 2026
@gaoanze888

This comment was marked as spam.

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UX] 思考过程(reasoning)在回复完成后自动消失,无法回顾 / Reasoning text disappears after response completes

1 participant