Skip to content

Version Packages#1828

Merged
threepointone merged 1 commit into
mainfrom
changeset-release/main
Jun 30, 2026
Merged

Version Packages#1828
threepointone merged 1 commit into
mainfrom
changeset-release/main

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

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

@cloudflare/think@0.12.0

Minor Changes

  • #1832 51ec433 Thanks @threepointone! - getModel() now accepts a model id string, resolved through a built-in workers-ai-provider instance — no separate provider package to install, import, or wire up for the common case.

    Think now depends on workers-ai-provider (plus the @ai-sdk/openai and @ai-sdk/anthropic wire-format plugins) directly. When getModel() returns a string, Think resolves it off your AI binding:

    • A @cf/... id hits Workers AI directly (with sessionAffinity wired in automatically for prefix-cache hits).
    • Any other "<provider>/<model>" slug — e.g. "openai/gpt-5.5", "anthropic/claude-sonnet-4-5", "google/gemini-2.5-pro", "xai/grok-4", "groq/..." — is routed through AI Gateway.
    export class MyAgent extends Think<Env> {
      getModel() {
        return "@cf/moonshotai/kimi-k2.7-code"; // or "openai/gpt-5.5"
      }
    }

    Returning a fully-constructed AI SDK LanguageModel from getModel() still works unchanged for any other provider or for full control over provider/gateway options. A new getAIBinding() override (default this.env.AI) controls which binding the string resolver uses.

    Because getModel() may now return a bare string, a new public resolveModel(model?) method (defaults to resolving getModel()) returns a concrete LanguageModel. Use it for side inference calls — e.g. summarization/compaction generateText — instead of passing getModel() straight to the AI SDK.

    The per-turn override TurnConfig.model (returned from beforeTurn) also accepts a ThinkModel now, so you can switch models for a turn with a plain string (e.g. a cheaper model for continuations). The per-step override StepConfig.model (returned from beforeStep) accepts a ThinkModel too — Think resolves a string back into a LanguageModel before handing the step to the AI SDK.

    getModel() is typed to return ThinkModel (a newly exported alias for LanguageModel | ThinkModelId). ThinkModelId (also exported) gives editor autocomplete for the Workers AI text-generation catalog (@cf/..., derived from the installed @cloudflare/workers-types) while still accepting any string — gateway catalog slugs like "openai/gpt-5.5" are validated at runtime, since the catalog lives server-side and is not knowable from types.

Patch Changes

  • #1827 e5e6b57 Thanks @threepointone! - Fix sub-agent tool events getting stuck at input-available when an agent-tool child proxies a remote toUIMessageStreamResponse() (#1589).

    tailAgentToolRun (in both AIChatAgent and Think) drained the stored chunk backlog and only afterwards attached its live forwarder, with await boundaries in between. Any chunk the child stored and broadcast in that window was neither in the drained snapshot nor live-forwarded, so it silently vanished from the parent's stream — leaving tool parts (notably tool-output-available) stuck at input-available in useAgentToolEvents. A network-paced proxied remote stream hits this window constantly, while a fast local child mostly avoids it. The forwarder is now registered before the backlog is drained, with live chunks buffered and replayed in order and deduped by sequence, closing the gap.

    Both AIChatAgent and Think also realign the in-memory live sequence to the stored high-water mark after draining. Without this, a re-attach after the child's Durable Object restarts or wakes from hibernation (where the live counter is cold but the durable backlog sits at N) would hand the recovered turn's new chunks sequences from 0, which the high-water dedupe silently drops — leaving the parent permanently stuck with no post-restart chunks.

agents@0.17.2

Patch Changes

  • #1836 0544aa2 Thanks @threepointone! - Fix useAgentToolEvents doubling streamed text in React StrictMode / SSR frameworks (#1835).

    The agent-tool-event reducer (applyAgentToolEventapplyToRun) shallow-copied a run's parts array with [...seeded.parts] and then handed it to applyChunkToParts, which mutates part objects in place (e.g. lastTextPart.text += delta). Because the copied array still shared its element references with the previous state, those in-place mutations leaked back into prev. React double-invokes setState updaters in StrictMode and during dev hydration, so each text-delta chunk was applied twice against the same already-mutated prev, doubling every word. Affected Next.js, TanStack Start, Remix, and any <React.StrictMode> app. The reducer now clones each part before mutating, keeping it pure.

  • #1838 cc21f09 Thanks @threepointone! - Fix reconnect-driven resume overlap throwing Cannot read properties of undefined (reading 'state') in useAgentChat (#1837).

    With resume: true (the default), the hook re-probes the stream from its WebSocket onAgentOpen handler on every reconnect. The AI SDK's Chat.makeRequest has no concurrency guard — every resume shares the single mutable this.activeResponse, and its finally finalizer reads this.activeResponse.state.message with a bare (unguarded) read before clearing it. Under a reconnect storm (flaky mobile link, or a Durable Object bounce on redeploy), a second resume could overwrite + clear activeResponse before an earlier resume's finalizer ran, so the earlier finalizer read undefined and threw. The old guard didn't close the window: isAwaitingResume() only covers the handshake (it flips false the instant STREAM_RESUMING resolves, before the AI SDK sets status to submitted in a later microtask) and statusRef is lagging React state. Resumes are now serialized via an in-flight flag, so a re-probe resumeStream() is never issued while one is still outstanding.

@cloudflare/ai-chat@0.9.2

Patch Changes

  • #1827 e5e6b57 Thanks @threepointone! - Fix sub-agent tool events getting stuck at input-available when an agent-tool child proxies a remote toUIMessageStreamResponse() (#1589).

    tailAgentToolRun (in both AIChatAgent and Think) drained the stored chunk backlog and only afterwards attached its live forwarder, with await boundaries in between. Any chunk the child stored and broadcast in that window was neither in the drained snapshot nor live-forwarded, so it silently vanished from the parent's stream — leaving tool parts (notably tool-output-available) stuck at input-available in useAgentToolEvents. A network-paced proxied remote stream hits this window constantly, while a fast local child mostly avoids it. The forwarder is now registered before the backlog is drained, with live chunks buffered and replayed in order and deduped by sequence, closing the gap.

    Both AIChatAgent and Think also realign the in-memory live sequence to the stored high-water mark after draining. Without this, a re-attach after the child's Durable Object restarts or wakes from hibernation (where the live counter is cold but the durable backlog sits at N) would hand the recovered turn's new chunks sequences from 0, which the high-water dedupe silently drops — leaving the parent permanently stuck with no post-restart chunks.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@github-actions github-actions Bot force-pushed the changeset-release/main branch 5 times, most recently from 8c3dc0a to e8bef13 Compare June 29, 2026 18:37
@github-actions github-actions Bot force-pushed the changeset-release/main branch from e8bef13 to 28bb53b Compare June 29, 2026 20:59
@threepointone threepointone merged commit 27bb642 into main Jun 30, 2026
@threepointone threepointone deleted the changeset-release/main branch June 30, 2026 13:10
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