Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ChatHistory thread safe #162

Merged
merged 5 commits into from
Aug 8, 2024
Merged

Make ChatHistory thread safe #162

merged 5 commits into from
Aug 8, 2024

Conversation

dsgrieve
Copy link
Member

@dsgrieve dsgrieve commented Aug 6, 2024

Motivation and Context

With Agents API, ChatHistory might be modified by multiple agents running in their own threads.

Description

Used java.util.concurrent.ConcurrentLinkedQueue in place of ArrayList. One consequence of this is that messages from one agent could be interspresed with messages from other agents in the chat history. I don't think this should be a problem. Note that one of the APIs in the agents space is an async receive (AgentChannel#receiveAsync) that will update the ChatHistory. Depending on the implementation of the Agent that uses this AgentChannel API, the messages could be received in bulk or streamed, so it seems the concurrent approach fits the use-case. The alternative is to use a Collections.synchronizeList().

Contribution Checklist

@dsgrieve dsgrieve requested review from johnoliver and milderhc August 6, 2024 21:09
@dsgrieve dsgrieve requested a review from johnoliver August 7, 2024 16:15
@johnoliver johnoliver merged commit 88e7fe7 into microsoft:main Aug 8, 2024
8 checks passed
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.

3 participants