Repository navigation
fix(ai): mark cancelled async LLM calls as errors - #1065
Merged
Merged
Conversation
Contributor
posthog-python Compliance ReportDate: 2026-10-15T16:31:38.103205+00:00 ✅ All Tests Passed!121/121 tests passed Capture_V1 Tests✅ 95/95 tests passed View Details
Capture_Ai Tests✅ 5/5 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
Feature_Flags_Local_Evaluation Tests✅ 4/4 tests passed View Details
|
turnipdabeets
approved these changes
Oct 15, 2026
There was a problem hiding this comment.
Approved.
The telemetry write-path change has independent assurance from current-head reviews and focused regression coverage. No unresolved substantive concerns or other refusal grounds were found.
- Author wrote 0% of the modified lines and has 61 merged PRs in these paths (familiarity MODERATE).
- PostHog Review (Standard) reviewed the current head: no findings.
- posthog[bot], turnipdabeets reviewed the current head.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 8L, 1F substantive, 129L/5F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (129L, 5F, two-areas, fix) |
| stamphog 2.5.1 | .stamphog/policy.yml @ cef2f80 · reviewed head cef2f80 |
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.
💡 Motivation and Context
Fixes #1064.
Cancelled async LLM calls currently emit
$ai_generationwith HTTP status 200 and no error fields. This counts cancelled requests as successful generations and includes their timeout latency in successful-call metrics.The shared non-streaming helper now handles
asyncio.CancelledErrorexplicitly. It captures status 0,$ai_is_error: true, and$ai_error: "cancelled", then re-raises the original cancellation. Ordinary provider errors keep their existing behavior. Streaming and synchronous calls are unchanged.The published
capture-aiSDK spec does not define cancellation classification. This change does not alter the public API or the spec's capture contract.💚 How did you test it?
wait_forstill raisesTimeoutErrorand the generation is marked as an error.cef2f8038f21bfefdf2b0f8e8691cad24e623849againstorigin/mainreported no actionable findings.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi using GitHub CLI, uv/pytest, Ruff, mypy, Sampo, and autoreview. The investigation and fix used the same isolated worktree. The implementation catches only
asyncio.CancelledError, rather than broadening exception handling to allBaseExceptionsubclasses. Human review is required.