The idea
A session is stablebrowse’s unit of conversation. It’s a sequence of tasks (“turns”) where each turn gets the prior turn’s result as context. Analogous to an OpenAI thread, an Anthropic conversation, or a chat-window history.Server mints the ID, you pass it back
Don’t generatesessionId on your side. Just omit it on the first call — the server returns a UUID. Include that UUID on subsequent calls to continue the conversation.
What actually flows across turns
Under the hood each turn is a fresh agent run — the browser is not persistent. What IS preserved:previousContext— the last completed turn’sresultis injected into the new turn’s system prompt (capped at 8 KB to keep the context window manageable). The agent “knows” what was answered before.previousError— if any prior turn in the session hadstatus: "failed", the error messages are passed forward so the agent doesn’t retry the same broken approach.- End-user credentials — same end-user, so Twitter/etc cookies carry through.
New conversation vs. follow-up
| Intent | What to send |
|---|---|
| Start a new conversation | sessionId omitted — server mints a new one |
| Continue an existing one | Pass the previous turn’s sessionId |
| Start over with the same end-user | Omit sessionId again. The old session is orphaned but not deleted (you can still GET /v1/sessions/{old-id} to browse it). |
Parallel sessions per end-user
An end-user can have N sessions open simultaneously. Alice’s “sports news” conversation and her “recipe research” conversation are separatesessionIds and won’t contaminate each other. Your app keeps track of which sessionId is “the current chat window” for each UI; stablebrowse doesn’t need to know.
Inspecting a session
- Rebuilding UI state after a reload
- Support / audit (“what did my customer ask yesterday?”)
- Showing your users their own conversation history
Concurrency note
If you fire two follow-ups in the same session before the first completes, both will use the samepreviousContext (the latest completed turn at the time each one lands). The in-flight turn is not seen by the later one. This is rarely a problem in practice — serialize on your side if you need strict ordering.