finish event carries an opaque session_id — the provider-managed conversation handle. Thread it back into the next call’s sessionId to continue.
Full example
Swapping providers mid-session
When providers change
session_id is provider-managed. Anthropic’s session IDs are not valid Google session IDs and vice versa. When you cross providers:
- Memory of prior turns comes from the Copass Context Window — always available, regardless of provider.
- Provider-native conversation state (prompt caches, model-side scratchpads) resets at the crossing point. That’s a feature: you’re explicitly changing runtimes.
sessionId when continuing on the same provider; omit or reset it when switching. The agent will still have the full memory of what’s been said because the Context Window lives in the sandbox.
See Portable Context for the underlying reason this works.
The endUserId parameter
endUserId is how Copass ties a session to a human. Required on every run() call. Opaque, URL-safe, ≤128 chars, stable per human. See Multi-tenancy for picking the right value.
Cleaning up
Sessions don’t need explicit teardown — they’re ephemeral data sources that expire. If you want to proactively clear one:Next steps
- Window-Aware Retrieval — what the Context Window actually does between turns.
- Providers — which runtime to route each turn to.
- Events — the full
finishpayload.

