Skip to content

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

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

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

Conversation

@gaoanze888

@gaoanze888 gaoanze888 commented Sep 3, 2026 •

Copy link
Copy Markdown

What Problem This Solves

Completed assistant reasoning could stay collapsed in the Control UI transcript when reasoning was enabled through an inherited agent/global default or the selected model's reasoning capability — rather than a session-specific reasoningLevel override. The transcript renderer only consulted the stored override, so even though saved thinking blocks existed, they never rendered because no override matched.

Closes #79469.

Change

Project the effective reasoning level on gateway session rows, separately from the stored override, and let the transcript renderer consult it.

  • src/gateway/session-utils-reasoning.ts (new) — resolveGatewaySessionReasoningLevel computes the effective level from the loaded session + prepared model catalog, reusing resolveReasoningDefault / resolveConfiguredThinkingDefaultCore / resolveAgentConfig.
  • src/agents/model-selection.ts — new shouldUseModelReasoningDefault: a model default applies only when reasoning is not explicit, thinking is inactive, and thinking was not explicitly disabled. Keeps model defaults from clobbering explicit settings.
  • src/gateway/session-utils-row.ts + session-utils.types.ts + session-utils-model.ts — buildGatewaySessionRow calls the resolver and adds effectiveReasoningLevel to the projected row (and tolerates a catalog lookup rejection).
  • ui/src/pages/chat/components/chat-transcript-projection.ts + ui/src/api/types.ts — the transcript renderer reads activeSession.effectiveReasoningLevel; non-off effective levels (except stream, which stays transient) now allow saved thinking blocks to render.

Behavior

  • Explicit session/agent reasoningLevel still wins, including legacy stored non-off values such as high.
  • Inherited agent/global defaults and model-capability defaults now surface as the effective level, so saved thinking blocks render.
  • stream remains transient: thinking is shown live while streaming but not persisted/displayed after completion.
  • No session-change event/lifecycle plumbing is added — the effective level is derived from the loaded session row on projection.

Evidence

