Skip to content

refactor(ai): the durable resolver offers only the engines that work, and the unread ai.durable settings are removed #1121

Closed

Description

@dan-petty

Problem

Lines cited at dcafadf.

ai/durable.py offers three optional durable-execution engines next to its local one: Temporal (temporalio), DBOS (dbos) and Prefect (prefect). Each has an availability check (is_temporal_available, is_dbos_available, is_prefect_available, :269-299, collected by get_available_durable_engines, :302-311) and a branch in resolve_durability_capability (:516-559) that builds pydantic-ai's TemporalDurability, DBOSDurability or PrefectDurability. They shipped in v0.2.10. None of the three packages is declared in pyproject.toml, locked in uv.lock or installed.

  • Nothing can select them.
    • No command, MCP tool or setting reaches the branches.
    • ai.durable is documented (docs/CONFIGURATION.md:96: engine defaulting to sqlite, plus store_path, task_queue and workflow_id_prefix), but no code reads settings.ai.durable (config/settings.py:395-401, :479). task_queue and workflow_id_prefix are Temporal terms that nothing passes on.
    • The only caller of resolve_durability_capability in src is create_durable_pydantic_agent (ai/durable.py:595), and nothing in src calls that function. refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005 deletes it.
    • Every other reference is a re-export: ai/__init__.py:45-57, ai/agents/__init__.py:294-306, ai/agents/pydantic_agent.py:218-227. ai/agents/persistence.py:12 imports only the local engine.
  • A selected engine would not be durable. pydantic-ai's docs for each engine say a run is durable only when agent.run() executes inside a Temporal workflow on a worker, a @DBOS.workflow of a launched DBOS instance, or a Prefect @flow. Outside those, the capability does nothing and the run is a plain one. Nothing in src starts a Worker, defines a workflow, calls DBOS. or decorates a @flow. Production also builds only the hand-rolled PydanticAgent, never a native pydantic_ai.Agent (refactor(ai): one agent runtime behind one construction point, with no silent fallback #1005), so no production run could carry any of these capabilities.
  • The install hints lead to a broken import.
    • The errors at :518-521, :533-536 and :548-551 say pip install "pydantic-ai-slim[temporal]" or uv add temporalio. The uv add hint is unpinned, unlike every dependency in pyproject.toml.
    • pydantic-ai-slim 2.35.0 is the version that pydantic-ai==2.35.0 (pyproject.toml:37) brings in. Its extra asks only for temporalio>=1.24.0, so installing pydantic-ai-slim[temporal]==2.35.0 today gets temporalio 1.34.0 (released 2026-09-30).
    • Installs in a throwaway Python 3.14.7 environment with pydantic 2.13.5, the pinned version (pyproject.toml:15), gave these results:
      • With temporalio 1.34.0, import pydantic_ai.durable_exec.temporal raises PydanticSchemaGenerationError for temporalio.workflow._event_groups.EventGroup, from pydantic_ai/durable_exec/temporal/_toolset.py:250.
      • temporalio 1.24.0, 1.27.0, 1.31.0, 1.32.0 and 1.33.0 import cleanly. So does 1.34.0 with pydantic-ai-slim 2.54.0.
      • is_temporal_available() (copied from :269-277) catches only ImportError. With 1.34.0 installed it raises that error instead of returning False, so get_available_durable_engines() and resolve_durability_capability("temporal") raise it too.
  • pydantic-ai does not test Temporal on the only Python devops-cli supports. devops-cli sets requires-python = ">=3.14" (pyproject.toml:10). pydantic-ai skips its whole Temporal suite on Python 3.14 (tests/test_temporal.py:208-214 at v2.35.0, tests/durable_exec/temporal/_shared.py:66-72 at v2.54.0) until sys.monitoring callbacks (coverage, etc.) cause workflow sandbox hang on Python 3.14 temporalio/sdk-python#1326 closes. That issue was still open on 2026-10-03.
  • What declaring them would cost.
    • Versions:
      • pydantic-ai==2.35.0 has extras named temporal, dbos and prefect. Each requires pydantic-ai-slim[<extra>]==2.35.0, which sets only minimum versions: temporalio>=1.24.0, dbos>=2.10.0, prefect>=3.7.5.
      • pydantic-ai's lock at v2.35.0 tests temporalio 1.24.0, dbos 2.10.0 and prefect 3.7.7; at v2.54.0 it tests temporalio 1.31.0 and still dbos 2.10.0 and prefect 3.7.7.
      • PyPI's newest releases are temporalio 1.34.0, dbos 3.2.0 and prefect 3.8.7. An extra without its own exact pin on the engine therefore installs versions pydantic-ai does not test.
    • Size: each extra was resolved for Python 3.14 against uv.lock without an engine pin. The sizes are the unpacked x86_64 Linux wheels of the packages uv.lock does not already hold, without bytecode:
      • temporal: 3 new packages (temporalio 1.34.0, nexus-rpc, types-protobuf), about 52 MB installed. temporalio alone is about 51 MB, 33 MB of it the temporal_sdk_bridge.abi3.so native library.
      • dbos, resolved today (dbos 3.2.0): 5 new packages (dbos, psycopg, psycopg-binary, SQLAlchemy, greenlet), about 42 MB.
      • prefect: 41 new packages, among them Alembic, asyncpg, Apprise, amplitude-analytics and redis, about 82 MB.
      • All three: 47 packages, about 156 MB.
    • Import time: importing all three integrations after pydantic_ai took 3.0-4.8 s in one interpreter. The host was busy during the measurement (load1 about 15 on 16 CPUs).
    • Offline testing:
      • Temporal and Prefect can be checked offline only by importing them. pydantic-ai's Temporal tests download a dev-server binary on first use, and its Prefect tests start a local Prefect server (prefect_test_harness, allowed 60 s to start).
      • DBOS alone runs in-process against SQLite.
      • Prefect 3.8.7 sends a first-use analytics event when imported in an interactive terminal, unless DO_NOT_TRACK=1 or a CI variable is set (prefect/__init__.py, prefect/_internal/analytics/).
  • Project policy. AGENTS.md:90-91 and :95 call for removing vestigial code rather than keeping it before 1.0.

