microsoft / microsoft/agent-framework

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

Open
#7,338 1 comment 0 reactions 1 assignee View on GitHub

@moonbox3 is already working on this.

Since Jul 27, 2026.

ag-ui python
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

### Discussed in https://github.com/microsoft/agent-framework/discussions/7320

Originally posted by **mjod** July 25, 2026
In [agent_framework_ag_ui._workflow_run.py:L968](https://github.com/microsoft/agent-framework/blob/main/python/packages/ag-ui/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:

```python
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](https://docs.ag-ui.com/concepts/messages#message-structure). 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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.