Skip to content

Add include_traceback to model-backed retry policies - #74308

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:retry-policy-include-traceback
Oct 6, 2026
Merged

kaxil merged 1 commit into
apache:mainfrom
astronomer:retry-policy-include-traceback

Conversation

@kaxil

@kaxil kaxil commented Oct 5, 2026

Copy link
Copy Markdown
Member

LLMRetryPolicy and ClassifierRetryPolicy send the model only ExceptionType: message. That drops the exception chain, the stack and the module-qualified class name, which are often what says whether another attempt can succeed. A JSONDecodeError raised while handling a truncated read looks like bad data, so a model may say "stop", though the chained transport error underneath makes it a network failure a retry can fix.

include_traceback=True sends the output of traceback.format_exception() instead. The default is unchanged.

ClassifierRetryPolicy(
    llm_conn_id="jev_default",
    categories=CATEGORIES,
    include_traceback=True,
)

Design points:

  • Redact first, then truncate, on the whole formatted traceback, so a registered secret can't be cut in half. That's the same order the message path already uses.
  • A long traceback keeps its tail (with a leading (truncated) ... marker): the innermost frames and the final exception line say the most. The message path still keeps the head.
  • Opt-in, because it sends more to the model: messages of chained exceptions, file paths on the worker, the source line of each frame, and more input tokens per classification. The docs warning now says so. Frame local variables are never included.

The single-argument traceback.format_exception(exc) form needs Python 3.10, which is the provider's floor.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

LLMRetryPolicy and ClassifierRetryPolicy send the model only "ExceptionType: message", so the exception chain, the stack, and module-qualified class names never reach it. A JSONDecodeError raised while handling a truncated read looks like bad data, though the chained transport error makes it a retryable network failure.

include_traceback=True sends traceback.format_exception() output instead, redacted as a whole and then truncated to max_exception_length keeping the tail, where the innermost frames and the final exception line are. The default is unchanged.
@kaxil
kaxil merged commit 246e3b2 into apache:main Oct 6, 2026
85 checks passed
@kaxil
kaxil deleted the retry-policy-include-traceback branch October 6, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants