Add durability capabilities for Temporal, DBOS, and Prefect#4977
Draft
Add durability capabilities for Temporal, DBOS, and Prefect#4977
Conversation
…s, ReplayStreamedResponse Foundation for porting TemporalAgent/DBOSAgent/PrefectAgent to capabilities: - Add `toolset_id: str | None` to ToolDefinition, auto-populated from toolset in CombinedToolset.get_tools() — enables per-toolset config in capability hooks - Add `wrap_get_tools(ctx, *, toolset, handler)` hook to AbstractCapability — allows capabilities to intercept tool listing I/O (e.g. MCP list_tools) - Add `ReplayStreamedResponse` that converts a completed ModelResponse into synthetic PartStart/PartDelta/PartEnd events — enables transparent streaming when wrap_model_request short-circuits - Use ReplayStreamedResponse in _agent_graph.py streaming short-circuit path (replaces _SkipStreamedResponse which yielded no events) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…y hooks Introduces TemporalDurability, an AbstractCapability that routes model requests and tool execution through Temporal activities using the capability hook system (wrap_model_request, wrap_run, get_wrapper_toolset) instead of requiring WrapperAgent/WrapperModel subclasses. - wrap_model_request: intercepts model calls inside workflows, serializes request context, and routes to request_activity or request_stream_activity - wrap_run: disables threads and catches PydanticSerializationError in workflows - get_wrapper_toolset: swaps leaf toolsets with pre-created Temporal wrappers - Model registry with identity + model_id string matching - DurabilityPlugin for worker activity registration - Rename _RequestParams → RequestParams for cross-module sharing - Fix ReplayStreamedResponse type narrowing for PartStartEvent.index Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
271c5f8 to
1e8bbd1
Compare
Contributor
Docs Preview
|
ec1b2f4 to
a9b627e
Compare
…for toolset_id - DBOSDurability: routes model requests through @dbos.step(), wraps MCP toolsets - PrefectDurability: routes model requests through @task, wraps toolsets via prefectify_toolset - Both are transparent outside their respective workflow/flow contexts - Fix OpenAIModel → OpenAIChatModel in docstring examples - Update snapshots for new toolset_id field on ToolDefinition - Update docs examples output for toolset_id Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a9b627e to
af54121
Compare
Capabilities can now declare ordering constraints via `get_ordering()`: - `position='outermost'`: must be first in the middleware chain (e.g. instrumentation) - `position='innermost'`: must be last, closest to handler (e.g. durability) - `before`/`after`: relative ordering between specific capability types - `requires`: assert another capability type is present CombinedCapability auto-sorts in __post_init__ when any child declares constraints. Uses Kahn's algorithm with original-index tiebreaking for stability. Zero overhead when no constraints exist. All three durability capabilities declare position='innermost'. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lication
- Change TemporalDurability from `models={'default': m}` to `model=m`
with optional `models` dict for additional runtime models
- Add `get_toolset()` to all three durability capabilities so the agent
automatically picks up toolsets — no need to pass them separately
- Expose `durability.model` so users can write `Agent(model=durability.model)`
- Update tests and docstring examples for the cleaner API
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TemporalDurabilitycapability that routes model requests and tool execution through Temporal activities using capability hooks (wrap_model_request,wrap_run,get_wrapper_toolset) instead of requiringWrapperAgent/WrapperModelsubclassesDBOSDurabilityandPrefectDurability— TODO, in progressDurabilityPluginfor Temporal worker activity registrationRequestParamstype (renamed from_RequestParams) for cross-module useReplayStreamedResponsetype narrowing forPartStartEvent.indexTest plan
TemporalDurability(workflow integration, tool wrapping, passthrough, validation, model registry)DBOSDurabilitycapability + testsPrefectDurabilitycapability + tests🤖 Generated with Claude Code