Version Packages#1140
Merged
Merged
Conversation
0a4ddc9 to
6d0a063
Compare
6d0a063 to
cc83085
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
agents@0.8.0
Minor Changes
#1152
16cc622Thanks @threepointone! - feat: expose readablestateproperty onuseAgentandAgentClientBoth
useAgent(React) andAgentClient(vanilla JS) now expose astateproperty that tracks the current agent state. Previously, state was write-only viasetState()— reading state required manually tracking it through theonStateUpdatecallback.React (useAgent)
agent.stateis reactive — the component re-renders when state changes from either the server or client-sidesetState().Vanilla JS (AgentClient)
Backward compatible
The
onStateUpdatecallback continues to work exactly as before. The newstateproperty is additive — it provides a simpler alternative to manual state tracking for the common case.Type:
State | undefinedState starts as
undefinedand is populated when the server sends state on connect (frominitialState) or whensetState()is called. Use optional chaining (agent.state?.field) for safe access.#1154
74a018aThanks @threepointone! - feat: idempotentschedule()to prevent row accumulation across DO restartsschedule()now supports anidempotentoption that deduplicates by(type, callback, payload), preventing duplicate rows from accumulating when called repeatedly (e.g., inonStart()).Cron schedules are idempotent by default. Calling
schedule("0 * * * *", "tick")multiple times with the same callback, cron expression, and payload returns the existing schedule instead of creating a duplicate. Set{ idempotent: false }to override.Delayed and scheduled (Date) types support opt-in idempotency:
New warnings for common foot-guns:
schedule()called insideonStart()without{ idempotent: true }now emits aconsole.warnwith actionable guidance (once per callback, skipped for cron and whenidempotentis explicitly set)alarm()processing ≥10 stale one-shot rows for the same callback emits aconsole.warnand aschedule:duplicate_warningdiagnostics channel event#1146
b74e108Thanks @threepointone! - feat: strongly-typedAgentClientwithcallinference andstubproxyAgentClientnow accepts an optional agent type parameter for full type inference on RPC calls, matching the typed experience thatuseAgentalready provides.New: typed
callandstubWhen an agent type is provided,
call()infers method names, argument types, and return types from the agent's methods. A newstubproperty provides a direct RPC-style proxy — call agent methods as if they were local functions:State is automatically inferred from the agent type, so
onStateUpdateis also typed:Backward compatible
Existing untyped usage continues to work without changes:
The previous
AgentClient<State>pattern is preserved —new AgentClient<{ count: number }>({...})still correctly typesonStateUpdateand leavescall/stubuntyped.Breaking:
callis now an instance property instead of a prototype methodAgentClient.prototype.callno longer exists. Thecallfunction is assigned per-instance in the constructor (via.bind()). This is required for the conditional type system to switch between typed and untyped signatures. Normal usage (client.call(...)) is unaffected, but code that reflects on the prototype or subclasses that overridecallas a method may need adjustment.Shared type utilities
The RPC type utilities (
AgentMethods,AgentStub,RPCMethods, etc.) are now exported fromagents/clientso they can be shared betweenAgentClientanduseAgent, and are available to consumers who need them for advanced typing scenarios.#1138
36e2020Thanks @threepointone! - Drop Zod v3 from peer dependency range — now requireszod ^4.0.0. Replace dynamicimport("ai")withz.fromJSONSchema()from Zod 4 for MCP tool schema conversion, removing theairuntime dependency from the agents core. RemoveensureJsonSchema().Patch Changes
#1147
1f85b06Thanks @threepointone! - Replace schedule-based keepAlive with lightweight ref-counted alarmskeepAlive()no longer creates schedule rows or emitsschedule:create/schedule:execute/schedule:cancelobservability events — it uses an in-memory ref count and feeds directly into_scheduleNextAlarm()keepAlive()callers now share a single alarm cycle instead of each creating their own interval schedule row_onAlarmHousekeeping()hook (called on every alarm cycle) for extensions like the fiber mixin to run housekeeping without coupling to the scheduling system_cf_keepAliveHeartbeatschedule rows from the previous implementation@experimentalfromkeepAlive()andkeepAliveWhile()@cloudflare/ai-chat@0.2.0
Minor Changes
#1150
81a8710Thanks @threepointone! - feat: addsanitizeMessageForPersistencehook and built-in Anthropic tool payload truncationsanitizeMessageForPersistence(message)— override this method to apply custom transformations to messages before they are persisted to storage. Runs after built-in sanitization. Default is identity (returns message unchanged).inputandoutputof provider-executed tool parts (e.g. Anthropiccode_execution,text_editor) are now automatically truncated. These server-side tool payloads can exceed 200KB and are dead weight once the model has consumed the result.Closes #1118
#1138
36e2020Thanks @threepointone! - Drop Zod v3 from peer dependency range — now requireszod ^4.0.0. Replace dynamicimport("ai")withz.fromJSONSchema()from Zod 4 for MCP tool schema conversion, removing theairuntime dependency from the agents core. RemoveensureJsonSchema().Patch Changes
#1151
b0c52a5Thanks @whoiskatrin! - fix(ai-chat): simplify turn coordination APIwaitForPendingInteractionResolution()towaitUntilStable()and make it wait for a fully stable conversation state, including queued continuation turnsresetTurnState()for scoped clear handlers that need to abort active work and invalidate queued continuationsisChatTurnActive(),waitForIdle(), andabortActiveTurn()to private — their behavior is subsumed bywaitUntilStable()andresetTurnState()#1106
3184282Thanks @threepointone! - fix: abort/stop no longer creates duplicate split messages (issue #1100)When a user clicked stop during an active stream, the assistant message was split into two separate messages. This happened because
onAbortin the transport immediately removed therequestIdfromactiveRequestIds, causingonAgentMessageto treat in-flight server chunks as a new broadcast.WebSocketChatTransport:onAbortnow keeps therequestIdinactiveRequestIdsso in-flight server chunks are correctly skipped by the dedup guarduseAgentChat:onAgentMessagenow cleans up the kept ID when receivingdone: true, preventing a minor memory leak#1142
5651eceThanks @whoiskatrin! - fix(ai-chat): serialize chat turns and expose turn control helpersonChatMessage()+_reply()work so user requests, tool continuations, andsaveMessages()never stream concurrentlysaveMessages()wait for the queued turn to finish before resolving, and reuse the request id for reply cleanupsaveMessages()calls that were enqueued before a chat clearsaveMessages()context (_lastClientTools,_lastBody) at enqueue time so a later request cannot overwrite it before executionisChatTurnActive(),waitForIdle(),abortActiveTurn(),hasPendingInteraction(), andwaitForPendingInteractionResolution()helpers for subclass code that needs to coordinate active turns and pending tool interactions#1096
0d0b7d3Thanks @threepointone! - fix(ai-chat): prevent duplicate messages after tool calls and orphaned client IDs@cloudflare/codemode@0.3.0
Minor Changes
36e2020Thanks @threepointone! - Drop Zod v3 from peer dependency range — now requireszod ^4.0.0. Replace dynamicimport("ai")withz.fromJSONSchema()from Zod 4 for MCP tool schema conversion, removing theairuntime dependency from the agents core. RemoveensureJsonSchema().Patch Changes
#1149
47ce125Thanks @threepointone! - feat: add TanStack AI integration (@cloudflare/codemode/tanstack-ai)New entry point for using codemode with TanStack AI's
chat()instead of the Vercel AI SDK'sstreamText().Exports:
createCodeTool— returns a TanStack AIServerTool(viatoolDefinition().server())tanstackTools— converts aTanStackTool[]into aToolProviderwith pre-generated typesgenerateTypes— generates TypeScript type definitions from TanStack AI toolsresolveProvider— re-exported framework-agnostic provider resolverInternal cleanup: extracted
resolveProviderinto a framework-agnosticresolve.tsmodule so the main entry (@cloudflare/codemode) no longer pulls in theaipackage at runtime. Shared constants and helpers moved toshared.tsto avoid duplication between the AI SDK and TanStack AI entry points.@cloudflare/think@0.1.0
Minor Changes
36e2020Thanks @threepointone! - Drop Zod v3 from peer dependency range — now requireszod ^4.0.0. Replace dynamicimport("ai")withz.fromJSONSchema()from Zod 4 for MCP tool schema conversion, removing theairuntime dependency from the agents core. RemoveensureJsonSchema().@cloudflare/worker-bundler@0.0.4
Patch Changes
94fac05Thanks @threepointone! - Separate assets from isolate:createAppnow returns assets for host-side serving instead of embedding them in the dynamic isolate. Removes DO wrapper code generation anddurableObjectoption — mounting is the caller's concern. Preview proxy replaced with Service Worker-based URL rewriting.