Skip to content

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

Open
pipe1os wants to merge 5 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 5 commits into
strands-agents:mainfrom
pipe1os:fix/prevent-message-history-mutation

Conversation

@pipe1os

@pipe1os pipe1os commented May 25, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added size/s and removed size/s labels May 27, 2026
@yonib05 yonib05 added area-context Session or context related bug Something isn't working python Pull requests that update python code labels May 27, 2026
@yonib05 yonib05 added the area-agent Related to the agent class or general agent questions label Jun 9, 2026
…-history-mutation

# Conflicts:
#	strands-py/src/strands/event_loop/streaming.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-agent Related to the agent class or general agent questions area-context Session or context related bug Something isn't working python Pull requests that update python code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants