Skip to content

fix(eve): session with first turn in streaming cannot be stored in fr…#385

Open
lchrennew wants to merge 1 commit into
vercel:mainfrom
lchrennew:main
Open

fix(eve): session with first turn in streaming cannot be stored in fr…#385
lchrennew wants to merge 1 commit into
vercel:mainfrom
lchrennew:main

Conversation

@lchrennew

Copy link
Copy Markdown

Description

Cannot get session id during first turn in streaming

How did you test your changes?

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@lchrennew is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@lchrennew

lchrennew commented Jun 28, 2026

Copy link
Copy Markdown
Author

@ruiconti @ijjk

I got a detailed description generated by LLM to express my idea in native English:

Title: Eagerly surface sessionId after POST completes

Description:

Previously, session.state.sessionId was only updated after the full event stream was consumed (in the finally block of #createEventStream ). This meant consumers who needed the session ID early — for example to persist it or display it in the UI — had to reach into MessageResponse.sessionId directly and could not rely on session.state .

This change updates ClientSession.send() to write the session ID into #state immediately after the POST response returns, before the event stream is created. It also adds an early onSessionChange notification in EveAgentStore.send() right after the session POST resolves, so framework integrations (Vue, React) can react to the new session ID before any stream events arrive.

Changes:

- packages/eve/src/client/session.ts : Eagerly assign sessionId to #state after #postTurn resolves.
- packages/eve/src/client/eve-agent-store.ts : Fire onSessionChange and #publish() immediately after session.send() returns, before iterating the event stream.
- packages/eve/src/client/session.test.ts : Added test verifying state.sessionId is available right after send() resolves.
- packages/eve/src/vue/use-eve-agent.test.ts : Updated onSessionChange expectations — now fires twice per turn (once after POST with initial sessionId, once after stream completes with final cursor).
Behavior:

onSessionChange now fires at two points during a turn:

1. After POST completes — sessionId is set, streamIndex is still 0
2. After stream consumption — continuationToken and streamIndex are finalized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant