Skip to content

Fix openAI telemetry response attributes use the request namespace type - #7126

Merged
tim-smart merged 3 commits into
mainfrom
audit/repro-b206fa5d76-openai-telemetry-response-namespace
Aug 8, 2026
Merged

Fix openAI telemetry response attributes use the request namespace type#7126
tim-smart merged 3 commits into
mainfrom
audit/repro-b206fa5d76-openai-telemetry-response-namespace

Conversation

@fubhy

@fubhy fubhy commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Correct OpenAI response telemetry attribute types to use the gen_ai.openai.response namespace emitted by the runtime helpers.
  • Apply the fix to both @effect/ai-openai and @effect/ai-openai-compat.
  • Add a patch changeset for both packages.

Validation

  • pnpm test --run packages/ai/openai/test packages/ai/openai-compat/test
  • pnpm --filter @effect/ai-openai --filter @effect/ai-openai-compat check
  • pnpm check
  • pnpm lint

Audit provenance

  • Audit base: b206fa5d7655c1634c9993410a9203f6616a5ca2
  • Finding: relsem-openai-telemetry-response-namespace

Closes EFF-560

@fubhy fubhy added the audit Findings originating from the Effect runtime correctness audit label Aug 7, 2026
@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 876e03d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@effect/ai-openai Patch
@effect/ai-openai-compat Patch
effect Patch
@effect/ai-anthropic Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node Patch
@effect/platform-node-shared Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/vitest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-slopcop effect-slopcop Bot added 4.0 bug Something isn't working labels Aug 7, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

This PR currently contains only the reproduction test; the implementation fix it describes is missing. The added test is correct and fails as expected, but the branch needs the source change before it can merge.

Reviewed changes

This PR adds a type-level regression test in packages/ai/openai/typetest/OpenAiTelemetry.tst.ts asserting that OpenAiTelemetryAttributes accepts gen_ai.openai.response.system_fingerprint and rejects the gen_ai.openai.request.* variant. I verified the test fails against the current implementation.

⚠️ Implementation fix is missing

packages/ai/openai/src/OpenAiTelemetry.ts:32 still prefixes ResponseAttributes with "gen_ai.openai.request" instead of "gen_ai.openai.response". The runtime helpers on lines 126-127 already emit the correct response namespace, so the type-level alias is inconsistent with runtime behavior. The fix is the single-line change noted in the PR body.

⚠️ Same bug in @effect/ai-openai-compat

packages/ai/openai-compat/src/OpenAiTelemetry.ts:31 has the identical copy-paste error. Since the two modules mirror each other and both runtime paths already use "gen_ai.openai.response", the compat package should be fixed and covered by an analogous type test.

ℹ️ Changeset

Once the source changes land, add a changeset for the affected packages (they are in the same fixed release group).

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

The latest commit completes the fix started in the first commit and resolves all feedback from the previous review.

  • Applied the source fix to both packagesOpenAiTelemetryAttributes in @effect/ai-openai and @effect/ai-openai-compat now prefixes ResponseAttributes with "gen_ai.openai.response" instead of "gen_ai.openai.request", aligning the type with the runtime helpers.
  • Added matching type-level regression tests in packages/ai/openai/typetest/OpenAiTelemetry.tst.ts and packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts, asserting that gen_ai.openai.response.system_fingerprint is assignable and gen_ai.openai.request.system_fingerprint is not.
  • Added a patch changeset covering both packages in the same release group.

Validation run: type tests, package runtime tests, package check, and repo lint all pass.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.92 KB 6.92 KB 0.00 KB (0.00%)
batching.ts 9.72 KB 9.72 KB 0.00 KB (0.00%)
brand.ts 6.60 KB 6.60 KB 0.00 KB (0.00%)
cache.ts 10.59 KB 10.59 KB 0.00 KB (0.00%)
config.ts 20.88 KB 20.88 KB 0.00 KB (0.00%)
differ.ts 19.74 KB 19.74 KB 0.00 KB (0.00%)
http-client.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
logger.ts 10.81 KB 10.81 KB 0.00 KB (0.00%)
metric.ts 8.86 KB 8.86 KB 0.00 KB (0.00%)
optic.ts 6.68 KB 6.68 KB 0.00 KB (0.00%)
pubsub.ts 14.86 KB 14.86 KB 0.00 KB (0.00%)
queue.ts 11.54 KB 11.54 KB 0.00 KB (0.00%)
schedule.ts 10.71 KB 10.71 KB 0.00 KB (0.00%)
schema-class.ts 19.45 KB 19.45 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.32 KB 29.32 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.59 KB 25.59 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.52 KB 13.52 KB 0.00 KB (0.00%)
schema-string.ts 11.05 KB 11.05 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.35 KB 15.35 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.48 KB 21.48 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 23.96 KB 23.96 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.70 KB 18.70 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.53 KB 18.53 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.39 KB 18.39 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.16 KB 22.16 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.05 KB 19.05 KB 0.00 KB (0.00%)
schema.ts 18.69 KB 18.69 KB 0.00 KB (0.00%)
stm.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
stream.ts 9.67 KB 9.67 KB 0.00 KB (0.00%)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The new commit removes the type-level regression tests that verified exactly the bug this PR fixes, leaving the fix without automated coverage.

Reviewed changes

Since the last Pullfrog review (04e63764), the only change is commit 876e03d:

  • Removed both type-level regression tests — deleted packages/ai/openai/typetest/OpenAiTelemetry.tst.ts and packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts, which asserted gen_ai.openai.response.* is assignable to OpenAiTelemetryAttributes and the gen_ai.openai.request.* variant is not.

⚠️ Removing the regression tests drops the only coverage for this fix

This PR is a pure type-level correction: the source change swaps the ResponseAttributes prefix from gen_ai.openai.request to gen_ai.openai.response in OpenAiTelemetry.ts (both packages). The runtime package tests exercise OpenAI API behavior and cannot detect a mistake in the telemetry attribute type namespace, so the deleted typetests were the sole automated guard for the exact bug being fixed.

The repo's tstyche pipeline would run these tests — tstyche.json matches packages/*/*/typetest/**/*.tst.*, and openai-compat retains a sibling OpenAiConfig.tst.ts in the same directory. Without a regression test, a future change re-introducing gen_ai.openai.request for response attributes would ship silently.

Technical details
# Re-add type-level regression coverage

## Affected sites
- packages/ai/openai/typetest/OpenAiTelemetry.tst.ts — deleted in 876e03d
- packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts — deleted in 876e03d

## Required outcome
- Restore at least one type-level test asserting `{ "gen_ai.openai.response.system_fingerprint" }` is assignable to `OpenAiTelemetryAttributes` and `{ "gen_ai.openai.request.system_fingerprint" }` is not (or the equivalent for `service_tier`). It must fail against the buggy `.request` prefix and pass with the `.response` prefix.
- Run `pnpm test-types packages/ai/openai/typetest/OpenAiTelemetry.tst.ts packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts` to confirm.

## Open questions for the human
- If the tests were removed because they did not actually run or were invalid, please note why — the sibling `OpenAiConfig.tst.ts` in `openai-compat` indicates typetests do run for these packages.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@tim-smart
tim-smart merged commit 16b94c7 into main Aug 8, 2026
19 of 20 checks passed
@tim-smart
tim-smart deleted the audit/repro-b206fa5d76-openai-telemetry-response-namespace branch August 8, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 audit Findings originating from the Effect runtime correctness audit bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants