← Back to Pull requests

feat(core): send explicit cancelled/interrupted run status from tracer #41785

Open
unknown opened this pull request with 206 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 10, 2026 16:20 UTC
Author

LangChainTracer now sends an explicit run status (cancelled / interrupted) alongside the error text, so a deliberate stop is no longer indistinguishable from a failure. Closes LIN-734 (core tracer part).

exception ending the run                        status sent     error text
-------------------------------------------     -----------     ----------
CancelledError(ExpectedCancellation(...))   ->  cancelled       kept
GraphBubbleUp subclass (GraphInterrupt, ...) -> interrupted     kept
bare CancelledError / timeout / any other   ->  (none)         kept  (stays an error)

  • New marker langchain_core.exceptions.ExpectedCancellation (from #41663): cancel with task.cancel(msg=ExpectedCancellation("reason")). Subclasses count as marked.

  • GraphBubbleUp subclasses are matched by class name, so core takes no langgraph dependency.

  • The status always matches the last error recorded on the run, so a cancel after a real error (or the reverse) cannot leave a stale status.

  • On Python < 3.11 the cancel message is dropped at task boundaries, so the marker is also looked up on __context__ there only.
  • Minimum langsmith version: the status is only set when the installed langsmith RunTree has a status field (first release that adds it; none published yet). Older versions are untouched and keep today's behavior. The pyproject.toml floor is not bumped.

    Release note


    LangChainTracer marks runs cancelled with ExpectedCancellation as cancelled and graph interrupts as interrupted (needs a langsmith release with status support).

    🤖 Generated with Claude Code

    Diff: 206 lines (+154 / -52) across 2 files Reviewer: mangeshraut712 Review duration: 10029m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 206 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.319
    Real PR Conversation Timeline
    1 comments
    "Review active on #41785"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.4% (MEDIUM) · Higher = larger blast radius
    36.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.4% · Safe to merge
    19.4%