Skip to content

Python: [AGUI] BaseMessage message_id uniqueness semantics - per-thread or globally unique or something else? #7338

Description

@moonbox3

Discussed in #7320

Originally posted by mjod July 25, 2026
In agent_framework_ag_ui._workflow_run.py:L968, executor activities use message_id=f"executor:{executor_id}" without including the run_id or some unique identifier:

yield ActivitySnapshotEvent(
    message_id=f"executor:{executor_id}" if executor_id else generate_event_id(),
    activity_type="executor",
    content=executor_payload,
)

Issue:
When a user sends multiple prompts (separate workflow runs), the same message_id is reused across runs. For example:

  • Run 1: message_id="executor:synthesizer"
  • Run 2: message_id="executor:synthesizer" (same ID!)
    This could cause UI issues where activities from Run 2 overwrite/update activities from Run 1. Also how we are configuring the DB to store Messages we originally assumed message_id was unique. As mentioned here. In that code block it says id: string // Unique identifier for the message

When ActivitySnapshotEvent is converted to an ActivityMessage, the message_id becomes the message's id field. Our implementation stores these in a database where id is expected to be unique(or so we thought). Without run-scoping, multiple runs using the same executor (e.g., "executor:synthesizer") generate duplicate IDs, causing newer runs to overwrite activities from previous runs. We are still early on this development so maybe our understanding is off and that should be the case and we need to update how we store Messages.

Question:
Should message_id be scoped to the run(or really just general uniqueness)? For example:
message_id=f"{run_id}:executor:{executor_id}" if executor_id else generate_event_id()
Or is the current behavior intentional, and UIs/DBs should handle this differently? It seems like if its missing the generate_event_id() gives it a random uuid which makes me think it should be unique each time.
And a more general question about message_id for all AGUI types, should they always be unique or just unique within that specific thread?

Version: agent_framework_ag_ui==1.0.0

Thanks all, appreciate all the hard work in this package!

Metadata

Metadata

Assignees

Labels

ag-uiUsage: [Issues, PRs], Target: AG-UI protocol integrationpythonUsage: [Issues, PRs], Target: Python

Type

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions