github cloudflare/agents agents@0.2.24

one month ago

Patch Changes

  • #673 603b825 Thanks @whoiskatrin! - added resumable streaming with minimal setup

  • #665 4c0838a Thanks @threepointone! - Add default JSON schema validator to MCP client

  • #664 36d03e6 Thanks @threepointone! - Refactor MCP server table management in Agent class

    Moved creation and deletion of the cf_agents_mcp_servers table from AgentMCPClientStorage to the Agent class. Removed redundant create and destroy methods from AgentMCPClientStorage and updated MCPClientManager to reflect these changes. Added comments to clarify usage in demo and test code.

  • #653 412321b Thanks @deathbyknowledge! - Allow this.destroy inside a schedule by including a destroyed flag and yielding ctx.abort instead of calling it directly
    Fix issue where schedules would not be able to run for more 30 seconds due to blockConccurencyWhile. alarm() isn't manually called anymore, getting rid of the bCW.
    Fix an issue where immediate schedules (e.g. this.schedule(0, "foo"))) would not get immediately scheduled.

  • #652 c07b2c0 Thanks @mattzcarey! - ### New Features

    • MCPClientManager API changes:
      • New registerServer() method to register servers (replaces part of connect())
      • New connectToServer() method to establish connection (replaces part of connect())
      • connect() method deprecated (still works for backward compatibility)
    • Connection state observability: New onServerStateChanged() event for tracking all server state changes
    • Improved reconnect logic: restoreConnectionsFromStorage() handles failed connections

    Bug Fixes

    • Fixed failed connections not being recreated on restore
    • Fixed redundant storage operations during connection restoration
    • Fixed potential OAuth storage initialization issue by excluding non-serializable authProvider from stored server options
    • Added defensive checks for storage initialization in MCPClientManager and DurableObjectOAuthClientProvider
    • Fixed initialization order: MCPClientManager is now created AFTER database tables are created to prevent possible table-not-found errors during DO restart
  • #678 cccbd0f Thanks @whoiskatrin! - convert internal AI SDK stream events to UIMessageStreamPart format

  • #672 7c9f8b0 Thanks @mattzcarey! - - MCPClientConnection.init() no longer triggers discovery automatically. Discovery should be done via discover() or through MCPClientManager.discoverIfConnected()

    Features

    • New discover() method on MCPClientConnection with full lifecycle management:
      • Handles state transitions (CONNECTED → DISCOVERING → READY on success, CONNECTED on failure)
      • Supports cancellation via AbortController (cancels previous in-flight discovery)
      • Configurable timeout (default 15s)
    • New cancelDiscovery() method to abort in-flight discoveries
    • New discoverIfConnected() on MCPClientManager for simpler capability discovery per server
    • createConnection() now returns the connection object for immediate use
    • Created MCPConnectionState enum to formalize possible states: idle, connecting, authenticating, connected, discovering, ready, failed

    Fixes

    • Fixed discovery hanging on repeated requests - New discoveries now cancel previous in-flight ones via AbortController
    • Fixed Durable Object crash-looping - restoreConnectionsFromStorage() now starts connections in background (fire-and-forget) to avoid blocking onStart and causing blockConcurrencyWhile timeouts
    • Fixed OAuth callback race condition - When auth_url exists in storage during restoration, state is set to AUTHENTICATING directly instead of calling connectToServer() which was overwriting the state
    • Set discovery timeout to 15s
    • MCP Client Discovery failures now throw errors immediately instead of continuing with empty arrays
    • Added "connected" state to represent a connected server with no tools loaded yet
  • #654 a315e86 Thanks @mattzcarey! - When handling MCP server requests use relatedRequestId in TransportOptions to send the response down a POST stream if supported (streamable-http)

  • #661 93589e5 Thanks @naji247! - fix: add session ID and header support to SSE transport

    The SSE transport now properly forwards session IDs and request headers to MCP message handlers, achieving closer header parity with StreamableHTTP transport. This allows MCP servers using SSE to access request headers for session management.

  • #659 48849be Thanks @threepointone! - update dependencies

Don't miss a new agents release

NewReleases is sending notifications on new releases.