Repository navigation
fix(gateway): retain thinking facts across partial catalog rows - #170659
Merged
Merged
Conversation
Keep prepared thinking facts keyed by their row-context owner when later rows omit configured reasoning metadata. Config and catalog publication already replace that context; configured reasoning remains an input to policy resolution. Add a runtime-route donor regression alongside the existing missing-catalog and identity-only cases. This retains the reasoning-disabled route behavior from #170589 while repairing its metadata cache regression.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 13, 2026
steipete
added a commit
that referenced
this pull request
Oct 13, 2026
## What Problem This Solves Interrupted provider streams could save generated text with zero or partial token counters and present them as complete usage. A cancelled Ollama `/v1` stream reproduced `Context: 0/33k` despite saving text. ## User Impact Interrupted or unmeasured responses report usage as unavailable in status, session metadata, accounting, and usage summaries. Complete measured-zero usage remains zero, and successful streams retain exact provider accounting. Known historical subtotals remain visible without being presented as complete totals. Compatible HTTP responses omit unavailable usage while completing their normal lifecycle. No configuration, database migration, or protocol version change is required. The optional completeness fact preserves legacy producer and stored-transcript interpretation; it cannot reconstruct missing historical usage. ## Why This Change Was Made The transport owns accounting completeness. The same fact flows through normalization, run aggregation, the existing session snapshot and abort-partial transaction, then reporting consumers. Terminal usage survives a later transport error. Transcript-backed status and session rows preserve authoritative zero instead of substituting an estimate. This preserves @OWWZO's commits and credit. Main `a59427ccc909c8cc6077ef7c9826e2ba4953f73a` was merged without rebasing or force-pushing. Current head: `c75898aa34c7c55aacfcc451c4e36dfa0e08f38d`. Against that merged base: production +858/-484 (net +374), tests/fixtures +1098/-148, docs +10/-1. The necessary growth carries one completeness fact through existing typed consumers; superseded partial handling is removed. Prompt/tool text is unchanged; token delta is zero. ## Evidence - Real CLI → isolated Gateway → Ollama `/v1`, `llama3.2:latest`, on main `706e08c4431947585166891a60c616366c87cf64`: cancellation saved 945 characters with zero/fresh usage and `/status` showed `Context: 0/33k`. Successful control: exact 2605 input / 19 output tokens. - Repaired generation at `87fa95081e10f082b7caa6543207b8563a3759f7` saved 4607 characters after interruption with unavailable usage. Successful `/v1` and native controls retained exact provider accounting (1809/4 and 1808/10). - Real CLI `/status`, `chat.history`, and `sessions.list` readback at `8dd5b2bea6f9a6a8f4c43bcaa5414b8dce0e58f9` reopened that saved interruption: `Tokens: unavailable (incomplete response)`, `Context: ~4.2k/33k (13% est)`, null totals, false freshness. This is later persistence/status readback of the real generation, not a fresh-generation claim for the final head. Focused local validation of the merged implementation (the final commit only removes a stale max-lines exemption): | Suite | Result | Wrapper wall time | | --- | --- | --- | | Lane controllers | 36 passed | 178.95 s | | Original 28-file Bun group | 500 passed | 230.82 s | | Storage and yielded Stop | 21 passed | 410.74 s | | Usage/readers and metadata | 30 passed | 340.90 s | | CLI/transport siblings | 72 passed | 225.23 s | Repository build, scoped core/UI/agent/Gateway types, lint, formatting, and all seven ratchet/config checks pass. The max-lines gate correctly identified the now-unneeded CLI exemption; it was removed and the check passed. No test assertion or deadline was weakened. The package-boundary declaration compiler used its supported 900-second budget, based on the prior cold-build timing; it completed successfully. ## CI and review Main was merged without conflicts. Its landed fixes now cover the two inherited failures from the prior CI run: - Workboard asset manifest: `faa8ad8e59833d23d606dbc3b73a7258265f094a`. On a fresh detached main checkout, the repository generator passed in 1.89 seconds and left the manifest unchanged. - Partial-catalog thinking metadata: `7b871cd72f219d94f27f7e4b3ddc9bbb12a0f544` (#170659). The exact metadata suite passed 7/7 on fresh main in 60.64 seconds. Both checks used main `89a3addb0de424ee46409938d81b289a34166470`; the relevant owners are unchanged in the merged main base. The prior task-suggestion scroll failure was classified as unrelated: head and exact main base each passed ten complete bundled UI E2E file runs (100 cases each), with identical summary scroll dimensions at all three viewports. The unchanged suggestion renderer, controller, and CSS do not consume usage in that empty-transcript fixture. The original Linux browser/timing trigger remains unobserved on macOS. Independent Codex review of the committed branch was scoped-clean through P2. The final one-line max-lines baseline deletion received a separate scoped-clean P2 review. The worktree contains no uncommitted source changes. Exact-head [CI run 38372789852](https://github.com/openclaw/openclaw/actions/runs/38372789852) completed successfully: 101 jobs passed, 21 skipped, zero failures. The exact-head combined CI gate and applicable security review also passed. The earlier ClawSweeper review found no code defects. Its Telegram Test Server and latest-stable upgrade proof requests remain explicitly accepted limitations. Historical CLI/Gateway/Ollama proof above is reused without claiming fresh generation on this merge head. Before (synthetic mock-Gateway fixture):  After (same synthetic fixture):  Co-authored-by: OWWZO <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 14, 2026
…claw#170659) Keep thinking-policy memoization under its existing row-context owner while retaining configured reasoning as resolver input. Partial catalog rows reuse complete facts until normal config or catalog publication invalidates the context. Regression proof: hosted exact file 7/7; PR CI 38349551198 passed with unchanged T1 and dialect counts. Two scoped Codex reviews found no actionable issues.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 14, 2026
## What Problem This Solves Interrupted provider streams could save generated text with zero or partial token counters and present them as complete usage. A cancelled Ollama `/v1` stream reproduced `Context: 0/33k` despite saving text. ## User Impact Interrupted or unmeasured responses report usage as unavailable in status, session metadata, accounting, and usage summaries. Complete measured-zero usage remains zero, and successful streams retain exact provider accounting. Known historical subtotals remain visible without being presented as complete totals. Compatible HTTP responses omit unavailable usage while completing their normal lifecycle. No configuration, database migration, or protocol version change is required. The optional completeness fact preserves legacy producer and stored-transcript interpretation; it cannot reconstruct missing historical usage. ## Why This Change Was Made The transport owns accounting completeness. The same fact flows through normalization, run aggregation, the existing session snapshot and abort-partial transaction, then reporting consumers. Terminal usage survives a later transport error. Transcript-backed status and session rows preserve authoritative zero instead of substituting an estimate. This preserves @OWWZO's commits and credit. Main `63bc8291bdc629f00803ccb14c591def212b37b3` was merged without rebasing or force-pushing. Current head: `c75898aa34c7c55aacfcc451c4e36dfa0e08f38d`. Against that merged base: production +858/-484 (net +374), tests/fixtures +1098/-148, docs +10/-1. The necessary growth carries one completeness fact through existing typed consumers; superseded partial handling is removed. Prompt/tool text is unchanged; token delta is zero. ## Evidence - Real CLI → isolated Gateway → Ollama `/v1`, `llama3.2:latest`, on main `17b55930758797692cecae98ec0e7a254d06563b`: cancellation saved 945 characters with zero/fresh usage and `/status` showed `Context: 0/33k`. Successful control: exact 2605 input / 19 output tokens. - Repaired generation at `87fa95081e10f082b7caa6543207b8563a3759f7` saved 4607 characters after interruption with unavailable usage. Successful `/v1` and native controls retained exact provider accounting (1809/4 and 1808/10). - Real CLI `/status`, `chat.history`, and `sessions.list` readback at `8dd5b2bea6f9a6a8f4c43bcaa5414b8dce0e58f9` reopened that saved interruption: `Tokens: unavailable (incomplete response)`, `Context: ~4.2k/33k (13% est)`, null totals, false freshness. This is later persistence/status readback of the real generation, not a fresh-generation claim for the final head. Focused local validation of the merged implementation (the final commit only removes a stale max-lines exemption): | Suite | Result | Wrapper wall time | | --- | --- | --- | | Lane controllers | 36 passed | 178.95 s | | Original 28-file Bun group | 500 passed | 230.82 s | | Storage and yielded Stop | 21 passed | 410.74 s | | Usage/readers and metadata | 30 passed | 340.90 s | | CLI/transport siblings | 72 passed | 225.23 s | Repository build, scoped core/UI/agent/Gateway types, lint, formatting, and all seven ratchet/config checks pass. The max-lines gate correctly identified the now-unneeded CLI exemption; it was removed and the check passed. No test assertion or deadline was weakened. The package-boundary declaration compiler used its supported 900-second budget, based on the prior cold-build timing; it completed successfully. ## CI and review Main was merged without conflicts. Its landed fixes now cover the two inherited failures from the prior CI run: - Workboard asset manifest: `31dfabbb3230d76c696f34bf91a554c6819f9b89`. On a fresh detached main checkout, the repository generator passed in 1.89 seconds and left the manifest unchanged. - Partial-catalog thinking metadata: `8740cb3b96da88ef10b55d77cd6457ba7fb26bde` (openclaw#170659). The exact metadata suite passed 7/7 on fresh main in 60.64 seconds. Both checks used main `7c05506250656f245f7d01394b78ab4e6ee832bc`; the relevant owners are unchanged in the merged main base. The prior task-suggestion scroll failure was classified as unrelated: head and exact main base each passed ten complete bundled UI E2E file runs (100 cases each), with identical summary scroll dimensions at all three viewports. The unchanged suggestion renderer, controller, and CSS do not consume usage in that empty-transcript fixture. The original Linux browser/timing trigger remains unobserved on macOS. Independent Codex review of the committed branch was scoped-clean through P2. The final one-line max-lines baseline deletion received a separate scoped-clean P2 review. The worktree contains no uncommitted source changes. Exact-head [CI run 38372789852](https://github.com/openclaw/openclaw/actions/runs/38372789852) completed successfully: 101 jobs passed, 21 skipped, zero failures. The exact-head combined CI gate and applicable security review also passed. The earlier ClawSweeper review found no code defects. Its Telegram Test Server and latest-stable upgrade proof requests remain explicitly accepted limitations. Historical CLI/Gateway/Ollama proof above is reused without claiming fresh generation on this merge head. Before (synthetic mock-Gateway fixture):  After (same synthetic fixture):  Co-authored-by: OWWZO <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
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 Problem This Solves
Session list rows can lose custom thinking labels or resolve the same policy twice when later catalog rows omit model metadata. This started after #170589 added configured reasoning to the cache key.
Keep thinking facts in their existing row-context cache, whose owner replaces the context on config and catalog publication. Configured reasoning still reaches policy resolution. Add a regression that selects a real runtime route, then reads through an empty prepared catalog while retaining the same owner.
Evidence
Two Codex reviews found no actionable issues; changed-file formatting, type-aware lint, and diff checks pass. Exact-file hosted proof: https://github.com/openclaw/openclaw/actions/runs/38349301790 (7/7 tests, zero skips, 33.45s Vitest). PR CI run 38349551198 passed (45 successful jobs, 26 skipped), including the aggregate gate, types, lint, and architecture checks. Madge found zero cycles; T1 remained 455 live / 9 compatibility calls and every dialect group remained zero. The corrected PR-context run also passed. The local attempt stopped during sparse-checkout setup before executing any tests (151.57s); no local pass is claimed.
This changes no database operation, schema, or security boundary. No SQL or T1 savings are claimed; no SQL harness run. Two files, +41/-3 lines, including production +2/-1. Accepted edge: partial catalog rows reuse the context owner’s last complete thinking facts until its normal publication invalidation.