Skip to content

Agents docs: add chat agents, retries, and sync with SDK changes#28378

Merged
threepointone merged 9 commits into
productionfrom
agents-050
Feb 17, 2026
Merged

Agents docs: add chat agents, retries, and sync with SDK changes#28378
threepointone merged 9 commits into
productionfrom
agents-050

Conversation

@threepointone

@threepointone threepointone commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Major update to the Agents SDK documentation, syncing with changes from the agents repo through 0.4.1 and upcoming unreleased features.

New pages

  • api-reference/chat-agents.mdx — Full API reference for AIChatAgent and useAgentChat from @cloudflare/ai-chat. Covers server API, client API, three tool patterns (server-side, client-side, approval), resumable streaming, storage management, multiple AI providers, and advanced patterns (prepareStep, middleware, subagent delegation). Also includes a deprecated APIs table.
  • api-reference/retries.mdx — Reference for this.retry() with exponential backoff and jitter, per-task retry options for queue()/schedule()/scheduleEvery(), class-level defaults, MCP server retries, and common patterns.
  • api-reference/protocol-messages.mdx — Reference for shouldSendProtocolMessages() and isConnectionProtocolEnabled(). Covers per-connection suppression of protocol text frames (identity, state, MCP servers) for binary-only clients like MQTT devices. Includes API reference, examples (query param, WebSocket subprotocol, combining with readonly), and how-it-works section. Corresponds to cloudflare/agents#920.

Rewritten pages

  • getting-started/build-a-chat-agent.mdx — Complete rewrite as a proper Diátaxis tutorial. Now uses Workers AI (no API key needed), modern @cloudflare/ai-chat imports, demonstrates all three tool patterns, and includes both server and client code the reader writes themselves. Replaces the old starter-template walkthrough.

Updated pages

  • api-reference/websockets.mdx — Added lifecycle hooks table, onStart hook documentation, connection tags with getConnectionTags(), hibernation section (what persists, how to disable), common patterns (presence tracking, chat room), and a note in "Handling binary data" linking to protocol messages for binary-only clients.
  • api-reference/mcp-client-api.mdx — Added createMcpOAuthProvider() section for custom OAuth providers, retry option to addMcpServer() API reference, and a note that MCP server list broadcasts respect the protocol messages filter.
  • api-reference/schedule-tasks.mdx — Updated scheduleSchema to discriminated union shape with ISO 8601 string dates. Updated getSchedule()/getSchedules() signatures from async to synchronous. Updated comparison table (retries now "Built-in").
  • api-reference/queue-tasks.mdx — Updated dequeue(), dequeueAll(), dequeueAllByCallback(), getQueue(), getQueues() signatures from async to synchronous. Replaced "No built-in retry" limitation with a note pointing to the retries page.
  • api-reference/agents-api.mdx — Added "Protocol messages" row to the server-side API reference table.
  • api-reference/store-and-sync-state.mdx — Clarified that setState() broadcasts exclude connections where shouldSendProtocolMessages returned false.
  • api-reference/readonly-connections.mdx — Added cross-reference to protocol messages in "Related resources" and "How it works" sections.
  • getting-started/add-to-existing-project.mdx — Added @callable() decorators to CounterAgent example (required for agent.stub.increment() calls shown later in the page).

Cross-cutting changes (all agents docs)

  • satisfies ExportedHandler<Env> added to every export default { ... } block across 16 files (35 occurrences). Ensures type safety in all code examples.
  • compatibility_date updated to "$today" across 6 files (7 occurrences). Replaces hardcoded dates like "2025-01-01" and "2026-01-28".

Notes for reviewers

  • The new chat-agents.mdx is ~1,065 lines. It is a Reference page (Diátaxis) covering the full @cloudflare/ai-chat surface. The previous build-a-chat-agent.mdx tutorial was the only chat docs — now there is a proper tutorial and a proper reference.
  • The retries.mdx page documents an unreleased feature (retry-utilities changeset). It should land alongside or after the next agents SDK release.
  • The protocol-messages.mdx page documents shouldSendProtocolMessages / isConnectionProtocolEnabled from cloudflare/agents#920, now merged to main.
  • The sync getter changes (getSchedule, getQueue, etc. dropping async) are also unreleased (sync-getters changeset). The old await usage is backward-compatible, but the signatures are now accurate.
  • The scheduleSchema discriminated union change is unreleased (many-turkeys-sit changeset).
  • createMcpOAuthProvider was shipped in 0.4.0 but never documented.
  • The deprecated APIs table in chat-agents.mdx covers deprecations from the ai-chat-refactor changeset.

