Description
When running agentcore dev in browser mode (default, without -b), the HTTP proxy
layer generates a new threadId for every AGUI request. This prevents agents from
maintaining multi-turn session state (e.g., via AgentCore Memory STM).
The root cause is in src/cli/operations/dev/web-ui/handlers/invocations.ts,
function handleAguiInvocation:
const aguiBody = JSON.stringify({
threadId: randomUUID(), // ← new UUID on every message
runId: randomUUID(),
...
});
The sessionId parameter is already available in scope, stable per chat session,
and even returned as an x-session-id response header — but it's never used as the
threadId.
Suggested fix:
- threadId: randomUUID(),
+ threadId: sessionId ?? randomUUID()
Steps to Reproduce
- Create an AGUI agent with "protocol": "AGUI" in agentcore.json
- Run agentcore dev (browser mode, no -b flag)
- Send two or more messages in the chat UI
- Log input_data.thread_id in the agent's request handler
Expected Behavior
The threadId remains stable across messages within the same conversation, allowing
agents to maintain session state.
Actual Behavior
A new random threadId is sent with every message:
[2026-07-01T10:32:56] thread_id=d5fa1ec3-87c9-4ca3-84ab-498c15608fbe
[2026-07-01T10:33:05] thread_id=a4fe3ccf-c0cb-4954-9a03-2344efd277ee
Note: TUI mode (agentcore dev -b) does not have this issue — it uses
aguiThreadIdRef in useDevServer.ts which correctly maintains a stable threadId.
The bug is specific to the browser mode HTTP proxy.
CLI Version
0.21.1
Operating System
Linux
Additional Context
No response
Description
When running agentcore dev in browser mode (default, without -b), the HTTP proxy
layer generates a new threadId for every AGUI request. This prevents agents from
maintaining multi-turn session state (e.g., via AgentCore Memory STM).
The root cause is in src/cli/operations/dev/web-ui/handlers/invocations.ts,
function handleAguiInvocation:
The sessionId parameter is already available in scope, stable per chat session,
and even returned as an x-session-id response header — but it's never used as the
threadId.
Suggested fix:
Steps to Reproduce
Expected Behavior
The threadId remains stable across messages within the same conversation, allowing
agents to maintain session state.
Actual Behavior
A new random threadId is sent with every message:
Note: TUI mode (agentcore dev -b) does not have this issue — it uses
aguiThreadIdRef in useDevServer.ts which correctly maintains a stable threadId.
The bug is specific to the browser mode HTTP proxy.
CLI Version
0.21.1
Operating System
Linux
Additional Context
No response