fix(core): size background turns for hidden reasoning - #2276
Conversation
There was a problem hiding this comment.
Changes requested: Two minor issues remain: wrapped output-cap errors are misclassified, and the memory spec contradicts the new cap behavior.
Warning
Changes requested · head 6f0b663 · 2 findings: 2 minor
| Severity | Finding | Where |
|---|---|---|
| minor | F1 Wrapped output-cap errors become provider failures | src/core/intake.ts:274 |
| minor | F2 Spec contradiction — docs/reference/specs/memory.md item 12: reflection no longer uses or reports a fixed 1024-token cap | docs/reference/specs/memory.md:27 |
Full review
F1: If intake first receives a malformed answer and the re-ask hits the output cap, askStructured wraps OutputCapError in StructuredAskError. The instanceof OutputCapError check then misses it and records a generic permanent provider failure, potentially emitting the wrong failure sentence. Inspect the preserved cause when classifying truncation and retain the structured attempts.
F2: Memory spec item 12 and validation rows still require a fixed 1,024-token cap, report truncation at 1,024, and allow a complete object that survived truncation to be written. The implementation now uses a reasoning-aware dynamic cap and rejects every max_tokens response without writing. Update the behavior and validation rows to describe the new contract.
Co-Authored-By: coreplane-switchboard[bot] <318072483+coreplane-switchboard[bot]@users.noreply.github.com>
6f0b663 to
ad5cba5
Compare
|
Re-review requested at ad5cba5 — rebased onto current main; fixed wrapped output-cap classification, aligned memory and intake specs, added production cap-propagation proofs, and preserved the typed provider-failure work. Independent OpenCode review is in progress. |
|
Production inclusion receipt — 1.260.6. |
Intake and memory reflection now reserve room for hidden reasoning without misclassifying capped replies. Wrapped intake cuts retain their structured-attempt history, and production composition tests prove both background paths receive their model card’s cap field.
Why: #2267 blocks first-party OpenAI defaults because Responses counts hidden reasoning inside the output cap. The original fix missed a wrapped retry failure, production wiring proof, and the behavior specs.
Where to look
Feedback wanted: Check that unwrapping only
StructuredAskError’s direct preserved cause is the right boundary, and that the two composition tests cover the live bridges without over-coupling startup.Risk: Incorrect classification could turn an output-cap cut into a permanent provider failure or omit the reasoning allowance in production. Revert this single commit to restore the prior behavior.
Verified: 97 focused tests, four exact regression/wiring tests, root TypeScript, specs/docs/hygiene/coverage/test-guard, Prettier, and
npm run fixpassed; CI remains the full-suite gate.Decisions (3)
askStructuredis the boundary that wraps a later model throw after collecting violations, so intake examines that known wrapper instead of recursively interpreting arbitrary error causes.intakeDecisionDepsis used bysrc/index.ts, while reflection is exercised throughscheduleReflection; both tests observe the completion request after model-card resolution.max_tokensresponse reaches parsing or storage.Validation (7 criteria)
npx vitest run src/core/intake.test.ts -t "an output-cap cut after a malformed answer stays an output-cap error and keeps the structured attempt"— passednpx vitest run src/intakeModel.test.ts -t "production intake deps carry the completion's cap field into the verdict call"— passednpx vitest run src/core/memory/index.test.ts -t "carries the reflection model card's cap field into the completion request"— passednpx vitest run src/core/memory/reflection.test.ts -t "every capped response is rejected even when the object is complete; another unusual stop is named"— passednpm run specs:check;npm run specs:coverage -- --changed origin/main...HEAD --test-guard;npm run docs:check— passedtsc --noEmit; changed-file Prettier;npm run hygiene:check;npm run fix— passedFor agents
Rebased onto current
origin/main, resolving the intake test conflict by retaining both the typed provider-failure cases from the base and this PR’s cap tests. The branch is one coherent commit above main.Red step: the new malformed-then-capped intake test failed because the decision reason was
The model provider refused the call…rather than containinganswer cut at the output cap; it passed after unwrapping the preservedOutputCapError.The first
npm run fixattempt used a symlinked dependency tree and rewrote generated Nuxt import paths; those unrelated changes were discarded. A local copy-on-write dependency tree then letnpm run fixcomplete successfully without generated path drift.