Skip to content

[WIP] Share non-blocking context maintenance and provider-usage recovery - #4321

Draft
JasonW404 wants to merge 5 commits into
developfrom
feature/context-maintenance-recovery
Draft

JasonW404 wants to merge 5 commits into
developfrom
feature/context-maintenance-recovery

Conversation

@JasonW404

@JasonW404 JasonW404 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Local context estimates could exhaust maintenance or recall allowance even when the provider could still serve the request. This change makes counts advisory, calibrates subsequent whole-request estimates from completed provider input usage, and preserves original/protected context when maintenance fails. Explicit provider input overflow can force bounded source-backed history recovery even when the local estimate fits; output truncation remains distinct.

Shared CodeAgent/model/context changes only. Native runtime integration follows in #4315 after this verified foundation. Saved model output budgets are unchanged.

Validation on 0241c3c (product revision b697eac; final test-only fixture correction):

  • Unit suites: 195 shared context/model/runtime, 182 CoreAgent, 141 legacy OpenAI and 96 monitoring tests passed in isolated processes.
  • Maintained transport D3: 65 passed, preparation and cleanup passed; strict formal asset validation passed. Real HTTP assertions cover missing usage, invalid summary preservation and bounded overflow recovery.
  • Built main/web images deployed on the user-authorized host with existing data. Real CodeAgent accepted estimated excess, compressed history, executed Python, summarized/offloaded and reloaded an original result.
  • Nine further real turns accepted eight checkpoints and retained nine exact facts. Browser reopened persisted results. Phoenix default traces: 25da97c495717406150dc56b11d5e3cd, 46dfd8b8f186def4b01b47b61bb6e8cb, 3298259fdae7c37bc3db595bd3557cc0.

Controlled overflow tests use an actual HTTP peer; hosted-model acceptance uses qwen3.8-flash. Full Nexent feature acceptance belongs to the stacked native branch and is still pending. Existing auxiliary summary billing-metric gaps and missing optional history HTTP500 are outside this change.

CI follow-up: the initial runner lost communication. Its retry exposed an eager model-package import in low-dependency runtime tests and mock serialization recursion. Moved the usage helper into neutral context_runtime and restricted structured serialization to Pydantic models. Reproduced then passed the affected 4 bootstrap and 59 history/observation tests; factory tests also pass. Rebuilt/redeployed corrected main image 5925767071ec and repeated actual Python/Agent execution, inspected in Phoenix trace 72caeea199cb3ff2ed2fe6b27a536aa4. Transport D3 65 cases and strict assets revalidated.

Final CI on 0241c3c: all configured checks pass, including unit tests, both image architectures, copyright and CodeQL. Codecov patch coverage 92.24806% (90% target), total 92.1%. The final correction updates test namespaces/imports only; product source matches the rebuilt and verified b697eac image.

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

1 participant