Skip to content

fix(agent): preserve newest turn in chronological conversation lists - #224

Merged
NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
Bruce-Yii:fix/agent-preserve-newest-turn-list
Sep 23, 2026
Merged

NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
Bruce-Yii:fix/agent-preserve-newest-turn-list

Conversation

@Bruce-Yii

Copy link
Copy Markdown
Contributor

Summary

Long chronological conversation state is serialized newest-last. When it exceeds the available state budget, build_sequence defaults to right truncation (st[:room]), so the newest turn can be silently dropped while Agent.system_one still returns a normal decision.

This patch preserves the most recent conversational intent for the public list-shaped state contract.

Change

  • Detect list-shaped state in Agent.system_one
  • Pass truncate_left=True for conversation turn lists
  • Keep existing truncation behavior unchanged for string and dict state
  • Leave the build_sequence API and default unchanged

Why this shape

Agent.system_one documents list state as a conversation turn list, so the newest turn is at the tail. Preserving the tail is the smallest change that protects recent conversational intent without changing non-conversation callers.

Validation

  • Added 5 regression tests covering list vs. string truncation behavior
  • Full model-free test run: 556 passed, 0 failed
  • Reproduced the failure before the fix on the pinned upstream base

This is orthogonal to #181, which covers truncation metadata reporting. The older #2 explored broader truncate_left plumbing; this PR keeps the change focused on the public conversation-list behavior.

@NandhaKishorM

Copy link
Copy Markdown
Owner

Thank you. Dropping the newest turn of a long conversation is the one truncation that changes the decision, and a list state is always chronological, so left truncation there is right. Strings and dicts keep their current behaviour. Merging.

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.

2 participants