Skip to content

@posthog/ai doesn't handle background: true and sets cost/token to 0 #2957

@maximedupre

Description

@maximedupre

Bug description

If we make a call with background: true, e.g.

	let res = await client.responses.parse({
		background: true,
        ...
  1. The initial client.responses.parse() call returns immediately with status: 'queued' and 0 tokens
  2. PostHog captures this initial response → logs $ai_generation event with 0 input/output tokens
  3. No polling until the actual response is received

Related sub-libraries

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react
  • @posthog/ai
  • @posthog/nextjs-config
  • @posthog/nuxt
  • @posthog/rollup-plugin
  • @posthog/webpack-plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions