Skip to content

fix(agent): pin SDK background model to stop retired-snapshot 404s#757

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/pin-sdk-background-model
Draft

fix(agent): pin SDK background model to stop retired-snapshot 404s#757
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/pin-sdk-background-model

Conversation

@posthog

@posthog posthog Bot commented Jun 29, 2026

Copy link
Copy Markdown

Problem

The wizard's Claude Agent SDK kept calling Anthropic's retired claude-3-5-haiku-20241022 for background work, which the PostHog LLM gateway doesn't serve — 203 failed generations across 17 users since 06-15, 100% not_found_error, still failing. The main query pins the primary model (claude-sonnet-4-6), but never pins the SDK's separate small/fast background model, so background operations (topic detection, summarization, quota probes) fell back to the SDK's built-in default snapshot. The failure is silent — those rows carry no $ai_http_status, so it only surfaces in AI observability. The core integration flow keeps working (the main model succeeds); only background features degrade. (Same gap explains the smaller claude-sonnet-4-20250514 and claude-3-7-sonnet-20250219 buckets.)

Changes

Pin the SDK's background/default model env vars in the same env: block that already drops ANTHROPIC_API_KEYANTHROPIC_DEFAULT_HAIKU_MODEL (+ legacy ANTHROPIC_SMALL_FAST_MODEL) and ANTHROPIC_DEFAULT_SONNET_MODEL — to gateway-supported bare aliases (claude-haiku-4-5, claude-sonnet-4-6). Added a DEFAULT_HAIKU_MODEL constant (bare alias, matching the existing DEFAULT_AGENT_MODEL convention) so the gateway's strict Bedrock lookup matches and the SDK can never reach for a retired snapshot.

Test plan

pnpm build && pnpm test && pnpm fix — all 1027 unit tests pass, lint clean.

LLM context

Authored by PostHog Code (Claude). Root-caused from the AI-observability error buckets and fixed by pinning the SDK background model env vars.


Created with PostHog Code from an inbox report.

The main query() pins the primary model (claude-sonnet-4-6), but never
pins the Claude Agent SDK's separate small/fast background model. For
background work (topic detection, summarization, quota probes) the SDK
falls back to its built-in default — a retired claude-3-5-haiku snapshot
the PostHog LLM gateway doesn't serve — so every such call 404s with
not_found_error. It's silent: those rows carry no $ai_http_status.

Pin ANTHROPIC_DEFAULT_HAIKU_MODEL / ANTHROPIC_SMALL_FAST_MODEL (legacy)
and ANTHROPIC_DEFAULT_SONNET_MODEL in the SDK env block to
gateway-supported bare aliases so the SDK can't reach for a retired id.

Generated-By: PostHog Code
Task-Id: fbe62d08-5ad3-45c2-b9e5-fdc735a3d728
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci mcp-analytics
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/cicd-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-nested-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-single-stage-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-gitlab-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-pnpm-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-raw-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-ssh-vps-node-raw
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants