Updated 4 Agents guides to latest#28319
Conversation
…tices and agents-starter - Use $today for compatibility_date per Workers best practices - Update AIChatAgent import to @cloudflare/ai-chat - Update tool definitions to use inputSchema (AI SDK v5) and zod/v3 - Update getSchedulePrompt import to agents/schedule - Add satisfies ExportedHandler<Env> to all default exports - Replace .dev.vars with .env for local secrets per best practices - Add wrangler secret bulk .env guidance for production - Replace hand-written Env types with wrangler types guidance - Add @callable() decorators to add-to-existing-project example - Fix vitest config references from .js to .ts - Remove $ prefix from terminal commands in testing guide - Use txt language for command output blocks
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
|
/bonk great. re-review, and suggest any structural improvements that make sure each of these guides is consistent, clear about the goals, and easy to understand for new users to Agents. assume 90% of users who read this are earlier career and/or new to Workers and the Agents SDK. avoid over-explaining or diluting the guide itself, but look for ambiguity in instructions and correct for it. |
- quick-start: add project name to create command so cd my-agent matches - add-to-existing-project: add missing description, fix misdirected 'starting fresh' link to point to quick-start instead of chat agent, add missing Agent import in multiple-agents example - testing-your-agent: add missing description, fix pcx_content_type to how-to, fix response.text() to response.json() in test examples, use relative URL for wrangler dev link, add Next steps section - build-a-chat-agent: rename Step 3 to 'Run the dev server' to avoid confusion with testing guide, remove duplicate secrets section, add Next steps section, import LinkCard
|
Here is a summary of what I found and fixed: Structural review summaryIssues found and fixedquick-start.mdx
add-to-existing-project.mdx
testing-your-agent.mdx
build-a-chat-agent.mdx
Consistency improvements across all guides
|
|
/bonk fix the CI failure |
|
Fixed. The CI failure was caused by a broken link in |
| export class Chat extends Agent { | ||
| import { Agent } from "agents"; | ||
|
|
||
| export class Chat extends Agent<Env> { |
There was a problem hiding this comment.
we actually don't recommend adding Env because we default to Cloudflare.Env, which wrangler types generates
There was a problem hiding this comment.
/bonk address this comment here re: wrangler types auto generation of Env and Agent<T> using it by default
wrangler types generates Cloudflare.Env which Agent uses by default, so Agent<Env> is redundant. Keep Env only where a second type param (state) is needed, e.g. Agent<Env, CounterState>.
|
Done. Here's what I changed to address @threepointone's review comment:
I left |
All changes are committed. Here is a summary of all updates made across the four guides:
Changes by file
quick-start.mdxcompatibility_datefrom"2025-01-01"to"$today"per Workers best practicessatisfies ExportedHandler<Env>to the default exportadd-to-existing-project.mdxcompatibility_datefrom"2025-01-01"to"$today"@callable()decorators to the CounterAgent example (was missing, inconsistent with quick-start)satisfies ExportedHandler<Env>to all five default export examples (plain Workers, static assets, auth, server access)Envinterface typing guidance withwrangler typesgeneration guidance per best practicestesting-your-agent.mdx.jsto.ts(matches the actual starter)jstotsfor vitest config examples$prefix from terminal commands (npm run test,npx vitest,npx wrangler dev)sh outputcode blocks totxt(unsupported language identifier)build-a-chat-agent.mdxAIChatAgentimport from"agents/ai-chat-agent"to"@cloudflare/ai-chat"(matches current starter)onChatMessagetype signature withStreamTextOnFinishCallback<ToolSet>parameterstoinputSchema(AI SDK v5 API)"zod"to"zod/v3"(matches current starter)unstable_getSchedulePrompttogetSchedulePromptfrom"agents/schedule".dev.varsto.envfor local secrets per Workers best practices.gitignorereminder for.envfileswrangler secret bulk .envguidance for uploading secrets to productionCloses #28318
github run