Add comprehensive Chat agents and Retries reference pages. Update numerous API examples to use TypeScript "} satisfies ExportedHandler<Env>;" for exported handlers. Change Wrangler compatibility_date to a placeholder "$today". Add MCP client retry options and a custom OAuth provider example. Update queue API docs to mark several methods as synchronous and adjust signatures, and add a note about built-in queue retries. Miscellaneous related doc fixes and clarifications.
@threepointone
threepointone requested a review from a team February 16, 2026 19:51
@threepointone
threepointone requested a review from a team as a code owner February 16, 2026 19:51
@github-actions github-actions Bot added product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/xl labels Feb 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/agents/ @irvinebroque, @rita3ko, @elithrar, @thomasgauvin, @threepointone, @whoiskatrin, @cloudflare/pcx-technical-writing, @cloudflare/ai-agents, @cloudflare/dev-plat-leads

@github-actions

github-actions Bot commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Preview URL: https://008aad79.preview.developers.cloudflare.com
Preview Branch URL: https://agents-050.preview.developers.cloudflare.com

Files with changes (up to 15)

Original Link Updated Link
https://developers.cloudflare.com/agents/api-reference/chat-agents/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/chat-agents/
https://developers.cloudflare.com/agents/api-reference/retries/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/retries/
https://developers.cloudflare.com/agents/getting-started/build-a-chat-agent/ https://agents-050.preview.developers.cloudflare.com/agents/getting-started/build-a-chat-agent/
https://developers.cloudflare.com/agents/api-reference/websockets/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/websockets/
https://developers.cloudflare.com/agents/api-reference/protocol-messages/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/protocol-messages/
https://developers.cloudflare.com/agents/api-reference/mcp-client-api/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/mcp-client-api/
https://developers.cloudflare.com/agents/getting-started/add-to-existing-project/ https://agents-050.preview.developers.cloudflare.com/agents/getting-started/add-to-existing-project/
https://developers.cloudflare.com/agents/api-reference/schedule-tasks/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/schedule-tasks/
https://developers.cloudflare.com/agents/api-reference/queue-tasks/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/queue-tasks/
https://developers.cloudflare.com/agents/api-reference/configuration/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/configuration/
https://developers.cloudflare.com/agents/api-reference/routing/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/routing/
https://developers.cloudflare.com/agents/guides/oauth-mcp-client/ https://agents-050.preview.developers.cloudflare.com/agents/guides/oauth-mcp-client/
https://developers.cloudflare.com/agents/api-reference/mcp-handler-api/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/mcp-handler-api/
https://developers.cloudflare.com/agents/api-reference/using-ai-models/ https://agents-050.preview.developers.cloudflare.com/agents/api-reference/using-ai-models/
https://developers.cloudflare.com/agents/guides/remote-mcp-server/ https://agents-050.preview.developers.cloudflare.com/agents/guides/remote-mcp-server/

Simplify Agent class examples in the agents docs by removing explicit generic type parameters (e.g. <Env>, <Env, never>) from class declarations. Updated multiple MDX files under src/content/docs/agents to match the current Agent API/signature and improve example readability. No runtime or behavioral changes — only documentation/type examples were adjusted.
Replace references to `.dev.vars` with `.env` across Agents documentation and update corresponding command examples (touch/echo/cat) and troubleshooting notes. Files updated: src/content/docs/agents/api-reference/configuration.mdx, src/content/docs/agents/guides/remote-mcp-server.mdx, src/content/docs/agents/guides/slack-agent.mdx, and src/content/docs/agents/index.mdx to standardize local development secrets guidance.
threepointone and others added 2 commits February 16, 2026 21:29
Reword the AIChatAgent lifecycle section to clarify that overriding onConnect/onClose is for adding custom logic while stream resumption, message sync, and connection cleanup are handled automatically. Updated the example comments to remove the implication that calling super is required. Also reformatted the deprecated APIs table for consistent column alignment and readability.
Add new page documenting `shouldSendProtocolMessages` and
`isConnectionProtocolEnabled` for per-connection control of protocol
text frames. Update cross-references in agents-api, websockets,
readonly-connections, store-and-sync-state, and mcp-client-api pages.

Corresponds to cloudflare/agents#920.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/content/docs/agents/api-reference/mcp-client-api.mdx Outdated
Comment thread src/content/docs/agents/api-reference/readonly-connections.mdx Outdated
Comment thread src/content/docs/agents/api-reference/protocol-messages.mdx
Comment thread src/content/docs/agents/api-reference/chat-agents.mdx
Comment thread src/content/docs/agents/api-reference/chat-agents.mdx Outdated
Comment thread src/content/docs/agents/api-reference/retries.mdx Outdated
Comment thread src/content/docs/agents/api-reference/retries.mdx
Oxyjun and others added 2 commits February 17, 2026 09:37
Co-authored-by: threepointone <threepointone@users.noreply.github.com>
@ask-bonk

ask-bonk Bot commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Added an introductory sentence before the table at line 105 explaining what it shows, as requested by the reviewer.

github run

Document data-* stream parts: server-side writer.write() usage,
three patterns (reconciliation, append, transient), typed client
access via UIMessage generics, and onData callback for transient parts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@threepointone
threepointone merged commit 592c5ec into production Feb 17, 2026
9 checks passed
@threepointone
threepointone deleted the agents-050 branch February 17, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/xl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants