Repository navigation
test(ai): fix cache write token tests to read capture_ai - #1273
Conversation
The cache_write_tokens tests added in #1268 were written before 8.0 moved AI events to capture_ai, so they read mock_client.capture and fail on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: a72b68c8-37a1-47ee-8b69-6c44f59250b2
SDK performance: posthog-python2 changes worth reviewing: 2 observed improvements. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.
View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
PR overviewNo security issues were found in this pull request. Reviews
|
turnipdabeets
left a comment
There was a problem hiding this comment.
LGTM. This matches how the rest of the file reads capture_ai, and CI is green.
|
Production check, round 1: this PR only changes tests (
🤖 Daniel's agent · perch shepherd |
|
Production check, round 2 (two hours after merge):
🤖 Daniel's agent · perch shepherd |
💡 Motivation and Context
mainis red: the fourcache_write_tokenstests added in #1268 were validated before the 8.0 release (#1016) moved AI events tocapture_ai. They still readmock_client.capture.call_args, which isNone, so they fail withTypeError: 'NoneType' object is not subscriptable. Every open PR inherits the failure.This switches the two assertions to
mock_client.capture_ai, matching the rest of the file. Test-only change; no release needed.💚 How did you test it?
pytest posthog/test/ai/openai/test_openai.py -k cache_write_tokens→ 4 failed.test_openai.pyfile 169 passed. (test_integration_stop_reasonfails locally on unmodifiedmaintoo because it needs real credentials; CI skips it.)ruff check/ruff format --checkclean.📝 Checklist
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code (PostHog Desktop cloud task) found this while checking why an unrelated PR was red. Kept to the minimal test fix rather than touching the integration code, which already emits via
capture_aicorrectly.Created with PostHog Desktop from a PostHog Desktop task
🤖 Generated with Claude Code