fix(dev): use stable sessionId as AGUI threadId for session persistence#1687
Closed
C0d3N1nja97342 wants to merge 1 commit into
Closed
fix(dev): use stable sessionId as AGUI threadId for session persistence#1687C0d3N1nja97342 wants to merge 1 commit into
C0d3N1nja97342 wants to merge 1 commit into
Conversation
handleAguiInvocation regenerated a random threadId on every browser-mode message, so AGUI agents could not keep multi-turn state (e.g. AgentCore Memory STM) across a chat. The per-chat sessionId was already in scope, stable for the session, and returned as the x-session-id response header — reuse it as the threadId, falling back to a UUID only when no sessionId is present. Mirrors the deployed path, which builds RunAgentInput via buildAguiRunInput(prompt, sessionId). Adds a regression test that mocks the proxied AGUI request and asserts the threadId matches the sessionId across two messages (and that the UUID fallback still yields a valid threadId).
Contributor
|
Claude Security Review: no high-confidence findings. (run) |
Contributor
|
Hi @C0d3N1nja97342 , closing out this PR in favor of #1686 which addresses the same concern. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In browser mode (
agentcore devwithout-b),handleAguiInvocationbuilt the AGUIRunAgentInputwiththreadId: randomUUID()on every message, so each message in a chat got a brand-new thread. AGUI agents could not keep multi-turn session state (e.g. AgentCore Memory STM) across a conversation.The per-chat
sessionIdwas already in scope (assigned inhandleInvocations, returned as thex-session-idresponse header) but was never used as thethreadId. This change reuses it, falling back torandomUUID()only when nosessionIdis present.This mirrors the deployed path, which already builds the input via
buildAguiRunInput(prompt, sessionId)— so local dev and deployed behaviour now agree. The TUI path (agentcore dev -b) was already correct viaaguiThreadIdRef; the bug was specific to the browser-mode HTTP proxy.Related Issue
Closes #1678
Type of Change
Testing
npm run typecheck— cleannpm run lint— clean (only pre-existingsecurity/detect-unsafe-regexwarnings, unrelated to this change)npm run test:unitandnpm run test:integ— rantest:unit; theweb-uisuite that covers this change passes 78/78 on Linux. The remaining unit failures are pre-existing, environment-dependent tests (python/docker subprocesses, etc.) that also fail on themainbaseline and are unrelated to this change.test:integwas not run (requires AWS credentials).src/assets/, I rannpm run test:update-snapshotsand committed the updated snapshots — N/AAdded a regression test (
agui-invocation.test.ts) that mocks the proxied AGUI request, sends two messages with the samesessionId, and asserts both bodies carry thatsessionIdasthreadId(verified to fail against the pre-fix code). Also covers therandomUUID()fallback when nosessionIdis supplied.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.