PackagesAgent
Upgrading between alphas
The breaking changes you are most likely to hit when you move an app from an earlier 2.0 alpha to the current one, and where to find the rest.
Alpha:
@statelyai/agent2.0 is in alpha. APIs can change between releases; pin an exact version. Feedback: github.com/statelyai/agent.
This page lists the breaking changes an app on an earlier 2.0 alpha is most likely to hit. Every release's full notes are in CHANGELOG.md, which ships in the package: node_modules/@statelyai/agent/CHANGELOG.md.
Peer versions
- XState: exactly the version in the package's
peerDependencies(6.0.0-beta.0today). Upgrade it in the same change as the agent package. - AI SDK:
ai7.0.128 or newer for@statelyai/agent/ai-sdk, which importsexperimental_decide. An olderaifails at import time withdoes not provide an export named 'experimental_decide'. Adapter SDKs are optional peers with no version range, so npm installs the core next to anyai,openai,@tanstack/ai, orajv. - Ajv:
ajv8.20.0 or newer for@statelyai/agent/validate, which importsajv/dist/2020.js. Ajv 6 installs, then fails when that subpath is imported.
Removed and moved APIs
| Was | Now |
|---|---|
defineModels({ ... }) | A plain models map, passed to setupAgent({ models }) and to createAiSdkExecutors({ models }). Pass executors to runAgent explicitly. |
createScriptedExecutors | Removed; the package ships no model mock. Write plain executors that return { result }, or use the AI SDK's MockLanguageModelV3 behind createAiSdkExecutors. |
assertAgentMachine, lintAgentMachine, simulateAgent, explorePaths, canReach from @statelyai/agent | The same names from @statelyai/agent/testing. assertAgentMachine(machine) is also lintAgentMachine(machine, { throw: true }). |
replay, initEntry, createReplayEntry, getUsageFromEvents, the stores from @statelyai/agent | The same names from @statelyai/agent/log. |
setupAgent({ isIdle }), idleTags | Removed. A run settles idle when the machine waits on an event; isAgentIdle(snapshot) tells a human wait from a stuck machine. |
Changed shapes
- Text request output. A request invoke's
onDoneoutput is{ result, messages }: readoutput.result.field, notoutput.field. Executors return{ result, messages?, usage? }, not{ output }. - Schemas. Every schema must be a Standard Schema.
setupAgentthrowsinvalid-schemafor one that is not, such as a zod 3.23 schema. - Undefined fields. Object fields set to
undefinedin input and events are dropped before they are logged, asJSON.stringifydrops them, so JSON-sanitizing written only for them can go. Other non-JSON values still fail a run that has astore. - Exploration types. Type
payloads,dedupeBy, andcanReachpredicate callbacks withExploreSnapshot(and the target withCanReachTarget) from@statelyai/agent/testing, not with your ownxstate'sAnyMachineSnapshot. - Requests. A
requestsentry needs apromptormessages.setupAgentthrowsinvalid-requestfor one with neither, even when the executor builds its own model call.
Checking an upgrade
- Run the type checker first: most of the changes above are type errors.
- Search
CHANGELOG.mdbetween your old version's heading and the new one for Breaking and Removed.