Skip to content

Conversation

@Phire1
Copy link

@Phire1 Phire1 commented Jul 10, 2025

This PR fixes a subtle bug where assigning to state.output.completion unintentionally mutated the last message in the message history, due to both referencing the same object.

This PR contains:

  • Bug fixes

What is the current behavior? (You can also link to an open issue here)

Before, line 199 (state.output.completion = answer) would modify the last message because the completion and the last message pointed to the same thing.

What is the new behavior?

Now, the code copies the message so that they're decoupled from each other

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

No

Other information:

Encountered when using Control Arena

Phire1 and others added 2 commits July 9, 2025 18:39
@jjallaire
Copy link
Collaborator

I am not sure we want this behavior, as in the case of agent handoffs we actually want to mutate the last assistant message to have the "answer" (as otherwise it will have only the tool call with the answer, which is then stripped). This means that when the parent agent gets the history back from agent it handed off to it can't see the answer.

Open to other ways to handle / think about this, but I believe the behavior you are seeing now is intentional.

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