Repository navigation
Conversation
… raises Flow.chat() temporarily enables defer_trace_finalization and restores its previous value in a finally block. finalize_session_traces() was called before the restoration, so if it raised, a reused Flow instance retained the temporary setting. Wrap finalization in a try/finally so the previous value is restored even when finalization raises, while still propagating the error. Fixes crewAIInc#8069
Strix Security Review✅ No open security findings. PR summary: Fixes `Flow.chat()` so that the temporary `defer_trace_finalization` flag is restored even when trace finalization raises, by wrapping `finalize_session_traces()` in an additional `try/finally`. The finalization error is still propagated. Review summaryReview of the single changed hunk in Review 1 on this PR · Reviewed by Strix |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
Fixes #8069.
Flow.chat()temporarily enablesdefer_trace_finalizationand restores its previous value in afinallyblock.finalize_session_traces()was called before the restoration, so if it raised, a reusedFlowinstance retained the temporary setting.Wrap finalization in a
try/finallyso the previous value is restored even when finalization raises, while still propagating the error.Reproduction
Before fix:
before: False,RuntimeError: finalization failed,after: True.After fix:
before: False,RuntimeError: finalization failed,after: False.Tests
test_flow_conversation.py(174 passed).Scope
Only touches the existing
chat()cleanup. No new session manager, retry loop, or tracing API; finalization errors are not suppressed.Note
Low Risk
Single cleanup-path change in conversational
chat()with no behavior change when finalization succeeds.Overview
Fixes a cleanup bug in
Flow.chat()whenfinalize_session_traces()fails at the end of the REPL loop.chat()temporarily setsdefer_trace_finalizationand is supposed to restore the previous value in afinallyblock. Previously, restoration ran in the samefinallyafter finalization, so if finalization raised, the flag stayedTrueon a reused flow instance.The change nests
try/finallyso the priordefer_trace_finalizationvalue is always restored; finalization errors still propagate unchanged.Reviewed by Cursor Bugbot for commit d7d57c0. Bugbot is set up for automated code reviews on this repo. Configure here.