Skip to content

fix: prevent in-place mutation of message history in normalizer#2326

Open
pipe1os wants to merge 3 commits into
strands-agents:mainfrom
pipe1os:fix/prevent-message-history-mutation
Open

fix: prevent in-place mutation of message history in normalizer#2326
pipe1os wants to merge 3 commits into
strands-agents:mainfrom
pipe1os:fix/prevent-message-history-mutation

Conversation

@pipe1os
Copy link
Copy Markdown

@pipe1os pipe1os commented May 25, 2026

Description

Fixes a state corruption bug where _normalize_messages mutated the agent.messages history in place during streaming. This permanently altered the canonical conversation state before it reached the session manager. Changed the normalization loop to build shallow copies so the original message history remains pristine.

Related Issues

N/A

Documentation PR

N/A

Type of Change

Bug fix

Testing

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly - N/A, internal bug fix
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed - N/A, internal bug fix
  • My changes do not introduce any new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant