Lee-W commented on code in PR #76999:
URL: https://github.com/apache/airflow/pull/76999#discussion_r4596917376
##########
providers/common/ai/src/airflow/providers/common/ai/mixins/cancellable_run.py:
##########
@@ -50,10 +54,25 @@ class CancellableAgentRunMixin:
def run_agent_sync(
self, agent: Agent[Any, Any], user_prompt: Any, **run_kwargs: Any
) -> AgentRunResult[Any]:
- """Call ``agent.run_sync`` under a fresh cancellation token held for
:meth:`on_kill`."""
+ """
+ Call ``agent.run_sync`` under a fresh cancellation token held for
:meth:`on_kill`.
+
+ A ``FallbackExceptionGroup`` from a failed chain is raised again as
+
:class:`~airflow.providers.common.ai.fallback_exceptions.FallbackChainExhaustedError`,
carrying
+ what the durable journal replayed and recorded so far.
+ """
self._cancellation_token = CancellationToken()
try:
return agent.run_sync(user_prompt,
cancellation_token=self._cancellation_token, **run_kwargs)
+ except FallbackExceptionGroup as group:
+ if isinstance(group, FallbackChainExhaustedError):
+ raise
+ journal = current_journal()
Review Comment:
Inside a task `current_journal()` creates the journal on first use, so
non-durable runs got 0/0. The mixin now calls a new `find_active_journal()`,
which returns the journal only if one is already recording and never creates
it, so the fields stay `None` for a non-durable run. I went with reading the
active journal instead of checking `durable` because a run can attach
`AirflowDurability` by hand with `durable=False`, and that journal is
recording. Added the case with a real task context and no journal.
--
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]