跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
设计与 UI

agents-sdk

Build or debug stateful applications that specifically use Cloudflare's `agents` package, including Agent classes, routing, callable methods, synchronized state, scheduling, AIChatAgent, durable execution, or Agents SDK client hooks. Do not trigger for generic AI-agent design, the OpenAI Agents SDK, or ordinary Durable Object work that does not use the Cloudflare Agents SDK.

swyxio · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add swyxio/skills --skill agents-sdk

技能说明


name: agents-sdk description: Build or debug stateful applications that specifically use Cloudflare's agents package, including Agent classes, routing, callable methods, synchronized state, scheduling, AIChatAgent, durable execution, or Agents SDK client hooks. Do not trigger for generic AI-agent design, the OpenAI Agents SDK, or ordinary Durable Object work that does not use the Cloudflare Agents SDK.

Cloudflare Agents SDK

Use current Cloudflare documentation and the installed agents package as the contract. APIs in this SDK evolve quickly; do not trust remembered signatures or examples without checking the relevant version.

Inspect first

  1. Read the project's package version, Wrangler configuration, Agent exports, routing entrypoint, and generated binding types.
  2. Retrieve the current docs for the feature being changed.
  3. Inspect installed exports and .d.ts files before adding casts or adapters.
  4. Identify the Agent instance name and who is authorized to select it. Instance naming is a state-partition and access-control decision, not just a URL detail.

Agents require Durable Objects. Verify the exact class export, binding, and lifecycle declaration used by the target environment. Do not copy a migration or configuration example without checking the current lifecycle model.

Preserve the runtime contract

  • Treat persisted Agent state, connection state, scheduled work, and client UI state as separate surfaces.
  • Validate client-originated state and callable methods at the server boundary; a callable method is not authorization by itself.
  • Use stable operation identities for work that may be retried or resumed.
  • Distinguish ordinary request work from SDK durable-execution primitives. Use the latter only when work must survive Durable Object eviction or restart.
  • Expect the Agent constructor and in-memory state to be recreated. Persist anything required after eviction.
  • Keep routing and client naming consistent. Test the actual route through routeAgentRequest or the project's custom router.
  • Treat experimental integrations as version-specific. Pin and test the seam rather than spreading preview types through domain code.

Load only the relevant reference

NeedReference
State, SQL, schedules, or alarmsstate-scheduling.md
Callable RPC, streaming, or timeoutscallable.md
Routing, bindings, or project setuprouting.md, configuration.md
React/browser clients or chat streamingclient-sdk.md, streaming-chat.md
Server-driven turns or approval flowsserver-driven-messages.md, human-in-the-loop.md
Workflows, fibers, queues, or retriesworkflows.md, durable-execution.md, queue-retries.md
MCP, email, webhooks, push, or observabilitymcp.md, email.md, webhooks-push.md, observability.md
Preview featuresthink.md, voice.md, codemode.md, browse-the-web.md

Read current first-party docs before relying on limits, package names, configuration fields, or experimental availability.

Verify proportionally

Run the narrow type, route, and state tests for the changed seam. For connection or recovery behavior, test disconnect/reconnect and a recreated Agent instance. For scheduled or durable work, prove that duplicate delivery converges and that the persisted result—not an in-memory flag—defines completion.