feat(kanban): harden budget-aware execution recovery - #66965
Open
GravityTone wants to merge 1 commit into
Open
GravityTone wants to merge 1 commit into
GravityTone wants to merge 1 commit into
Conversation
Builds on timeout-salvage work from NousResearch#52511 and implements the preventive budget-warning contract from NousResearch#54153. Co-authored-by: Daniel Maly <maly.daniel@protonmail.com>
GravityTone
marked this pull request as draft
July 18, 2026 14:43
GravityTone
force-pushed
the
feat/kanban-token-budget-optimizer
branch
from
July 18, 2026 14:59
31a5333 to
efa7a99
Compare
GravityTone
marked this pull request as ready for review
July 18, 2026 15:00
teknium1
reviewed
Jul 19, 2026
teknium1
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the substantial recovery and ownership hardening work. The current main path still lacks the run-id guard in agent/turn_finalizer.py:109-131, so the underlying Kanban recovery premise remains valid.
Problems
- Blocking:
agent/agent_runtime_helpers.py:422-425now removes every underscore-prefixed message field before the provider path. The PR uses that copy for every request inagent/conversation_loop.py:979. This removes_anthropic_content_blocks, but currentagent/anthropic_adapter.py:2069-2077explicitly reads that field to preserve legacy stashed multimodal tool-result blocks. Anthropic requests are built from these transformed messages viaagent/chat_completion_helpers.py:859-869, so the compatibility path loses its image/content blocks.
Suggested changes
- Preserve
_anthropic_content_blocksuntil Anthropic conversion, or restrict early stripping to known bookkeeping markers and retain generic transport sanitization afterward. - Add an Anthropic request-path regression test for a tool message containing
_anthropic_content_blocks.
Automated hermes-sweeper review.
| if content | ||
| else repaired_user_prefix | ||
| ) | ||
| for internal_key in [ |
Collaborator
There was a problem hiding this comment.
Blocking: this blanket underscore-key removal also drops _anthropic_content_blocks. The Anthropic converter explicitly consumes that back-compat field in agent/anthropic_adapter.py:2069-2077, and this helper is now used before provider conversion at agent/conversation_loop.py:979. Preserve that field until Anthropic conversion (or narrow this filter) and add a request-path regression test.
16 tasks done
This branch has not been deployed
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.
Summary
This PR hardens Kanban execution so long-running work can use fewer context tokens and iterations without increasing
max_turns.LATEST_HANDOFFandCONTEXT_REFpartial_summary_fullPREPARE_ONLYBuilds on the timeout-salvage work in #52511 and implements the preventive budget-warning contract from #54153. The original contribution remains credited in the commit trailer.
Verification
Verification on the final integrated candidate:
git diff --check, Python 3.11 compile, and focused Python 3.9 compile: PASSSynthetic benchmark:
Review receipts
efa7a991148be122e93f7c898f5adf98d4f55083c78aa0bad5dc96c8080b1d16def868f1ab039b0cb6b04c8eaa3be35c4a6d895d7d2e6f6b5dfefa339f3dea8ac55998cf9302ccab61a55c3c5a47e4b9843de4e86095121ee2122d901cbf19e12bc68b1a515706ce9ae8f0883f5c05409c292666ae8447ede02fd55eAfter the frozen review,
mainadvanced by four commits touching three paths. The intersection with the feature's 36 paths is empty; the reviewed base remains an ancestor, andgit merge-treereports a clean merge against currentmain.