跳转到主要内容

章节Cloudflare 开发者文档(免费档)

Agents

147 页更新于 1 天前

开始阅读

本章内容147

  1. 01 Build Agents on Cloudflare import { RelatedProduct, Render } from " /components"; import AgentsPlatformDiagram from "/components/cf/Ag... 1 天前
  2. 02 Agents as tools import { TypeScriptExample, LinkCard } from "~/components"; Agents as tools let one chat agent dispatch ano... 1 天前
  3. 03 Callable methods import { TypeScriptExample, LinkCard } from "~/components"; Callable methods let your frontend call methods... 1 天前
  4. 04 Durable execution with fibers Run work that survives Durable Object eviction. runFiber() registers a task in SQLite, keeps the agent ali... 1 天前
  5. 05 Agent class import { Render, LinkCard } from "~/components"; This page provides an overview of the Agents SDK. For deta... 1 天前
  6. 06 Agent class internals The core of the agents library is the Agent class. You extend it, override a few methods, and get state m... 1 天前
  7. 07 Protocol messages import { TypeScriptExample, LinkCard } from "~/components"; When a client connects, an Agent sends it JSON ... 1 天前
  8. 08 Queue tasks import { TypeScriptExample, LinkCard } from "~/components"; The Agents SDK provides a built-in queue system... 1 天前
  9. 09 Readonly connections import { TypeScriptExample, LinkCard } from "~/components"; A readonly connection receives state updates bu... 1 天前
  10. 10 Retries import { TypeScriptExample, LinkCard } from "~/components"; Retry failed operations with exponential backof... 1 天前
  11. 11 Routing import { TypeScriptExample, LinkCard } from "~/components"; Agents use the same routing as any Durable Obje... 1 天前
  12. 12 Run Workflows import { TypeScriptExample, WranglerConfig, LinkCard } from "~/components"; Integrate Cloudflare Workflows ... 1 天前
  13. 13 Schedule tasks import { TypeScriptExample, LinkCard } from "~/components"; The Agent class installs the Scheduler capabi... 1 天前
  14. 14 Store and sync state import { TypeScriptExample, LinkCard } from "~/components"; The Agent class installs the State capability... 1 天前
  15. 15 Sub-agents import { TypeScriptExample, WranglerConfig, LinkCard } from "~/components"; Spawn child agents as co-locate... 1 天前
  16. 16 WebSockets import { TypeScriptExample, LinkCard } from "~/components"; The Agent class installs the WebSockets capab... 1 天前
  17. 17 Chat SDK import { LinkCard, PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; Use agents/c... 1 天前
  18. 18 Email import { LinkCard, TypeScriptExample, WranglerConfig } from "~/components"; Email is a communication channe... 1 天前
  19. 19 Communication channels import { DirectoryListing } from "~/components"; Communication channels define how agents communicate with ... 1 天前
  20. 20 Slack import { LinkCard } from "~/components"; Slack is a communication channel for agents that need to participa... 1 天前
  21. 21 Voice import { CardGrid, InlineBadge, LinkCard, TypeScriptExample, WranglerConfig, PackageManagers, } from "~/com... 1 天前
  22. 22 Autonomous responses import { TypeScriptExample, LinkCard } from "~/components"; Send messages and trigger LLM responses from th... 1 天前
  23. 23 Chat agents import { TypeScriptExample, LinkCard, PackageManagers, } from "~/components"; Build AI-powered chat interfa... 1 天前
  24. 24 Client SDK import { TypeScriptExample, LinkCard } from "~/components"; Connect to agents from any JavaScript runtime —... 1 天前
  25. 25 Chat import { DirectoryListing } from "~/components"; 1 天前
  26. 26 Webhooks import { TypeScriptExample, LinkCard } from "~/components"; Receive webhook events from external services a... 1 天前
  27. 27 Push notifications import { TypeScriptExample, LinkCard } from "~/components"; Send browser push notifications from your agent... 1 天前
  28. 28 Agent Skills Agent Skills are an open format for giving an agent specialized knowledge and repeatable workflows. A skill... 1 天前
  29. 29 Calling LLMs import { TypeScriptExample, LinkCard } from "~/components"; Agents change how you work with LLMs. In a stat... 1 天前
  30. 30 Conversation state and memory import { TypeScriptExample, LinkCard, WranglerConfig } from "~/components"; Agents need memory to be useful... 1 天前
  31. 31 Concepts import { DirectoryListing } from "~/components"; 1 天前
  32. 32 Tools Tools let models retrieve information, process data, and perform actions. Each tool defines an interface th... 1 天前
  33. 33 What are agents? import { LinkCard } from "~/components"; An agent is an AI system that can autonomously execute tasks by ma... 1 天前
  34. 34 Using Agents with Workflows import { TypeScriptExample, LinkCard } from "~/components"; What are Workflows? Cloudflare Workflows provid... 1 天前
  35. 35 Human-in-the-loop patterns import { TypeScriptExample, WranglerConfig, LinkCard } from "~/components"; Human-in-the-loop (HITL) patter... 1 天前
  36. 36 Agentic patterns This page lists and defines common patterns for implementing AI agents, based on Anthropic's patterns for b... 1 天前
  37. 37 Long-running agents Build agents that persist for days, weeks, or months — surviving restarts, waking on demand, and managing w... 1 天前
  38. 38 Browser agent import { TypeScriptExample, WranglerConfig, PackageManagers, Render, } from "~/components"; Build an agent ... 1 天前
  39. 39 Chat agent import { TypeScriptExample, WranglerConfig, LinkCard } from "~/components"; Build a chat agent that streams... 1 天前
  40. 40 Email agent import { TypeScriptExample, WranglerConfig, LinkCard, PackageManagers, } from "~/components"; Agents can se... 1 天前
  41. 41 Examples import { DirectoryListing } from "~/components"; End-to-end examples showing how to build complete agents. 1 天前
  42. 42 Slack agent import { Details, Render, PackageManagers, WranglerConfig, LinkCard, } from "~/components"; Deploy your fir... 1 天前
  43. 43 Voice agent import { InlineBadge, TypeScriptExample, WranglerConfig, PackageManagers, LinkCard, } from "~/components"; ... 1 天前
  44. 44 Add to an existing project import { PackageManagers, Render, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; Any Clou... 1 天前
  45. 45 Getting started import { DirectoryListing, LinkCard } from "~/components"; An agent on Cloudflare is a Durable Object with ... 1 天前
  46. 46 Learn the runtime import { PackageManagers, Render, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; An agent... 1 天前
  47. 47 Build your first Durable Agent import { PackageManagers, Render, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; A Durabl... 1 天前
  48. 48 Testing your Agents Because Agents run on Cloudflare Workers and Durable Objects, they can be tested using the same tools and t... 1 天前
  49. 49 Harnesses import { LinkCard } from "~/components"; A harness is the loop that makes an agent behave like an agent ins... 1 天前
  50. 50 OpenCode import { CopyPromptButton, PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; OpenC... 1 天前
  51. 51 Extensions import { TypeScriptExample } from "~/components"; Both tools and system prompt sections are provided to the... 1 天前
  52. 52 Pi import { CopyPromptButton, LinkCard, Render, TypeScriptExample, WranglerConfig, } from "~/components"; Pi i... 1 天前
  53. 53 Actions import { TypeScriptExample } from "~/components"; :::note[Experimental] The Actions API surface may evolve ... 1 天前
  54. 54 Channels import { TypeScriptExample } from "~/components"; :::note[Experimental] The Channels API surface may evolve... 1 天前
  55. 55 Client tools import { TypeScriptExample } from "~/components"; Think supports tools that execute in the browser. The cli... 1 天前
  56. 56 Configuration import { TypeScriptExample } from "~/components"; Think is configured by overriding methods and properties ... 1 天前
  57. 57 Getting started import { TypeScriptExample, WranglerConfig } from "~/components"; Build a chat agent with persistent memory... 1 天前
  58. 58 Think import { TypeScriptExample, WranglerConfig, PackageManagers, LinkCard, CardGrid, } from "~/components"; @cl... 1 天前
  59. 59 Lifecycle hooks import { TypeScriptExample } from "~/components"; Think owns the streamText call and provides hooks at eac... 1 天前
  60. 60 Messengers import { TypeScriptExample } from "~/components"; Use messengers when a Think agent should receive and repl... 1 天前
  61. 61 Programmatic submissions import { TypeScriptExample } from "~/components"; Durably accept a Think turn and return before inference r... 1 天前
  62. 62 Durable recovery import { TypeScriptExample } from "~/components"; Think always wraps chat turns in recoverable fibers. If t... 1 天前
  63. 63 Scheduled tasks import { TypeScriptExample } from "~/components"; Use getScheduledTasks() when code should create recurrin... 1 天前
  64. 64 Sub-agent RPC and programmatic turns import { TypeScriptExample } from "~/components"; Think works as both a top-level agent and a sub-agent. Wh... 1 天前
  65. 65 Tools import { TypeScriptExample, WranglerConfig } from "~/components"; Think provides built-in workspace file to... 1 天前
  66. 66 Workflows import { TypeScriptExample } from "~/components"; ThinkWorkflow connects Think to Cloudflare Workflows when... 1 天前
  67. 67 Model Context Protocol (MCP) You can build and deploy Model Context Protocol (MCP) servers on Cloudflare. What is the Model Context Prot... 1 天前
  68. 68 McpAgent (deprecated) import { TypeScriptExample, LinkCard, PackageManagers } from "~/components"; McpAgent creates a stateful le... 1 天前
  69. 69 MCP Client import { Render, TypeScriptExample, LinkCard } from "~/components"; Connect your agent to external Model Co... 1 天前
  70. 70 MCP Server import { LinkCard, PackageManagers, TypeScriptExample } from "~/components"; createMcpHandler from agents/... 1 天前
  71. 71 APIs import { DirectoryListing } from "~/components"; 1 天前
  72. 72 Cloudflare import { DirectoryListing } from "~/components"; 1 天前
  73. 73 Cloudflare Community MCP Server The MCP server for the Cloudflare Community forum lets AI agents search topics, read posts, look up users, ... 1 天前
  74. 74 Cloudflare's own MCP servers Cloudflare runs a catalog of managed remote MCP servers which you can connect to using OAuth on clients lik... 1 天前
  75. 75 Build a Code Mode MCP server import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; A Code Mode MCP ... 1 天前
  76. 76 Connect to an MCP server import { Render, TypeScriptExample, PackageManagers, Steps, LinkCard, } from "~/components"; Your Agent can... 1 天前
  77. 77 Guides import { DirectoryListing } from "~/components"; 1 天前
  78. 78 Migrate to MCP SDK v2 import { PackageManagers, Steps, TypeScriptExample } from "~/components"; This guide covers the MCP SDK v2 ... 1 天前
  79. 79 Handle OAuth with MCP servers import { Render, TypeScriptExample, PackageManagers, LinkCard, } from "~/components"; When connecting to OA... 1 天前
  80. 80 Build a Remote MCP server import { Details, Render, PackageManagers, LinkCard } from "~/components"; This guide shows how to deploy a... 1 天前
  81. 81 Securing MCP servers import { LinkCard, TypeScriptExample } from "~/components"; MCP servers, like any web application, need to ... 1 天前
  82. 82 Test a Remote MCP Server import { Render } from "~/components"; Remote, authorized connections are an evolving part of the Model Con... 1 天前
  83. 83 Authorization import { LinkCard, PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; When building... 1 天前
  84. 84 MCP governance Model Context Protocol (MCP) allows Large Language Models (LLMs) to interact with proprietary data and inte... 1 天前
  85. 85 Protocol import { DirectoryListing } from "~/components"; 1 天前
  86. 86 Tools import { TypeScriptExample, LinkCard } from "~/components"; MCP tools are functions that an MCP server expo... 1 天前
  87. 87 Transport import { TypeScriptExample } from "~/components"; The Model Context Protocol (MCP) specification defines tw... 1 天前
  88. 88 AI SDK import { PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; agents/models/ai-sdk is... 1 天前
  89. 89 Models import { LinkCard, PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; The Agents SD... 1 天前
  90. 90 Pi AI import { PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; agents/models/pi-ai is ... 1 天前
  91. 91 Platform import { DirectoryListing } from "~/components"; 1 天前
  92. 92 Limits import { Render } from "~/components"; Limits that apply to authoring, deploying, and running Agents are de... 1 天前
  93. 93 Runtime import { TypeScriptExample } from "~/components"; Every agent built with the Agents SDK runs on a Durable O... 1 天前
  94. 94 Build a capability import { TypeScriptExample } from "~/components"; Build a capability to reuse a feature that participates i... 1 天前
  95. 95 Capabilities import { TypeScriptExample } from "~/components"; A capability adds a reusable feature to your agent, such ... 1 天前
  96. 96 MCPClientManager import { PackageManagers, Render, TypeScriptExample } from "~/components"; MCPClientManager from agents/mc... 1 天前
  97. 97 Scheduler import { TypeScriptExample } from "~/components"; Scheduler from agents/schedules runs registered callback... 1 天前
  98. 98 Sessions import { Render, TypeScriptExample } from "~/components"; Sessions is the session store that underpins the ... 1 天前
  99. 99 State import { TypeScriptExample } from "~/components"; State from agents/state stores one JSON value in the Dur... 1 天前
  100. 100 Streams import { Render, TypeScriptExample } from "~/components"; <Render file="experimental" product="agents" para... 1 天前
  101. 101 WebSockets import { TypeScriptExample } from "~/components"; WebSockets from agents/websockets is a capability that m... 1 天前
  102. 102 Lifecycle API import { TypeScriptExample } from "~/components"; This page lists every export of agents/lifecycle. For a ... 1 天前
  103. 103 getCurrentAgent() import { TypeScriptExample } from "~/components"; getCurrentAgent() returns the Durable Object that is hand... 1 天前
  104. 104 Lifecycle import { PackageManagers, Render, TypeScriptExample } from "~/components"; Lifecycle from agents/lifecycle... 1 天前
  105. 105 Jobs and alarms import { TypeScriptExample } from "~/components"; A Durable Object has one alarm. The Lifecycle owns that a... 1 天前
  106. 106 Diagnostics channels import { TypeScriptExample, LinkCard } from "~/components"; The Lifecycle and its capabilities publish stru... 1 天前
  107. 107 Observability import { DirectoryListing } from "~/components"; 1 天前
  108. 108 Tracing import { LinkCard, TypeScriptExample, WranglerConfig } from "~/components"; Agent tracing helps you underst... 1 天前
  109. 109 Authentication import { TypeScriptExample } from "~/components"; Anyone who knows an agent's URL can send it requests. Che... 1 天前
  110. 110 Custom routing import { Render, TypeScriptExample } from "~/components"; routeAgentRequest() is optional. Any request that... 1 天前
  111. 111 HTTP and Server-Sent Events import { TypeScriptExample, LinkCard } from "~/components"; Once a request reaches your Durable Object, the... 1 天前
  112. 112 Routing import { TypeScriptExample, WranglerConfig } from "~/components"; Each agent is a named Durable Object. Rou... 1 天前
  113. 113 Routing options import { TypeScriptExample } from "~/components"; Pass options to routeAgentRequest() as the third argumen... 1 天前
  114. 114 Execution import { TypeScriptExample, WranglerConfig } from "~/components"; Agent Skills can bundle scripts under sc... 1 天前
  115. 115 Agent Skills import { DirectoryListing, TypeScriptExample } from "~/components"; Agent Skills are on-demand instructions... 1 天前
  116. 116 Code import { TypeScriptExample } from "~/components"; skills.manifest() creates a source from Agent Skills defi... 1 天前
  117. 117 Computer import { TypeScriptExample, WranglerConfig } from "~/components"; skills.workspace() reads Agent Skills fro... 1 天前
  118. 118 Sources import { DirectoryListing } from "~/components"; A source tells an agent where its Agent Skills live. 1 天前
  119. 119 R2 import { TypeScriptExample, WranglerConfig } from "~/components"; skills.r2() reads Agent Skills from an R2... 1 天前
  120. 120 AI Search import { LinkCard, TypeScriptExample, WranglerConfig } from "~/components"; Agents can use AI Search to ret... 1 天前
  121. 121 Browser import { LinkCard, Render, TypeScriptExample, WranglerConfig, } from "~/components"; Give your agent a brow... 1 天前
  122. 122 File system import { LinkCard, PackageManagers, TypeScriptExample, WranglerConfig, } from "~/components"; Cloudflare Co... 1 天前
  123. 123 Tools import { DirectoryListing } from "~/components"; Tools give agents capabilities such as searching the web, ... 1 天前
  124. 124 MCP import { LinkCard, TypeScriptExample } from "~/components"; Agents can use Model Context Protocol (MCP) as ... 1 天前
  125. 125 Sandbox import { LinkCard, TypeScriptExample, WranglerConfig } from "~/components"; Give an agent a Linux sandbox f... 1 天前
  126. 126 Skills import { PackageManagers, Steps, TypeScriptExample } from "~/components"; Give your agent tools to use Agen... 1 天前
  127. 127 Web fetch import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; Give your agent ... 1 天前
  128. 128 Web search import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; Give your agent ... 1 天前
  129. 129 AI SDK integration import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; The @cloudflare... 1 天前
  130. 130 Code Mode API reference Code Mode publishes six package entry points. Import framework-specific APIs from their matching entry poin... 1 天前
  131. 131 Browser integration import { PackageManagers, Steps, TypeScriptExample } from "~/components"; Use @cloudflare/codemode/browser... 1 天前
  132. 132 Create a durable Code Mode runtime import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; This guide adds ... 1 天前
  133. 133 How Code Mode works import { TypeScriptExample } from "~/components"; Code Mode is a pattern where a model writes code to compo... 1 天前
  134. 134 Code Mode import { CardGrid, LinkCard } from "~/components"; Code Mode is a tool-use pattern where a model writes cod... 1 天前
  135. 135 Use MCP tools with Code Mode import { PackageManagers, Steps, TypeScriptExample } from "~/components"; Use McpConnector to expose tools... 1 天前
  136. 136 Use an OpenAPI service with Code Mode import { Steps, TypeScriptExample } from "~/components"; Use OpenApiConnector to expose an OpenAPI service... 1 天前
  137. 137 Use Code Mode with TanStack AI import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; Use the @cloudf... 1 天前
  138. 138 Agentic Payments import { LinkCard, CardGrid } from "~/components"; AI agents need to discover, pay for, and consume resourc... 1 天前
  139. 139 Charge for HTTP content The mpp-proxy template is a Cloudflare Worker that sits in front of any HTTP backend. When a request hits a... 1 天前
  140. 140 Accept payments with MPP import { PackageManagers, Steps, TypeScriptExample, WranglerConfig, } from "~/components"; Use Cloudflare W... 1 天前
  141. 141 MPP (Machine Payments Protocol) import { LinkCard, CardGrid } from "~/components"; Machine Payments Protocol (MPP) is an open protocol for ... 1 天前
  142. 142 Pay from the Agents SDK import { PackageManagers, Steps, TypeScriptExample } from "~/components"; Use the Cloudflare Agents SDK to ... 1 天前
  143. 143 Charge for HTTP content The x402-proxy template is a Cloudflare Worker that sits in front of any HTTP backend. When a request hits ... 1 天前
  144. 144 Charge for MCP tools import { TypeScriptExample } from "~/components"; The Agents SDK provides paidTool, which registers a tool... 1 天前
  145. 145 x402 import { LinkCard, CardGrid } from "~/components"; x402 is a payment standard built around HTTP 402 (Paymen... 1 天前
  146. 146 Pay from Agents SDK The Agents SDK includes an MCP client that can pay for x402-protected tools. Use it from your Agents or any... 1 天前
  147. 147 Pay from coding tools The following examples show how to add x402 payment handling to AI coding tools. When the tool encounters a... 1 天前