feat(http): support persistent sessions via X-GoClaw-User-Id header#713
Open
olbboy wants to merge 1 commit intonextlevelbuilder:mainfrom
Open
feat(http): support persistent sessions via X-GoClaw-User-Id header#713olbboy wants to merge 1 commit intonextlevelbuilder:mainfrom
olbboy wants to merge 1 commit intonextlevelbuilder:mainfrom
Conversation
When X-GoClaw-User-Id header is provided, build a stable session key
using BuildSessionKey() — same canonical format as Telegram, Discord,
Slack channels. This allows HTTP API clients to maintain conversation
history across multiple requests.
Without the header, behavior is unchanged (random session per request).
Session key format:
With userId: agent:{id}:http:direct:{userId} (persistent)
Without: agent:{id}:http-{random} (stateless)
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.
Summary
HTTP
/v1/chat/completionsendpoint now supports persistent sessions whenX-GoClaw-User-Idheader is provided. Without the header, behavior is unchanged (stateless, random session per request).Problem
Every HTTP API request creates a new session (random UUID in session key), even when the same user sends multiple messages. The agent always responds as if it was a new conversation — no memory of previous messages.
Root cause: Session key includes
runID[:8](random UUID per request):This is the only channel without persistent sessions — Telegram, Discord, Slack, Zalo all use stable session keys.
Solution
When
X-GoClaw-User-Idis present, build a stable session key using the canonicalBuildSessionKey()— same pattern as all other channels:Impact
X-GoClaw-User-Idheader → behavior unchangedhttp:direct:prefix is unique among all channelsTest Plan
X-GoClaw-User-Id: user1→ send "I'm Alice" → send "What's my name?" → agent remembersUse Case
Enables integration with Microsoft Teams (and any HTTP client) where a bridge bot sends
X-GoClaw-User-Idheader with the Teams user ID, maintaining conversation history across messages.