Conversation
…ion history Signed-off-by: Michele Papalini <micpapal@cisco.com>
micpapal
marked this pull request as ready for review
September 8, 2026 07:32
Collaborator
|
Superseded by #62 Thanks for the fix and the repro context. #62 addresses the same Bedrock failure (
Why we prefer #62:
Request: Could you confirm this approach fixes the original CONCORD/Bedrock scenario from your side? If so, we will close #55 when #62 merges. Happy to compare diffs or run your benchmark scenario against our branch if useful. |
jordanauge
added a commit
that referenced
this pull request
Sep 11, 2026
- Repair committed history at assembly via sanitize_provider_messages - Pin in-turn working memory with token-budget pin_tail - Add per-session kernel outbound-waits ledger (MODEL/TOOL/HITL) - Fix assembler to retain tool messages and skip live-turn sanitize - Fix pre-existing driver.py lint issues; document zero-tolerance for failures in AGENTS.md
4 tasks
jordanauge
added a commit
that referenced
this pull request
Sep 11, 2026
- Repair committed history at assembly via sanitize_provider_messages - Pin in-turn working memory with token-budget pin_tail - Add per-session kernel outbound-waits ledger (MODEL/TOOL/HITL) - Fix assembler to retain tool messages and skip live-turn sanitize - Fix pre-existing driver.py lint issues; document zero-tolerance for failures in AGENTS.md Signed-off-by: Jordan Augé <augjorda@cisco.com>
jordanauge
added a commit
that referenced
this pull request
Sep 11, 2026
…) (#62) - Repair committed history at assembly via sanitize_provider_messages - Pin in-turn working memory with token-budget pin_tail - Add per-session kernel outbound-waits ledger (MODEL/TOOL/HITL) - Fix assembler to retain tool messages and skip live-turn sanitize - Fix pre-existing driver.py lint issues; document zero-tolerance for failures in AGENTS.md Signed-off-by: Jordan Augé <augjorda@cisco.com>
Collaborator
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.
Problem
Long-running agent conversations that exceed the configured history limit
(
max_messages,max_turns, or the token budget) get trimmed by one of thecontext_managerstrategies (StackConversation,SlidingWindowConversation,SummarizingConversation). All three cut the message list at a positionalboundary with no awareness of tool-call structure, so a truncation could land
between an assistant
tool_callsmessage and its matchingtoolresult,sending one without the other.
Bedrock function-calling APIs reject that outright:
This surfaced in long-running multi-turn agents (e.g. a CONCORD consensus negotiation),
eventually exhausting the LLM call's fallback chain and failing the whole
benchmark run.
token_budget.pytrim_messages_to_budgetalready handled this correctlyvia a private
_skip_tool_grouphelper — it just wasn't shared with theother three strategies.
Fix
library-standard/.../plugins/context/tool_pairing.pywith two sharedhelpers:
skip_tool_group(messages, start)— returns how many messages must beevicted together as one atomic unit (an assistant
tool_callsmessageplus every
toolresponse that references one of those call ids).group_exchanges(past)— builds turn-level exchange groups forwindowing, folding trailing tool call/result messages into the exchange
they belong to instead of splitting them into their own single-message
exchanges.
token_budget.pynow importsskip_tool_groupfrom the shared moduleinstead of keeping a private duplicate (no behavior change).
StackConversation.manage_historynow evicts from the front intool-call-atomic units instead of a raw
past[-max_messages:]slice.SlidingWindowConversationandSummarizingConversationnow build theirexchange groups via
group_exchanges, so slicing by turn count can neverland inside a tool_calls/tool_result pair.
Testing
runtime/tests,library-standard/tests).result, landing exactly on a trim boundary) confirming no orphaned
toolmessage reaches position 0 after trimming, for both
StackConversationand
SlidingWindowConversation.Expected toolResult blockserror no longer occurs across 5 consecutiveruns.