Claude Opus 5.5

agents-0-25-0-3-b

Claude Code's read-only tools, web search on, ludion sync off

Question

Why does native RPC to my Agent fail when I address it with idFromString()?

Answer key

A correct answer says
Native RPC to async Agent/Think methods first runs lifecycle initialization, so Agents must be addressed by name; stubs from `newUniqueId()` or `idFromString()` fail their first async RPC.
The stale answer
You can get an Agent stub from any Durable Object ID, including `newUniqueId()` or `idFromString()`, and call its methods over RPC.

Answer

Most likely cause: an Agent is a Durable Object built on PartyServer, and it needs to know its **name**. `getAgentByName()` and `routeAgentRequest()` pass that name in when they get the stub. `idFromString()` (like `newUniqueId()`) gives you a stub for a bare hex ID with no name attached, so the Agent never sets `this.name`. When your RPC method runs, anything that reads the name or depends on it (state, SQL setup, `onStart`, scheduling, broadcasting) throws, usually with an error like "Attempting to read .name … before it was set."

The fix is to address Agents by name: `const stub = await getAgentByName(env.MyAgent, "some-name")`, then call `stub.myMethod()`. If you only have an ID string, keep a mapping back to the name you used and look it up that way. I answered from memory of the Agents SDK and didn't check your code, so if your error message is different, paste it and I'll take another look.

Answering cost $0.06.

Grade

correct

The judge's reason: It says Agents must be addressed by name and that RPC on idFromString()/newUniqueId() stubs fails because name-dependent initialization (onStart, state, SQL setup) can't run, which matches the key and doesn't claim the stale behavior.

The judge's log

Session log

What the agent wrote, the tools it called, and what they returned, from docs/bench/2026-10-11-done3/runs/B-project/agents-0-25-0-3-b.jsonl. Thinking and the session's settings are left out. The raw log

  1. Agent

    Most likely cause: an Agent is a Durable Object built on PartyServer, and it needs to know its **name**. `getAgentByName()` and `routeAgentRequest()` pass that name in when they get the stub. `idFromString()` (like `newUniqueId()`) gives you a stub for a bare hex ID with no name attached, so the Agent never sets `this.name`. When your RPC method runs, anything that reads the name or depends on it (state, SQL setup, `onStart`, scheduling, broadcasting) throws, usually with an error like "Attempting to read .name … before it was set."
    
    The fix is to address Agents by name: `const stub = await getAgentByName(env.MyAgent, "some-name")`, then call `stub.myMethod()`. If you only have an ID string, keep a mapping back to the name you used and look it up that way. I answered from memory of the Agents SDK and didn't check your code, so if your error message is different, paste it and I'll take another look.