Skip to content

Comments

some playground fixes #965

Merged
threepointone merged 6 commits intomainfrom
better-playground
Feb 21, 2026
Merged

some playground fixes #965
threepointone merged 6 commits intomainfrom
better-playground

Conversation

@threepointone
Copy link
Contributor

  • better top level descriptions
  • added some missing demos that were text only
  • code samples with syntax highlighting
  • self destroy agents after 15 mins of inactivity
  • misc

Add a new CodeExplanation component (using shiki) to render "How it works" code snippets with syntax highlighting and include it in the components index. Update many playground demos (Chat, Codemode, Tools, Callable, Connections, Readonly, Retry, Routing, Schedule, SQL, etc.) to include illustrative codeSections, improved descriptions, and use HighlightedCode/HighlightedJson components instead of raw CodeBlock; also adjust message scrolling refs. Add several multi-agent demo files and corresponding Durable Object types to env.d.ts to support fan-out/pipeline examples. Docs: add TypeScript decorator guidance to callable-methods.md (recommend target ES2021 and warn against experimentalDecorators) and switch the Workers AI model reference in configuration.md. package.json updated to include shiki dependency. These changes enrich the playground with inline, runnable documentation and better developer UX for the demos.
Introduce a playable MCP demo: add a client UI and server agent, plus routing and type updates. Added two new agent implementations (mcp-client-agent.ts and mcp-server-agent.ts) that expose callables for connecting/disconnecting and calling tools, and register several example tools (roll_dice, generate_uuid, word_count, hash_text) and a server resource. Updated ClientDemo and ServerDemo UIs to let users connect to the MCP server, inspect discovered tools/resources, call tools, and view logs. Wire up the MCP server handler in src/server.ts and export the new agents. Update env.d.ts with DurableObject namespaces for the new agents and adjust wrangler.jsonc to include bindings and run_worker_first routing for /mcp-server. Also include a small markup tweak in DemoWrapper.
Introduce MCP request utilities and session management in ServerDemo: add MCP_HEADERS, mcpRequest (JSON-RPC POST helper with SSE/text-event-stream parsing), and ensureSession (initialize session and send notifications/initialized). Store sessionId in component state, ensure a session before calling tools/call, log newly created session, and reset sessionId on errors. Update tool call flow to use the new helpers and handle server-sent event responses.
Add a new shared PlaygroundAgent that extends Agent and adds durable idle timeout / self-cleanup behavior (cancel idle schedule on connect, schedule destroy on last close, and destroy on idle timeout). Update many playground demo agents to import PlaygroundAgent as Agent and adjust connection handlers to call super when needed. For the HTTP-based MCP server, add a resetIdleTimer helper and onIdleTimeout logic to reset the 15-minute idle schedule on each tool call so unused demo sessions are cleaned up. Misc: update RoomAgent onConnect signature to accept ConnectionContext and pass it to super.
@changeset-bot
Copy link

changeset-bot bot commented Feb 21, 2026

⚠️ No Changeset found

Latest commit: 50ab82f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@965
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/ai-chat@965
npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/codemode@965
npm i https://pkg.pr.new/cloudflare/agents/hono-agents@965

commit: 98056cf

Import ConnectionContext and update ConnectionsAgent.onConnect to accept a ConnectionContext parameter and forward it to super instead of casting to any. This improves type-safety for connection handling and preserves the original broadcast behavior.
Mark MCP Server and MCP Client items as implemented and flesh out details in the playground TODO. Adds MCP Server at /mcp-server with tools (roll_dice, generate_uuid, word_count, hash_text) and resources, and an MCP Client that discovers tools via onMcpUpdate and calls them. Also adds an Idle Cleanup entry: agents self-destroy after 15 minutes without connections. Minor checkbox/format cleanup.
@threepointone threepointone merged commit fac6221 into main Feb 21, 2026
2 of 3 checks passed
@threepointone threepointone deleted the better-playground branch February 21, 2026 14:38
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