Skip to content

InMemorySessionService allows duplicate events to be appended during concurrent state broadcasts #5723

@chriskinzel

Description

@chriskinzel

Description

In InMemorySessionService.append_event, there is no deduplication check before appending an Event to session.events. When an orchestrator or background task broadcasts shared state updates to multiple concurrent agent sessions, race conditions can cause the exact same event ID to be appended multiple times to a session's history.

Proposed Solution

Add a simple, universal deduplication check at the beginning of append_event:

async def append_event(self, session: Session, event: Event) -> Event:
    if event.partial:
        return event
    if any(e.id == event.id for e in session.events):
        return event
    # ...

Metadata

Metadata

Assignees

Labels

services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions