Patch Changes
-
#1286
d76f8b9Thanks @threepointone! - FixMcpAgent.handleMcpMessagecrashing with "Attempting to read .name before it was set" when the Durable Object wakes from hibernation via native DO RPC. The method now calls__unsafe_ensureInitialized()to hydratethis.namefrom storage and runonStart()before processing messages, matching the pattern used by_workflow_*RPC methods andalarm(). -
#1278
8c7caabThanks @threepointone! - Think now owns the inference loop with lifecycle hooks at every stage.Breaking:
onChatMessage(),assembleContext(), andgetMaxSteps()are removed. Use lifecycle hooks and themaxStepsproperty instead. If you need full custom inference, extendAgentdirectly.New lifecycle hooks:
beforeTurn,beforeToolCall,afterToolCall,onStepFinish,onChunk— fire on every turn from all entry paths (WebSocket,chat(),saveMessages, auto-continuation).beforeTurn(ctx)receives the assembled system prompt, messages, tools, and model. Return aTurnConfigto override any part — model, system prompt, messages, tools, activeTools, toolChoice, maxSteps, providerOptions.maxStepsis now a property (default 10) instead of a method. Override per-turn viaTurnConfig.maxSteps.MCP tools auto-merged — no need to manually merge
this.mcp.getAITools()ingetTools().Dynamic context blocks:
Session.addContext()andSession.removeContext()allow adding/removing context blocks after session initialization (e.g., from extensions).Extension manifest expanded with
context(namespaced context block declarations) andhooksfields.