Acceptance criteria

  • Pending a person: the owner chooses between deletion and the DBOS alternative (first two key questions) before work starts. The criteria below are for deletion.
  • ai/durable.py builds only the local engine:
    • is_temporal_available, is_dbos_available, is_prefect_available and get_available_durable_engines (:269-311) are deleted, along with the three resolver branches (:516-559).
    • The resolver's docstring (:484-490) and its unknown-engine error (:561-564) name only sqlite, local and memory.
    • A test asserts that resolve_durability_capability("unsupported_backend") raises ConfigurationError with a message that lists exactly those three.
  • The removed names leave every re-export list:
    • ai/__init__.py:45-57 and __all__ (:1045, :1069, :1073, :1077).
    • ai/agents/__init__.py:294-306 and __all__ (:1114, :1134, :1138, :1143).
    • ai/agents/pydantic_agent.py:218-227 and __all__ (:834, :852, :855, :860).
    • ai/durable.py's __all__ (:631-634).
  • rg -n -i 'temporalio|dbos|prefect|temporal(_|\]|durab|")' src tests prints nothing. At dcafadf it prints 102 lines in 5 files, all of them durable-engine code, re-exports or tests.
  • ai.durable is removed:
    • AIDurableConfig and AIConfig.durable (config/settings.py:395-401, :479, and the imports at :39-42).
    • DEFAULT_AI_DURABLE_TASK_QUEUE and DEFAULT_AI_DURABLE_WORKFLOW_PREFIX (config/defaults.py:125-126), with their re-exports (config/__init__.py:179-180, :636-637; ai/durable.py:31-32, :622-623).
    • DEFAULT_AI_DURABLE_ENGINE and DEFAULT_AI_DURABLE_STORE_PATH stay, because the resolver uses them as defaults (ai/durable.py:473, :496).
    • After devops docs generate, docs/CONFIGURATION.md no longer lists durable.
    • A test loads a configuration that still has an ai.durable block and shows it loads without error. AIConfig uses pydantic's default of ignoring unknown keys.
  • Changes to tests/test_pydantic_ai_durable.py:
    • test_resolve_durability_capability_mocked_external_engines (:342-380) and test_ai_durable_config_settings (:235-252) are deleted.
    • test_native_durable_reexports_and_availability_helpers (:34-58) checks only the re-exports.
    • test_resolve_durability_capability_missing_external_engines (:181-196) becomes the unknown-engine test above.
    • The module imports that would no longer resolve or would go unused are removed: the four helpers at :18-21, the whole devops_cli.config.defaults import at :24-29 (DEFAULT_AI_DURABLE_TASK_QUEUE and DEFAULT_AI_DURABLE_WORKFLOW_PREFIX at :27-28 no longer exist, and the other two names are used only by the deleted settings test), and AIDurableConfig at :30. Settings stays.
    • The tests stay offline. The change removes two tests and adds no dependency or measurable gate time.
  • No dependency, extra or uv.lock change. If fix(deps): pyproject.toml declares every package src imports, and a deptry step in devops ci keeps it that way #1120 has landed, the DEP001 entries for temporalio, dbos and prefect are removed from [tool.deptry.per_rule_ignores] (with the DEP001 key and its comment, once the list is empty), and uv run deptry src passes.
  • changelog.d/<issue>.md lists the three engines, the four helper functions and the ai.durable keys under ### Removed. CHANGELOG.md is not edited.
  • uv run devops ci passes.

