Reject `override(toolsets=...)` and run-time `id` collisions under durable execution
The shared defect
Both issues let a toolset the agent was not constructed with escape durable wrapping:
override(toolsets=...)replaced the construction-time list while the runtime guard was deciding which leaves were registered.@agent.toolsetappended aDynamicToolsetafter construction and after the engine created its activities, steps, or tasks.
The fix makes _registered_toolsets the single answer to βwhat was this agent built with?β Agent._build_toolset_list(ignore_overrides=True) now ignores contextual overrides and slices decorator-added dynamic toolsets off at the constructor-time boundary. The durable runtime guard re-reads that live view during each run, so capability-contributed toolsets that are legitimately recreated per run are compared with the current capability tree rather than stale object identities.
Executing toolsets that arrive later are rejected inside a workflow or flow through each engine's existing _unsupported_runtime_toolset_kinds. Outside a durable container, the capability remains transparent. The error directs users to pass DynamicToolset(..., id='...') through Agent(toolsets=[...]).
Why #6946 was superseded
#6946 was closed as superseded by this PR. Its bind-time snapshot of registered leaf object identities failed because capability-contributed toolsets are legitimately recreated per run. Fresh runtime identities were therefore misclassified as late arrivals, including by test_durability_validates_only_resolved_runtime_capability_layers. This PR deliberately uses a live re-read of _registered_toolsets instead.
Existing #6908 behavior
The existing change continues to:
- reject unsupported executing toolsets passed through
run(toolsets=...)oroverride(toolsets=...); - preserve DBOS's deliberate allowance for
FunctionToolset, whose tools run inline; - reject run-time toolsets that reuse a registered
id, preventing dispatch to the wrong wrapped toolset.
Tests and docs
Each durable engine now covers:
- a decorator-registered
DynamicToolsetworking outside the durable container; - the same registration raising
UserErrorinside a workflow or flow; DynamicToolset(..., id='...')passed toAgent(toolsets=[...])receiving activities, steps, or tasks.
The Temporal, DBOS, and Prefect guides and the bundled agent-building skill now state that every executing toolset must be passed to the constructor under durable execution. Temporal no longer recommends decorator id= as a durable configuration.
Checklist
- Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
- No breaking changes in accordance with the version policy.
- PR title is fit for the release changelog.