Skip to main content
What this builds. A standalone Session(session_id=...) reconnection that sends a follow-up message and streams the reply. You’ll end up with. Confirmation that the session resumed and a streamed answer continuing the prior conversation. Demonstrates resuming an existing session using just the session_id. No agent or chatbot object needed — just the session ID and a message.
import asyncio

from vectorshift.session import Session
from vectorshift.events import SessionEventType

SESSION_ID = "69de3cbd9b196c7bf0a75f20"


async def main() -> None:
    session = Session(session_id=SESSION_ID)
    async with session:
        print(f"Resumed session: {session.session_id}")

        await session.send("Pick up where we left off — what were we discussing?")

        async for event in session.listen(
            event_types=[
                SessionEventType.MESSAGE_DELTA,
                SessionEventType.MESSAGE_COMPLETE,
            ]
        ):
            if event.delta:
                print(event.delta, end="", flush=True)
            if event.is_complete:
                break

    print("\nDone.")


if __name__ == "__main__":
    asyncio.run(main())

Expected output

Resumed session: 69de3cbd9b196c7bf0a75f20
We were discussing ...
Done.
The session id is a hard-coded literal here — in real code you’d persist session.session_id from a prior run (or from agent.run(..., keep_alive=True).session_id) and feed it back in.
See Session overview for connection lifecycle and event semantics.

See also

Conversational agent run

Where keep_alive=True produces a resumable session_id.

Terminating a session

Once terminated, resume fails — see what that looks like.

Session reference

Session(session_id=...) and connection helpers.