Key questions

Strategic alignment

Update 2026-10-08: refinement

#1446 pinned pydantic-ai==2.54.0, with which temporalio imports cleanly, so 'the install hints lead to a broken import' no longer holds; the hints are unpinned (ai/durable.py:532-562). Deletion stands. The DBOS alternative pins pydantic-ai[dbos]==2.54.0 and dbos==2.10.0. The local engine is decided by #1331 (Q22, 2026-10-07): nothing public reaches the resolver, SqliteStepStore or StepPersistence, so they go with #1331, and this item removes the three engines and ai.durable. #1374 then closes as not planned.

Proposed design

Problem statement

The ai/durable.py module offers three optional durable-execution engines (Temporal, DBOS, Prefect) that are not actually usable. None of these packages is declared in pyproject.toml, they are not installed, and nothing in the codebase selects or uses them. The install hints lead to broken imports, and the engines are untested on the supported Python version. The module also defines ai.durable settings that are never read, and re-exports these names in multiple places.

Acceptance criteria

  • Criterion 1: The ai/durable.py module builds only the local engine, with all external engine functions and branches removed.
    Verification: Running rg -n -i 'temporalio|dbos|prefect' src tests prints nothing.
  • Criterion 2: All re-export lists are updated to remove the durable engine names.
    Verification: The __all__ lists in ai/__init__.py, ai/agents/__init__.py, ai/agents/pydantic_agent.py, and ai/durable.py no longer include Temporal, DBOS or Prefect related items.
  • Criterion 3: The ai.durable configuration block is removed from settings.
    Verification: The AIDurableConfig and AIConfig.durable are deleted, and ai.durable no longer appears in docs/CONFIGURATION.md after running devops docs generate.
  • Criterion 4: Tests related to external durable engines are removed or updated.
    Verification: The tests test_resolve_durability_capability_mocked_external_engines, test_ai_durable_config_settings, and test_native_durable_reexports_and_availability_helpers are deleted, and test_resolve_durability_capability_missing_external_engines is updated to test only unknown engine errors.
  • Criterion 5: The ai/durable.py module no longer imports external engine packages or related code.
    Verification: After changes, running uv run devops ci passes with no dependency or extra changes.

Key questions

