kaxil opened a new pull request, #73873: URL: https://github.com/apache/airflow/pull/73873
With `durable=True`, `AgentOperator` caches each model response and tool result so that a retry replays them instead of running them again. Some results cannot be cached: a tool that returns a value that is not JSON-serializable (for example `BinaryContent` from an MCP tool), or a task state store write that fails. The step still succeeds, but a retry runs it live again, so a tool with side effects repeats them. Before this change, nothing said which tool that was. The backend logged a warning with the cache key (`key=__commonai_durable__tool_step_1`), the caching wrappers counted the step as cached anyway, and the end-of-run summary was only logged after a successful run, which does not retry and deletes its cache straight after. The failed attempt, the one Airflow retries, never named the tool that would run again. Now: - `save_model_response` and `save_tool_result` return whether they wrote the entry. `DurableStepCounter` records skipped model responses and the names of skipped tools, so `cached_*` counts only steps a retry will replay. - Each skipped write logs a warning with the tool name and step, whether the run goes on to succeed or fail. - `AgentOperator` logs the durable summary from a `finally` block, so a failed attempt gets it too, and the summary lists every tool that was not cached. **The warnings say later steps may re-run as well.** A skipped model response re-runs live on retry and returns fresh tool call ids, which changes the fingerprint of every step after it. A skipped tool that returns different content on its re-run does the same to the next model request. Naming only the skipped step would understate what a retry repeats. **The storage protocol's `save_*` return type changes from `None` to `bool`.** Both backends in the provider are updated, and the only place a backend is constructed is `AgentOperator._build_durable_storage`, so there is no outside implementation to break. Run end to end on a local Airflow 3.4.0 (task state store backend) with an agent that has two tools: `render_chart` returns `BinaryContent`, and `publish_report` fails on the first try. The task has `retries=1`. On try 1, which fails, line 11 is the new per-step warning naming `render_chart`, and lines 14 and 15 are the summary, logged before the task fails:  On try 2, the model step replays from the cache and `render_chart` runs again (line 9), as the warning said it would:  -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
