Repository navigation
Replay an OpenAI Agents SDK agent's completed calls when Airflow retries its task - #74770
Merged
Merged
Conversation
kaxil
force-pushed
the
openai-agents-durable
branch
from
October 15, 2026 12:38
ccb390c to
6a2eaea
Compare
kaxil
force-pushed
the
openai-agents-durable
branch
2 times, most recently
from
October 15, 2026 12:47
76baf91 to
38ad01b
Compare
Lee-W
reviewed
Oct 15, 2026
pankajastro
reviewed
Oct 15, 2026
pankajastro
left a comment
Member
There was a problem hiding this comment.
A few questions, mostly about test coverage and wording in the guide.
Drafted-by: Claude Code (Sonnet 5.5); reviewed by @pankajastro before posting
kaxil
force-pushed
the
openai-agents-durable
branch
from
October 15, 2026 15:06
38ad01b to
4285715
Compare
…ies its task run_durably() and run_durably_sync() run an agent like Runner.run, recording each model call and function tool call in the task's durable journal, the one AgentOperator(durable=True) uses. A retry replays every call that asks what the failed try asked, in order, and runs live from the first that differs. A run the model failed (max turns, malformed output, output guardrail) asks the model again from its last request; an agent called through as_tool replays as one call; server-side conversations are refused because a replay never reaches them.
kaxil
force-pushed
the
openai-agents-durable
branch
from
October 15, 2026 17:48
4285715 to
1002f07
Compare
…ing its error A function tool's exception that failure_error_function turned into text was recorded as the tool's result, so a retry replayed the error and never ran the tool again. Such a call is no longer recorded, as a call that raised is not. The guide now splits what a retry replays from what always runs live, names the journal's storage, and the tests cover unreadable recordings, structured results, sessions, and a tool-raised ModelBehaviorError.
phanikumv
approved these changes
Oct 17, 2026
vatsrahul1001
approved these changes
Oct 17, 2026
1 task done
SameerMesiah97
pushed a commit
to SameerMesiah97/airflow-oss-sm97
that referenced
this pull request
Oct 27, 2026
…ies its task (apache#74770) run_durably() and run_durably_sync() run an agent like Runner.run, recording each model call and function tool call in the task's durable journal, the one AgentOperator(durable=True) uses. A retry replays every call that asks what the failed try asked, in order, and runs live from the first that differs. A run the model failed (max turns, malformed output, output guardrail) asks the model again from its last request; an agent called through as_tool replays as one call; server-side conversations are refused because a replay never reaches them. A function tool's exception that failure_error_function turned into text was recorded as the tool's result, so a retry replayed the error and never ran the tool again. Such a call is no longer recorded, as a call that raised is not. The guide now splits what a retry replays from what always runs live, names the journal's storage, and the tests cover unreadable recordings, structured results, sessions, and a tool-raised ModelBehaviorError.
This was referenced Nov 4, 2026
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.
When a task running an OpenAI Agents SDK agent fails and Airflow retries it, the agent starts again from the prompt: every model call is paid for again and every tool call happens again.
run_durably()/run_durably_sync()take the same arguments asRunner.run/Runner.run_syncand record each model call and function tool call in the task's durable journal, the oneAgentOperator(durable=True)uses. A retry replays every call that asks what the failed try asked, in order, and runs live from the first that differs. Once the run succeeds the recording is deleted.From Airflow 3.3 the journal is kept in the task state store; before that, under
[common.ai] durable_cache_path, as forAgentOperator(durable=True). Stacked on the tracing PR.Design rationale
Model calls are intercepted by wrapping the model, not by run hooks.
RunHooksandAgentHooksreturnNone, so they can observe a call but not replace it, andRunState.to_json()captures a run only at an interruption, not mid-run. The SDK resolves a model fromRunConfig.model, then themodel_providerfor names, then aModelon the agent, sorun_durablywraps the provider and therun_configmodel and clones the agent graph (followinghandoffs) to wrapModelinstances and function tools. This is the same interception point the SDK's Temporal integration uses.A replayed call has to turn into the same next request as the live one did. Each request is fingerprinted from the model, instructions, conversation, settings, tools (with descriptions and strictness), output schema, handoffs and prompt, and four things keep that stable across a replay:
exclude_unset), andNonefields are left out of the fingerprint. Otherwise replayed items carry explicitnulls the live ones do not, and every request after the first replay mismatches.ToolOutput*content as it is, anything else asstr(output). Recording a Pydantic model, tuple or datetime as JSON would replay as different text.prompt_cache_keythe SDK generates once per run is left out of the settings.An agent used through
as_toolis one recorded call. Its own model calls run inside the outer tool call, so they run live rather than taking positions of the outer run; the outer call replays whole.A run the model failed asks the model again. For
MaxTurnsExceeded,ModelBehaviorError,ModelRefusalErrorand output or tool-input guardrail tripwires the recorded answers would replay into the same failure, so the journal reruns from the model's last request.Server-side conversations are refused.
previous_response_id,conversation_idandauto_previous_response_idkeep the conversation on OpenAI's servers, which a replayed call never reaches, sorun_durablyraisesValueErrorfor them.Known issues
mcp_serverstools, shell and computer tools), a function tool whoseneeds_approvalis a function (the SDK checks the approved arguments only through its own invoker, so wrapping it would weaken that check), an agent reached throughhandoff()unless its model is given by name, and streamed runs. Asessionmakes every retry run live. The guide lists all of these.ModelBehaviorErrorthat a tool raises, such as arguments failing validation withfailure_error_function=None, counts as the tool's failure: the tool reruns, but the answer that asked for it replays.result.last_agentback intorun_durablywraps it twice; the wrapped model provider is not closed whenrun_configis omitted, which matters only for the 0.23 websocket transport; a dictrun_configis not accepted.{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.