Open questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/refactor
    scope/ai
    scope/config
    priority/p3-low
    on Oct 3, 2026
  2. added this to the v0.2.39 milestone on Oct 22, 2026
  3. added
    status/in-progress
    on Oct 22, 2026
  4. added a commit that references this issue on Oct 22, 2026
    c53d780
  5. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1880, merged into release/v0.2.39 as c53d780.

    Cause: devops_cli.ai.durable built Temporal, DBOS and Prefect durability bridges that nothing could select (none of the three packages is declared or locked, and a run is durable only inside the engine's own workflow), a local SQLite step store behind them, and an ai.durable settings block (engine, store_path, task_queue, workflow_id_prefix) that no code ever read. Next to it sat five agent modules that no command, server tool or other module imported: ai/agents/media.py, persistence.py, prompt.py, spend.py and synthesis_protocol.py. An AST import graph from every commands/ and server/ module, main and entry (75 entries, 543 of 567 modules reached) reaches none of the six. The only importer of ai/durable.py was persistence.py, and nothing imported persistence.py. No importlib, entry point or registry names any of them, and the facades no longer re-export them.

    Change: the six modules and the six test modules written for them are deleted, with every symbol that only they used. AIDurableConfig and AIConfig.durable leave config/settings.py, and the row leaves docs/CONFIGURATION.md. The six DEFAULT_AI_DURABLE_* constants, DEFAULT_SQLITE_MEMORY_DB_PATH and the two DEFAULT_MEDIA_* constants leave config/defaults.py and config/__init__.py. BudgetExceededError goes with its module, so CONST_DOMAIN_EXCEPTION_MODULES and the generated docs/ERRORS.md lose it. sanitize_prompt_injection (its only caller was ManagedPrompt)…

    32 file(s) changed.

    How it was verified

    Check runs at d402af7:

    • Audit Defect PR Hardening: skipping
    • Prune PR DevContainer Images: pass
    • Service Image: skipping
    • Dependency Freshness: skipping
    • DevContainer Image: skipping
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Fail-to-Pass Check: pass
    • Fail-to-Pass Self-Check: pass
    • Changed-Test Independence: pass
    • Rule Pack Tests: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Analyze (actions): pass
    • Static Analysis: pass

    Acceptance Criteria of docs/agent/tasks/task-1121-unwired-agent-extras-and-durable.md:

    • The three engines, is_temporal_available, is_dbos_available, is_prefect_available and get_available_durable_engines are deleted, and git grep -i -E 'temporalio|dbos|prefect|temporal(_|\]|durab|")' -- src tests prints nothing.
    • AIDurableConfig, AIConfig.durable and the DEFAULT_AI_DURABLE_* constants are removed with their re-exports, docs/CONFIGURATION.md no longer lists durable, and a configuration that still has an ai.durable block loads without error (test_a_config_file_still_holding_the_removed_ai_durable_block_loads).
    • The six unwired modules are deleted with every test that existed only for them, none skipped or xfailed. A search of src, tests, AGENTS.md, README.md, docs, k8s, .github and pyproject.toml (outside docs/agent/tasks, docs/agent/archive, docs/ROADMAP.md and CHANGELOG.md) for the deleted module paths and public names finds nothing.
    • The import graph from commands/, server/, main and entry reaches no deleted module, and the deleted modules are absent from the tree.
    • The DEP001 ignore list for the three engines is removed from pyproject.toml and uv run deptry src passes; no dependency, extra or uv.lock change.
    • The suppression and swallowed-failure ceilings are no looser than the tree measures for the kinds the deletion changed, docs/ERRORS.md and docs/CONFIGURATION.md are regenerated, and uv run devops docs check reports every file up to date.
    • changelog.d/1121.md lists the engines, the helper functions and the ai.durable keys under ### Removed.
    • ruff check, ruff format --check and mypy pass over src and tests.
    • Pending a person: uv run devops ci passes on the delivering tree. This change ran the targeted tests, not the gate.
  6. added a commit that references this issue on Oct 23, 2026
    f209f6c
  7. removed
    status/in-progress
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p3-lowscope/aiscope/configtype/refactor

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions