-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Let TemporalAgents be registered to a Temporal workflow using __pydantic_ai_agents__ field
#3676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DouweM
merged 9 commits into
pydantic:main
from
adtyavrdhn:simple_temporal_agent_registration
Dec 12, 2025
+273
−20
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
64eb828
Adding simple registration to TemporalAgent
adtyavrdhn 73bee58
Adding casette
adtyavrdhn 98b3670
Merge branch 'main' of https://github.com/pydantic/pydantic-ai into s…
adtyavrdhn 3056478
fixing comments
adtyavrdhn 854b117
docs
adtyavrdhn af7b1d0
Merge branch 'main' of https://github.com/pydantic/pydantic-ai into s…
adtyavrdhn f2163fc
file rename for casette
adtyavrdhn 14370c3
Adding type checks
adtyavrdhn d6375ed
addressing comments, fixes docstring, adds typechecks, adds test
adtyavrdhn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
10 changes: 10 additions & 0 deletions
10
pydantic_ai_slim/pydantic_ai/durable_exec/temporal/_workflow.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from collections.abc import Sequence | ||
| from typing import Any | ||
|
|
||
| from pydantic_ai.durable_exec.temporal import TemporalAgent | ||
|
|
||
|
|
||
| class PydanticAIWorkflow: | ||
| """Temporal Workflow base class that provides `__pydantic_ai_agents__` for direct agent registration.""" | ||
|
|
||
| __pydantic_ai_agents__: Sequence[TemporalAgent[Any, Any]] |
79 changes: 79 additions & 0 deletions
79
tests/cassettes/test_temporal/test_passing_agents_through_workflow.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| interactions: | ||
| - request: | ||
| headers: | ||
| accept: | ||
| - application/json | ||
| accept-encoding: | ||
| - gzip, deflate | ||
| connection: | ||
| - keep-alive | ||
| content-length: | ||
| - '105' | ||
| content-type: | ||
| - application/json | ||
| host: | ||
| - api.openai.com | ||
| method: POST | ||
| parsed_body: | ||
| messages: | ||
| - content: What is the capital of Mexico? | ||
| role: user | ||
| model: gpt-4o | ||
| stream: false | ||
| uri: https://api.openai.com/v1/chat/completions | ||
| response: | ||
| headers: | ||
| access-control-expose-headers: | ||
| - X-Request-ID | ||
| alt-svc: | ||
| - h3=":443"; ma=86400 | ||
| connection: | ||
| - keep-alive | ||
| content-length: | ||
| - '838' | ||
| content-type: | ||
| - application/json | ||
| openai-organization: | ||
| - pydantic-28gund | ||
| openai-processing-ms: | ||
| - '403' | ||
| openai-project: | ||
| - proj_dKobscVY9YJxeEaDJen54e3d | ||
| openai-version: | ||
| - '2020-10-01' | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains; preload | ||
| transfer-encoding: | ||
| - chunked | ||
| parsed_body: | ||
| choices: | ||
| - finish_reason: stop | ||
| index: 0 | ||
| logprobs: null | ||
| message: | ||
| annotations: [] | ||
| content: The capital of Mexico is Mexico City. | ||
| refusal: null | ||
| role: assistant | ||
| created: 1754675179 | ||
| id: chatcmpl-C2LSVwAtcuMjKCHykKXgKphwTaQVB | ||
| model: gpt-4o-2024-08-06 | ||
| object: chat.completion | ||
| service_tier: default | ||
| system_fingerprint: fp_ff25b2783a | ||
| usage: | ||
| completion_tokens: 8 | ||
| completion_tokens_details: | ||
| accepted_prediction_tokens: 0 | ||
| audio_tokens: 0 | ||
| reasoning_tokens: 0 | ||
| rejected_prediction_tokens: 0 | ||
| prompt_tokens: 14 | ||
| prompt_tokens_details: | ||
| audio_tokens: 0 | ||
| cached_tokens: 0 | ||
| total_tokens: 22 | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
79 changes: 79 additions & 0 deletions
79
...ttes/test_temporal/test_passing_agents_through_workflow_without_pydantic_ai_workflow.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| interactions: | ||
| - request: | ||
| headers: | ||
| accept: | ||
| - application/json | ||
| accept-encoding: | ||
| - gzip, deflate | ||
| connection: | ||
| - keep-alive | ||
| content-length: | ||
| - '105' | ||
| content-type: | ||
| - application/json | ||
| host: | ||
| - api.openai.com | ||
| method: POST | ||
| parsed_body: | ||
| messages: | ||
| - content: What is the capital of Mexico? | ||
| role: user | ||
| model: gpt-4o | ||
| stream: false | ||
| uri: https://api.openai.com/v1/chat/completions | ||
| response: | ||
| headers: | ||
| access-control-expose-headers: | ||
| - X-Request-ID | ||
| alt-svc: | ||
| - h3=":443"; ma=86400 | ||
| connection: | ||
| - keep-alive | ||
| content-length: | ||
| - '838' | ||
| content-type: | ||
| - application/json | ||
| openai-organization: | ||
| - pydantic-28gund | ||
| openai-processing-ms: | ||
| - '403' | ||
| openai-project: | ||
| - proj_dKobscVY9YJxeEaDJen54e3d | ||
| openai-version: | ||
| - '2020-10-01' | ||
| strict-transport-security: | ||
| - max-age=31536000; includeSubDomains; preload | ||
| transfer-encoding: | ||
| - chunked | ||
| parsed_body: | ||
| choices: | ||
| - finish_reason: stop | ||
| index: 0 | ||
| logprobs: null | ||
| message: | ||
| annotations: [] | ||
| content: The capital of Mexico is Mexico City. | ||
| refusal: null | ||
| role: assistant | ||
| created: 1754675179 | ||
| id: chatcmpl-C2LSVwAtcuMjKCHykKXgKphwTaQVB | ||
| model: gpt-4o-2024-08-06 | ||
| object: chat.completion | ||
| service_tier: default | ||
| system_fingerprint: fp_ff25b2783a | ||
| usage: | ||
| completion_tokens: 8 | ||
| completion_tokens_details: | ||
| accepted_prediction_tokens: 0 | ||
| audio_tokens: 0 | ||
| reasoning_tokens: 0 | ||
| rejected_prediction_tokens: 0 | ||
| prompt_tokens: 14 | ||
| prompt_tokens_details: | ||
| audio_tokens: 0 | ||
| cached_tokens: 0 | ||
| total_tokens: 22 | ||
| status: | ||
| code: 200 | ||
| message: OK | ||
| version: 1 |
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
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.
Uh oh!
There was an error while loading. Please reload this page.