Skip to content

Upgrade: Cloudflare sub-agent entries go through a Durable Object RPC method ​

@helix-agents/runtime-cloudflare (major): a parent Durable Object starts and resumes its sub-agents and companions through DurableObjectAgentBase.subAgentEntry, a Durable Object RPC method. A sub-agent's parent, root and consult come from that entry only.

What to do ​

  1. Use compatibility date 2024-04-03 or later, or add the rpc compatibility flag:

    toml
    compatibility_date = "2024-04-03"
    # or, on an older date:
    compatibility_flags = ["nodejs_compat", "rpc"]

    On an older date without the flag, a child entry is refused framework_not_supported before anything is sent.

  2. A custom subAgentNamespace, or a wrapper of one (tracing, metrics, a test fake), must also forward subAgentEntry. A wrapper that forwards only fetch gets the same typed refusal:

    ts
    get: (id) => { const s = ns.get(id); return { fetch: (i, init) => s.fetch(i, init), subAgentEntry: (r) => s.subAgentEntry(r) }; },

    A namespace from env (the Durable Object binding itself) needs no change.

What else changed ​

  • A sub-agent's parent, root and consult come from subAgentEntry only. A /subagent/:type/start or /resume that reaches a Durable Object through its fetch (the remote-agent worker handler, or an app's own route) names no parent, root or consult: a new session is a root session in this service, and its binding is kept. A native /start is the same. Such an entry into an existing session enters it as it is, with its stored parent and root.
  • An entry into an existing session must match the session's parent and root. One that names another parent or root (including a parent on a root session) is refused state_child_session_taken (409). Nothing is written.
  • An app's auth hook decides who may create or enter a session with a given id.
  • A parent's abort bounds its wait for a child entry; it does not cancel the child's entry.
  • @helix-agents/runtime-js (minor): execute() onto an existing session whose parentSessionId / rootSessionId (or binding parent) differs from the session's is refused state_child_session_taken before anything is written.

Released under the MIT License.