agentleFS
PydanticKnown publisherpydantic/pydantic-ai/pydantic_ai_slim/pydantic_ai/durable_exec/AGENTS.md

pydantic-ai / durable_exec

AGENTS.md20k starsChanged 2 months agoMITView on GitHub

Durable execution integrations are first-class compatibility targets. Build new integrations on the public pydantic_ai.durable_exec surface. Subclass BaseDurabilityCapability for the agent-facing capability and provide a DurableOperationBackend from get_durable_operation_backend. Do not copy the model, toolset, event, or capability-operation collection machinery into the integration. Choose the backend tier from the engine SDK's execution model: - Subclass CallableOperationBackend when the SDK accepts an async callback at invocation time. Implement execute to run that callback in one named durable unit. The base owns parameter and…

Trending

Less talk lately.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 2 mentionsApr 2026: 29 mentionsMay 2026: 2 mentionsJun 2026: 2 mentionsJul 2026: 3 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the pydantic/pydantic-ai repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about pydantic/pydantic-ai

The biggest 5 of 64 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 64

Talked about on GitHub, Bluesky, Hacker News and the web (64 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 7

2 more on Bluesky

On Hacker News · 5

On the web · 2

The file

We split this AGENTS.md into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat Temporal, DBOS, Prefect, Restate, and similar engines as compatibility checks for core agent semantics, not peripheral adapters.

    line 5
  2. Distinctive:

    Avoid hidden ordering assumptions, non-serializable state, and runtime-only closures unless the durable wrapper explicitly owns them.

    line 7
  3. Very specific:

    Prefer generic capabilities/toolsets/models extension points over engine-specific escape hatches.

    line 8
  4. Very specific:

    When changing graph/tool/output/streaming/MCP behavior, check whether durable wrappers need matching updates and add workflow-level tests …

    line 9

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

durable_exec/ Guidelines

Durable execution integrations are first-class compatibility targets.

  • Treat Temporal, DBOS, Prefect, Restate, and similar engines as compatibility checks for core agent semantics, not peripheral adapters.
  • Preserve run context, dependencies, message history, retries, model/profile selection, and toolset lifecycle across durable boundaries.
  • Avoid hidden ordering assumptions, non-serializable state, and runtime-only closures unless the durable wrapper explicitly owns them.
  • Prefer generic capabilities/toolsets/models extension points over engine-specific escape hatches.
  • When changing graph/tool/output/streaming/MCP behavior, check whether durable wrappers need matching updates and add workflow-level tests where external runtime behavior matters.
  • Sync stream (run_stream_sync) inherits via self.run_stream; missing wrapper override is intentional — workflows are async and SyncStreamBridge rejects a running event loop.

Building a new durable execution engine

Build new integrations on the public pydantic_ai.durable_exec surface. Subclass BaseDurabilityCapability for the agent-facing capability and provide a DurableOperationBackend from get_durable_operation_backend. Do not copy the model, toolset, event, or capability-operation collection machinery into the integration.

Choose the backend tier from the engine SDK's execution model:

  • Subclass CallableOperationBackend when the SDK accepts an async callback at invocation time. Implement execute to run that callback in one named durable unit. The base owns parameter and result transport, cache identity, naming, and config resolution.
  • Subclass RegisteredOperationBackend when handlers must be registered before a worker starts. Implement register to return the bound caller and all SDK registration handles. Expose those registrations from the engine capability without rebuilding or reordering them. The base binds the four model operations during agent assembly, so registrations() is complete before worker start; pass the collected registrations to the engine SDK when creating the worker.

Set the public engine_spec once using DurabilityEngineSpec. Declare the engine name, durable unit noun, durable container noun, codec, unsupported runtime toolset kinds, wrapped toolset kinds, toolset lifecycles, tool-call result upgrade policy, discovery policy, sequential tool policy, and tool config key deliberately. Use IDENTITY_CODEC when the engine SDK serializes Python values itself. Use JSON_CODEC when the integration must reduce values to JSON-compatible payloads before journaling them.

Persisted operation names are compatibility data, independent of Python class names. Prefer JournalOperationNamer when its convention fits. Otherwise implement DurableOperationNamer and keep its output stable. Before refactoring agent, model, toolset, or capability identity, pin the complete name set using the tests/durable_exec/test_durable_exec_compat.py pattern. Never update those pins as part of an implementation rename unless the migration of in-flight executions is intentional and reviewed.

Resolve base and per-tool configuration with OperationConfigRole and DurableOperationId. Handle known ID variants and retain a default branch because the public union grows in minor releases. The union includes model requests, suspended-response cancellation, message compaction, event handling, discovery, validation, calls, and CapabilityOperationId. Capability methods marked with @durable_operation arrive through the same backend and config resolver as framework operations, so do not maintain a second registration path for them.

A toolset the run holds reaches the durable unit through the run context, so an engine that serializes it (or dispatches the unit elsewhere) sees none and the unit enters its own, as every unit did before. When a unit does reach one, it enters that toolset on first use and leaves it entered for the run, which the durable container closes: that is the deliberate exception to the rule below, and it is what lets an MCPToolset hold one session per run instead of one per unit. Declare it with the 'enter-in-durable-unit' lifecycle, which is only for engines whose units run in the container's own process; connecting still happens inside a unit, so the engine retries it. A DynamicToolset built with per_run_step=False is held the same way, except that the run resolves it first: that factory runs in container code, so it carries the same determinism requirement as every other factory that runs there.

Workspaces are routed by the base, not by engines: when a construction-time capability overrides get_workspace, _bind_workspace_operation binds one operation, CapabilityOperationId('workspace', operation='call'), configured and retried like any capability operation (bind nothing otherwise, so agents without a supplier keep their pinned names). _prepare_workspace installs a DurableWorkspace around the selected workspace inside the container; each of its calls, ensure included, is one WorkspaceCall. The WorkspaceEnsurer companion runs ensure before the run body, with a locked lazy fallback on first call, so parallel units share one environment. Inside a unit, _unit_workspace gives the call the plain workspace: the live one in-process, or on Temporal the one rebuilt from the serialized ref. Expected workspace errors cross as data and are re-raised with their original type; Temporal lists WorkspaceError as a workflow-failure type; an uncaught builtin error keeps Temporal's default and fails the workflow task.

Assume a durable unit may execute more than once if the process fails after the side effect but before its checkpoint commits. Document the engine's guarantees and require idempotency or expose an engine-native at-most-once option where available. Keep workflow-side code deterministic. Enter and close toolset resources according to engine_spec.toolset_lifecycles, including failure and cancellation paths, and verify that resources created inside a durable unit do not escape it. Test replay, teardown, control-flow exceptions, persisted-output upgrades, and behavior outside the durable context in the engine's own suite.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.