Local validation on a worktree rebased onto current origin/main (64f4cdac8), zero conflicts:

  • npx vitest run src/agents/model-selection.test.ts src/gateway/session-utils-row.test.ts → 141 passed (141), including the new shouldUseModelReasoningDefault truth table and 5 buildGatewaySessionRow cases: "projects inherited reasoning defaults separately from the stored override", "projects the prepared model reasoning default when no override exists", "omits an unknown model reasoning default without a catalog", "keeps per-model thinking defaults from enabling model reasoning defaults", "preserves legacy stored non-off reasoning values in the effective projection".
  • npx tsc --noEmit -p tsconfig.core.json → clean for the 11 changed files (the only diagnostic, chat-turn-router.ts:188, is pre-existing and reproduces on pristine origin/main with no PR changes; it is a @types resolution artifact of the symlinked node_modules and is not seen by CI's real install).
  • Import audit: the 11 files reference none of the dropped lifecycle/subscription symbols (observeLifecycle, transcriptUnsub, tryBeginGatewaySuspendAdmission, onSessionLifecycleEvent, …), so the scoped change is self-contained.

Diff: 11 files changed, +417/-4.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 agents Agent runtime and tooling size: XL labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 5, 2026, 2:17 AM ET / 06:17 UTC.

ClawSweeper review

What this changes

The PR projects inherited reasoning settings into Gateway session responses and uses them to decide whether saved thinking appears in Control UI transcripts.

Merge readiness

⛔ Blocked before merge - 6 items remain

This remains useful work that current main does not implement. The earlier visibility and event-payload corrections are present, but the previously reported history-refresh defect remains unresolved.

Priority: P2
Reviewed head: 54b891cb2a48bd88d206028f40a788cdced1bceb

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused patch and earlier screenshots provide useful signal, but the unresolved refresh defect and outdated proof scope prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Inspected predecessor screenshots demonstrate inherited on/model visibility and stream hiding in a real Gateway/Control UI setup. They do not establish the revised resolver through catalog-less history replacement and event reconciliation; the captured contributor discussion promises updated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Inspected predecessor screenshots demonstrate inherited on/model visibility and stream hiding in a real Gateway/Control UI setup. They do not establish the revised resolver through catalog-less history replacement and event reconciliation; the captured contributor discussion promises updated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 13 items Introduced change and review continuity: The host verifies merge-base a72ff7a and original head 54b891c. The previous completed review examined this same head and retained the catalog-less history-refresh finding; no subsequent code change addresses it.
Unknown reasoning projection: The introduced resolver returns undefined when neither reasoning nor thinking is explicit and the prepared catalog is unavailable. buildGatewaySessionRow consequently omits effectiveReasoningLevel.
Production history entry point: chat.history requests ready-only startup metadata and continues without that projection when unavailable. It passes the resulting optional catalog through buildGatewaySessionInfo into the changed row builder.
Findings 1 actionable finding [P2] Preserve effective reasoning across catalog-less history refreshes
Security None None.

How this fits together

The Gateway combines session overrides, agent defaults, and prepared model information into session metadata. Control UI reconciles that metadata with history and live events before deciding whether to display saved thinking.

flowchart LR
 A[Session overrides and agent defaults] --> C[Gateway effective reasoning]
 B[Prepared model catalog] --> C
 C --> D[Session snapshots and events]
 D --> E[Control UI reconciliation]
 E --> F{Reasoning on and View enabled}
 F --> G[Show saved thinking]
 F --> H[Hide saved thinking]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Inspected predecessor screenshots demonstrate inherited on/model visibility and stream hiding in a real Gateway/Control UI setup. They do not establish the revised resolver through catalog-less history replacement and event reconciliation; the captured contributor discussion promises updated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve effective reasoning across catalog-less history refreshes (P2) - This omission also reaches chat.history, whose ready-only metadata read can return no catalog. After a catalog-backed row supplies effectiveReasoningLevel: "on", an accepted same-session history response replaces it through reconcileSessionHistory; its preservation helpers do not retain this field. The transcript then falls back to off and hides the saved thinking again. Complete identity-aware reconciliation or retain the prepared fact at its owner, and cover the list-to-history sequence. This is the unresolved finding from the previous review.
  • Resolve merge risk (P1) - The revised projection has not been demonstrated across history replacement and model/profile/settings transitions, where derived visibility must neither disappear nor remain stale.
  • Resolve merge risk (P1) - The added production code leaves model-default eligibility duplicated between Gateway projection and reply resolution, creating a future policy-drift risk.
  • Resolve merge risk (P1) - Captured GitHub state reports merge conflicts; no pinned three-way merge result is available to assess a resolved branch.
  • Complete next step (P2) - Repair the history-refresh defect, resolve the reported conflicts, and update the PR body with revised real-behavior proof and accurate canonical-on/event behavior.

Findings

  • [P2] Preserve effective reasoning across catalog-less history refreshes — src/gateway/session-utils-reasoning.ts:48-49
Agent review details

Security

None.

PR surface

Source +113, Tests +309. Total +422 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 8 115 2 +113
Tests 4 311 2 +309
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 426 4 +422

Review metrics

Metric Value Why it matters
Production versus test growth Production +113 lines; tests +309 lines The additive projection explains some growth, but runtime fallback eligibility remains duplicated and can be shared.
Session response contract 1 derived response field added; 0 configuration options added The new field needs consistent omission and replacement semantics across snapshots and events.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #79469
Summary: This PR is the remaining candidate for inherited completed-reasoning visibility; visible-child thinking persistence is separate work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Mantis proof suggestion

Web UI chat proof can directly show whether saved reasoning survives history refresh and session updates. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis verify inherited-on and model-default saved reasoning in Control UI through history refresh and session updates, confirm off and stream remain hidden, and return a redacted recording with session-response evidence.

Merge-risk options

Maintainer options:

  1. Complete reasoning-state reconciliation (recommended)
    Preserve resolved reasoning only for matching session and setting identities, then demonstrate history refresh and live updates together.

Technical review

Best possible solution:

Reuse one reasoning-default policy and identity-aware session reconciliation so inherited on survives refreshes while explicit off and stream remain hidden.

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

Yes, from source: reconcile a catalog-backed model-default row with a same-session catalog-less history row, and the new effective value disappears. This review did not execute that sequence.

Is this the best way to solve the issue?

Not yet: server-owned effective projection is appropriate, but the patch must complete history reconciliation and reuse the existing runtime eligibility policy.

Full review comments:

  • [P2] Preserve effective reasoning across catalog-less history refreshes — src/gateway/session-utils-reasoning.ts:48-49
    This omission also reaches chat.history, whose ready-only metadata read can return no catalog. After a catalog-backed row supplies effectiveReasoningLevel: "on", an accepted same-session history response replaces it through reconcileSessionHistory; its preservation helpers do not retain this field. The transcript then falls back to off and hides the saved thinking again. Complete identity-aware reconciliation or retain the prepared fact at its owner, and cover the list-to-history sequence. This is the unresolved finding from the previous review.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0007cbf8e4c5.

Labels

Label justifications:

  • P2: This repairs a bounded transcript-visibility problem without evidence of a core outage or lost stored messages.
  • merge-risk: 🚨 session-state: The new effective reasoning state can be discarded during accepted history replacement, making the transcript contradict the resolved setting.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Inspected predecessor screenshots demonstrate inherited on/model visibility and stream hiding in a real Gateway/Control UI setup. They do not establish the revised resolver through catalog-less history replacement and event reconciliation; the captured contributor discussion promises updated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected predecessor screenshots demonstrate inherited on/model visibility and stream hiding in a real Gateway/Control UI setup. They do not establish the revised resolver through catalog-less history replacement and event reconciliation; the captured contributor discussion promises updated proof.

Evidence

What I checked:

  • Introduced change and review continuity: The host verifies merge-base a72ff7a and original head 54b891c. The previous completed review examined this same head and retained the catalog-less history-refresh finding; no subsequent code change addresses it. (54b891cb2a48)
  • Unknown reasoning projection: The introduced resolver returns undefined when neither reasoning nor thinking is explicit and the prepared catalog is unavailable. buildGatewaySessionRow consequently omits effectiveReasoningLevel. (src/gateway/session-utils-reasoning.ts:48, 54b891cb2a48)
  • Production history entry point: chat.history requests ready-only startup metadata and continues without that projection when unavailable. It passes the resulting optional catalog through buildGatewaySessionInfo into the changed row builder. (src/gateway/server-methods/chat-history-handler.ts:325, 54b891cb2a48)
  • History replacement loses the new field: The history reconciliation path replaces the existing row. Its preservation helpers retain thinking-picker and roster presentation metadata, but not effectiveReasoningLevel; chat-state-refresh routes accepted history through this owner. (ui/src/lib/sessions/reconcile.ts:604, 54b891cb2a48)
  • Earlier corrections verified: The current event payload omits unknown effective reasoning rather than emitting a null tombstone, retains archiveReason's null tombstone, and the transcript gate requires canonical on. The legacy-value rendering test now expects thinking to remain hidden. (src/gateway/session-event-payload.ts:93, 54b891cb2a48)
  • Existing policy and sibling runtime: Reply resolution already owns model-default eligibility, but still uses its inline predicate rather than the newly introduced helper. The changed display path consumes OpenClaw catalog flags and session rows; it does not change or require a Codex runtime/protocol contract. (src/auto-reply/reply/get-reply-directives.ts:604, 54b891cb2a48)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vyctor H. Brzezowski: 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.

  • Fix and cover catalog-less history replacement with identity-aware preservation, sharing fallback eligibility with reply resolution.
  • Resolve the reported merge conflicts while preserving current-main behavior.
  • Add a short recording of the revised real Gateway/Control UI through history refresh and session updates, with off/stream hidden; redact keys, IPs, phone numbers, and private endpoints. Update the PR body to trigger re-review, or ask a maintainer for @clawsweeper re-review.

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 (6 earlier review cycles)
  • reviewed 2026-09-03T08:17:37.082Z sha 8c546098f1f3c46742296ffe128cbc470baea79a :: needs real behavior proof before merge. :: [P1] Keep saved reasoning gated to approved on consent
  • reviewed 2026-09-03T08:36:09.663Z sha f9ac1566162160738edf4220f478b909661b2c2c :: needs real behavior proof before merge. :: [P1] Keep completed saved reasoning gated to canonical on
  • reviewed 2026-09-03T09:54:24.280Z sha c1a304f6d4a2d3916312d77298c3a46c3003069b :: needs real behavior proof before merge. :: [P1] Keep saved reasoning gated to canonical on | [P1] Recompute capacity state after the catalog await
  • reviewed 2026-09-03T11:43:56.689Z sha 0fe8f3ac02708f321870f41776957b1fa451069b :: needs real behavior proof before merge. :: [P1] Serialize the effective reasoning level in session events | [P1] Gate completed reasoning on canonical on
  • reviewed 2026-09-04T09:46:52.671Z sha d449b62 :: needs real behavior proof before merge. :: [P1] Do not tombstone model-derived reasoning on lifecycle events | [P1] Restore archive reason in session change events | [P1] Align legacy reasoning coverage with the canonical visibility gate
  • reviewed 2026-09-05T04:59:49.022Z sha 54b891c :: needs real behavior proof before merge. :: [P2] Preserve effective reasoning across catalog-less history refreshes

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Sep 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: XL triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 3, 2026
@clawsweeper clawsweeper Bot added 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 Sep 3, 2026
…s clawsweeper findings

- effectiveReasoningLevel now serialized in gateway session event payload (Finding 1)
- resolveGatewaySessionReasoningLevel falls back to off instead of raw stored value (Finding 2)
- showReasoning requires canonical on (Finding 2)
- rebased onto current main (a72ff7a)
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Sep 4, 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.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 4, 2026
…veReason, test gate)

- Finding 1 [P1]: session-event-payload.ts effectiveReasoningLevel now uses
  conditional spread (omit when undefined) instead of `?? null`. The prior
  `?? null` converted a catalog-unknown value to null, which reconciliation
  interpreted as a tombstone clearing an already-on row from a prior
  sessions.list snapshot. Omitting the field preserves the prepared value.
- Finding 2 [P1]: restore `archiveReason: sessionRow.archiveReason ?? null` at
  session-event-payload.ts:44. The prior bot-fix tree dropped the field and its
  null tombstone; UI reconciliation needs the null form to remove a stale
  archive notice after unarchiving, and existing coverage requires both forms.
- Finding 3 [P1]: chat-transcript-render.test.ts legacy-coverage case now
  asserts `.chat-thinking` is null for `reasoningLevel: "high"` with no
  effective level, matching the production canonical-on visibility gate.
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Sep 5, 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 5, 2026
@clawsweeper clawsweeper Bot removed P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 5, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 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: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant