Skip to content

Sessions on their own, and @restatedev/ai - #55

Draft
igalshilman wants to merge 3 commits into
restatedev:mainfrom
igalshilman:sessions-and-ai
Draft

igalshilman wants to merge 3 commits into
restatedev:mainfrom
igalshilman:sessions-and-ai

Conversation

@igalshilman

Copy link
Copy Markdown
Collaborator

No description provided.

The high-level agents layer (packages/agents) is taken out of the tree. What
remains is @restatedev/sessions, and a new package, @restatedev/ai: thin
integrations that put a framework's own storage in a session object's
database, and add what a turn needs to survive a crash and to stop on a
cancellation.

- @restatedev/ai has the entries /pi, /langgraph and /opencode. Each has a
  factory (withPi, withLangGraph, withOpenCode) whose closure gets ask,
  messages and the framework's own object, over the pieces it is built from:
  storage, keep-alive, and what stops a turn. OpenCode takes nothing from the
  machine unless `machine` is set, and never its credentials.
- Sessions: ctx.stoppable and ctx.suspendable; one rule for how a handler
  ends after a cancellation; the hooks only the agents layer used are pruned.
- docs/semantics.md specifies attempts, turns, cancellation and suspension as
  rules and assumptions with ids. Every id has a unit test that names it, or
  a stated reason; packages/ai/test/semantics.test.ts checks that. Its
  section 7 lists known limits, open decisions, and rules stated inexactly.
- packages/e2e: `turns` runs the turn semantics against a real Restate server,
  in CI; `real-model` does the same with a model provider, by hand.
- docs/agents is a design record of the removed layer.
- The examples and the template's pi lesson use the factories.
The test support named every attempt's service after its object, so all
attempts of a test file shared one namespace of the process-wide page cache.
A killed attempt, which keeps running in the tests, could fail its last
commit after a later attempt had opened the namespace, and that attempt's
next commit was then refused. The test saw only a wait that never ended.
Each attempt now has a namespace of its own, and a wait that never ends
reports its name before the test's own time limit.
docs/README.md is the map. getting-started.md, concepts.md and sessions/*
cover session objects: the database, retries, calls and sends, long work,
cancellation, views, operations, testing. ai/* covers the integrations: the
layers, pi, LangGraph, OpenCode, turns, tools, known limits. Each page ends
with the rules of docs/semantics.md that decide what it says.

Every TypeScript block is an excerpt of a type-checked file under
packages/examples/docs; packages/examples/docs.test.ts checks that each block
equals its source and that every link resolves.
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