Give the `PydanticAIDocs` and `BrowserUse` toolsets an `id`, as Temporal requires

Merged
DO
1d ago
+89-40

Written by Claude Code on behalf of @DouweM.

Part of #9233

Why we make these changes

A Temporal agent with PydanticAIDocs or BrowserUse fails at construction with Toolsets that are 'leaves' ... need to have a unique id ... Temporal, because both build their toolset without an id. For PydanticAIDocs the error's advice doesn't help: the capability already has id='pydantic_ai_docs', it just isn't forwarded. These were the last two _TOOLSET_WITHOUT_ID exemptions citing #9233 in tests/capability_cases.py.

  • PydanticAIDocs forwards its id to its toolset, so the default 'pydantic_ai_docs' and a custom id name the toolset; id=None stays id-less, as the unset_id contract asks.
  • BrowserUse passes its id, or 'browser_use' when unset, as Shell and FileSystem do. Its capability id default is unchanged (Collides case), so repeats behave as before.

Left open on #9233: whether FileSystem/Shell should declare a capability default id, which tests/capability_cases.py records as an owner decision (merging would union allow-lists).

New public surface

  • PydanticAIDocsToolset(..., id: str | None = None) and BrowserUseToolset(..., id: str | None = None): optional keyword, like ShellToolset/FileSystemToolset. API compat check against v2.77.0 passes.

User-visible behavior

Agent(model, capabilities=[PydanticAIDocs(), TemporalDurability()])
# before: UserError (leaf toolset needs an id)
# after: registers agent__<name>__toolset__pydantic_ai_docs__call_tool

PydanticAIDocs still doesn't run under Temporal: each run builds a new toolset with the same id, which Temporal refuses when the run starts in a workflow (the DURABLE_TEMPORAL exemption in tests/capability_cases.py). #15623 fixes that by sharing the toolset across runs, and the docs now say so.

Verification

  • New test_temporal_names_pydantic_ai_docs_activities_after_the_capability_id in tests/harness/test_durable_engine_exports.py (default and custom id), and test_the_toolset_id_is_the_capability_id_or_browser_use in tests/harness/browser_use/test_browser_use.py. That module can't name Temporal, because the harness Temporal job collects every module that mentions it and has no browser_use.
  • unset_id/custom_id contracts now hold for PydanticAIDocs and custom_id for BrowserUse (stale exemptions removed).
  • Without the fix, the PydanticAIDocs test fails with the Temporal UserError (run in-process). The BrowserUse test runs only in the browser-use CI job (not installed locally).
  • scripts/durable_exec_contract.py --write: no change.

What changes for existing users

No persisted unit name moves: Temporal and every engine that wraps function toolsets refused these toolsets, and DBOS doesn't wrap FunctionToolsets. Outside durable execution the toolsets' id is now set instead of None.

  • Deprecated PrefectAgent: it accepted the id-less docs and browser toolsets and wrapped them in tasks. Their task names don't change, but the task cache key includes the toolset id. So a PrefectAgent flow retried across the upgrade misses its saved result once and runs read_pyai_docs or browse_web again, the same as when a tool's description changes between releases.
  • DBOS with child_workflow selected (via SetToolMetadata): these toolsets now register a child workflow, where that setup raised UserError before. This can change DBOS's application-version hash.
PR decisions
  • 2026-11-30 pre-push review 1 of 3 at 5d33d665536652ac808b1ef57e4c07e5d47744d0: no findings (current at 5d33d66). Tree 58d88b08a9b81818bdf05c975f6922802d08d10a; full branch vs merge base ffd953b3b2; fresh read-only reviewer from an origin/main policy checkout.
  • 2026-11-30 scope: fix only the capabilities whose toolset Temporal refuses; deriving default ids in the engines (position-based, or one generic call_tool unit) was considered and left out, as it adds a new identity rule that maintainers chose against (_explicit_id only, durable_exec/_base.py).
  • 2026-11-30 083f6ad5 pushed under the test-harness-repair exemption, chained from reviewed SHA 5d33d66 (review budget 1 of 3 used). The delta is test code only: it moves the BrowserUse test off Temporal and pins TemporalDurability[None] for Pyright, after the first CI run.
  • 2026-11-30 b9b1d168 and 23c42ae7 pushed under the same test-only exemption, chained from 5d33d66. b9b1d168 asserts the BrowserUse toolset's _explicit_id (PR Review Checks finding). 23c42ae7 builds the docs test's agents inline, so Pyright infers their deps type.
  • 2026-11-30 6986d877 pushed under the same test-only exemption, chained from 5d33d66. It applies two PR Review Checks findings: the Temporal test moves to test_durable_engine_exports.py, and the BrowserUse test asserts the public id. Three findings were declined with evidence: the test never runs the agent, so the docs-path env var can't reach it; no CI job has both browser_use and temporalio; DBOS doesn't wrap FunctionToolsets.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.