fix(py-ext-lightning): log unexpected kernel failures with traceback in step#2169
Merged
imran-siddique merged 1 commit intoMay 12, 2026
Conversation
…in step
`GovernedRunner.step` caught unexpected (non-policy) kernel exceptions in
a bare ``except Exception as e:`` branch and logged them with
``logger.error(f"Execution failed: {e}")``. ``logger.error(msg)``
discards ``exc_info`` — the operator-visible log record shows only the
exception's ``str(e)``, dropping the stack frame information needed to
localise where the kernel failed.
Switch to ``logger.exception("Execution failed")`` so the active
traceback travels with the record (``exc_info`` is automatically set).
The policy-violation branch immediately above is unaffected: it
deliberately logs only the violation description because that branch
catches an *expected* control-flow exception, not an unexpected failure.
Regression test exercises the fallback ``self.agent(input)`` path with
an agent that raises ``RuntimeError`` and asserts that the resulting
log record carries ``exc_info is not None`` (the contract that
``logger.error`` previously violated). Confirmed the test fails against
unfixed source and passes with the fix.
Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Extensions].
🤖 AI Agent: test-generator — `runner.py`
|
🤖 AI Agent: breaking-change-detector — API CompatibilityAPI Compatibility
|
🤖 AI Agent: security-scanner — View detailsNo security issues found. |
🤖 AI Agent: docs-sync-checker — Docs SyncDocs Sync
|
🤖 AI Agent: code-reviewer — View detailsTL;DR: 0 blockers, 0 warnings. No issues found. Clean change. |
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
PR Review Summary
Verdict: ✅ Ready for human review |
MohammadHaroonAbuomar
pushed a commit
to MohammadHaroonAbuomar/agt-acs
that referenced
this pull request
Jun 1, 2026
…in step (microsoft#2169) `GovernedRunner.step` caught unexpected (non-policy) kernel exceptions in a bare ``except Exception as e:`` branch and logged them with ``logger.error(f"Execution failed: {e}")``. ``logger.error(msg)`` discards ``exc_info`` — the operator-visible log record shows only the exception's ``str(e)``, dropping the stack frame information needed to localise where the kernel failed. Switch to ``logger.exception("Execution failed")`` so the active traceback travels with the record (``exc_info`` is automatically set). The policy-violation branch immediately above is unaffected: it deliberately logs only the violation description because that branch catches an *expected* control-flow exception, not an unexpected failure. Regression test exercises the fallback ``self.agent(input)`` path with an agent that raises ``RuntimeError`` and asserts that the resulting log record carries ``exc_info is not None`` (the contract that ``logger.error`` previously violated). Confirmed the test fails against unfixed source and passes with the fix. Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Extensions].
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.
Summary
GovernedRunner.stepcaught unexpected (non-policy) kernel exceptions in a bareexcept Exception as e:branch and logged them with:logger.error(msg)discardsexc_info— the operator-visible log record shows only the exception'sstr(e), dropping the stack frame information needed to localise where the kernel actually failed.Change
Switch to
logger.exception("Execution failed")so the active traceback travels with the record (exc_infois automatically set).The policy-violation branch immediately above is unaffected: it deliberately logs only the violation description because that branch catches an expected control-flow exception (
PolicyViolationError), not an unexpected failure — those are two different log shapes for two different events.Tests
New regression test
TestGovernedRunnerStep::test_step_unexpected_kernel_failure_logs_tracebackexercises the fallbackself.agent(input)path with an agent that raisesRuntimeError("kernel boom")and asserts the resulting log record carriesexc_info is not None.Confirmed the test fails against unfixed source (
exc_info is Nonefromlogger.error) and passes with the fix.Test plan
Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Python Extensions].