Skip to main content

Signed-out Session lifecycle

Signed-out Session lifecycle — loading the slides…

A signed-out Session gives the company a stable, pairwise context before the user shares account identity. The Session can support public questions and a conversation that later continues through sign-in. A Session is local: SessionClient.start makes a PapSession with a random sid and asks the company nothing. The company meets the Session on its first request, and the Poppy-Session header of every request names it.

What the example proves​

  • Starting a Session sends no request. The Session is signed out until a request carries an access token.
  • Every request carries a new Session JWT, with a new jti, for the same sid.
  • session_ended means the company ended the Session (§5.5). The client starts a new Session once, with a new sid, and sends the request again in it.
  • A second session_ended stops there: the refusal goes to the caller.
  • invalid_session means the header failed a check (§5.3): a new Session would fail the same way, so the refusal goes to the caller at once, to fix its cause.
  • The User ID and the delegated key stay the same across a restart.
  • Session IDs, pairwise subjects, Session JWTs, delegations, and keys stay inside host-owned code and protected storage.
  • The model sees only lifecycle status and safe invariants.

To end a Session without signing out, the agent stops using its sid. Its refresh tokens are unaffected.

The deterministic company transport answers session_ended on chosen requests, so the restart path is always exercised. Production code uses the same SessionClient and SessionHttpClient with real HTTPS and managed Reactor contributions.

Run the Pydantic AI example or the Agent Runtimes example. Continue with the complete Direct Sign-In lifecycle.