Skip to content

[Bug]: Memory's flushing behavior in _manage_queue may end up with an assistant message as the first message #20256

@GinkREAL

Description

@GinkREAL

Bug Description

If Memory's flushing limit is set low enough such that one conversation turn is enough to make it overflow and trigger the flushing behavior, it is possible to end up with a list of active messages that begin with a assistant message instead of a user message.

Some providers like Amazon Bedrock do not allow this and return an error, since they require that the first message be a user message.

Version

0.12.52.post1

Steps to Reproduce

  1. Create FunctionTool such that the token count returned by the tool triggers Memory's flushing behavior
  2. Create any chat
  3. Observe that the remaining message in the active queue is only the latest assistant reply

Relevant Logs/Tracbacks

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue needs to be triaged/prioritized

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions