Skip to content

fix(gateway): attribute inference calls to traces - #519

Merged
jdchawla29 merged 1 commit into
mainfrom
jaideep/hud-2096-trace-attribution
Jul 29, 2026
Merged

fix(gateway): attribute inference calls to traces#519
jdchawla29 merged 1 commit into
mainfrom
jaideep/hud-2096-trace-attribution

Conversation

@jdchawla29

@jdchawla29 jdchawla29 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

What

  • Attach the ambient SDK trace ID to each OpenAI, Anthropic, and Gemini gateway request.
  • Resolve trace context per request so cached clients remain safe across concurrent rollouts.
  • Keep response automation's instrumented classifier span and synthetic user-step behavior, while including the classifier's gateway cost in trace and job usage.

Why

Provider clients bypass the SDK's normal request helpers, so gateway inference logs were created without trace_id. The platform could charge the owning team, but trace and job usage could not attribute those costs.

The request hook uses the existing SDK trace context rather than requiring callers to manage a separate header contract.

Validation

  • Ruff check and format
  • Strict pyright
  • Focused gateway tests, including an actual async Gemini provider request: 4 passed
  • Broader SDK utility and agent tests: 174 passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c328ef036

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hud/utils/gateway.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9c328ef. Configure here.

Comment thread hud/utils/gateway.py
@jdchawla29
jdchawla29 force-pushed the jaideep/hud-2096-trace-attribution branch from 9c328ef to 9892982 Compare July 29, 2026 03:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9892982d18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hud/utils/gateway.py Outdated
@jdchawla29
jdchawla29 force-pushed the jaideep/hud-2096-trace-attribution branch from 9892982 to 3a7b5ad Compare July 29, 2026 03:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a7b5ad101

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hud/utils/gateway.py
@jdchawla29
jdchawla29 merged commit c064098 into main Jul 29, 2026
8 checks passed
@jdchawla29
jdchawla29 deleted the jaideep/hud-2096-trace-attribution branch July 29, 2026 17:43
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.

1 participant