Skip to content

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

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

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

Conversation

@fubhy

@fubhy fubhy commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

Both aliases apply AttributesWithPrefix<ResponseAttributes, gen_ai.openai.request>, so they expose gen_ai.openai.request.system_fingerprint and reject gen_ai.openai.response.system_fingerprint. Both runtime helpers emit the latter.

Important

This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.

OpenAI-compatible telemetry response attributes use the request namespace type

Module: packages/ai/openai-compat/src/OpenAiTelemetry.ts
Audit ID: relsem-openai-compat-telemetry-response-namespace
Severity / confidence: medium / high

What happens

Both aliases apply AttributesWithPrefix<ResponseAttributes, gen_ai.openai.request>, so they expose gen_ai.openai.request.system_fingerprint and reject gen_ai.openai.response.system_fingerprint. Both runtime helpers emit the latter.

Why it happens

A copied request prefix is used for ResponseAttributes in both public type intersections.

Expected behavior

Provider response attributes represented at the type level use the same gen_ai.openai.response prefix emitted at runtime.

Relevant implementation

These links and excerpts are pinned to audit base b206fa5d7655c1634c9993410a9203f6616a5ca2.

View problematic code at packages/ai/openai-compat/src/OpenAiTelemetry.ts:1
/**

View exact lines on GitHub

Reproduction

pnpm test-types packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts

Observed failure: Independently rerun; failed at the intended semantic assertion.

Implementation handoff

The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.

  1. Start with the pinned implementation excerpts and the Why it happens analysis above.
  2. Change the implementation so it satisfies the stated Expected behavior; do not weaken or remove the reproduction assertions.
  3. Run the focused reproduction command(s) and confirm the observed failures become passing tests:
pnpm test-types packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts
  1. Run the affected package's existing tests, then the repository lint and type checks before requesting review.

Audit provenance

  • Audit base: b206fa5d7655c1634c9993410a9203f6616a5ca2
  • Reproduction base: b206fa5d7655c1634c9993410a9203f6616a5ca2
  • Findings: relsem-openai-compat-telemetry-response-namespace
  • Initial patch: focused reproduction tests; implementation fix pending

Closes EFF-561

@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: 3aa0b3b

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

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

The reproduction test correctly captures the bug, but the implementation fix in packages/ai/openai-compat/src/OpenAiTelemetry.ts is missing. CI will fail and the PR title's "Fix" claim is unfulfilled until the source type is corrected.

Reviewed changes

This PR adds a TSTyche type test in packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts that verifies OpenAiTelemetryAttributes accepts gen_ai.openai.response.system_fingerprint and rejects the gen_ai.openai.request.system_fingerprint namespace.

⚠️ Implementation fix is missing

The test reproduces the bug as intended, but packages/ai/openai-compat/src/OpenAiTelemetry.ts was not modified. Line 30 still maps ResponseAttributes under the request namespace:

& Telemetry.AttributesWithPrefix<ResponseAttributes, "gen_ai.openai.request">

The runtime helper on line 125 already emits gen_ai.openai.response.*, so the type declaration should match:

& Telemetry.AttributesWithPrefix<ResponseAttributes, "gen_ai.openai.response">

Please apply the source fix to the same branch and confirm pnpm test-types packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts passes.

Technical details
# Missing response namespace fix

## Affected sites
- packages/ai/openai-compat/src/OpenAiTelemetry.ts:30 — `ResponseAttributes` uses `"gen_ai.openai.request"` instead of `"gen_ai.openai.response"`

## Required outcome
- `OpenAiTelemetryAttributes` exposes `gen_ai.openai.response.system_fingerprint`
- `OpenAiTelemetryAttributes` rejects `gen_ai.openai.request.system_fingerprint`
- `pnpm test-types packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts` passes

## Suggested approach
Change line 30 of `src/OpenAiTelemetry.ts` to:

```ts
& Telemetry.AttributesWithPrefix<ResponseAttributes, "gen_ai.openai.response">
```

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

This incremental pass covered the new commit that completes the PR: the implementation fix and a patch changeset.

  • Applied the response-namespace fix in packages/ai/openai-compat/src/OpenAiTelemetry.tsResponseAttributes is now prefixed with "gen_ai.openai.response", matching the runtime helper.
  • Added a patch changeset for @effect/ai-openai-compat describing the namespace fix.
  • The reproduction type test already present now passes, confirming gen_ai.openai.response.system_fingerprint is accepted and gen_ai.openai.request.system_fingerprint is rejected.

ℹ️ Sibling package has the same copied-prefix issue

The same ResponseAttributes prefix bug appears to remain in packages/ai/openai/src/OpenAiTelemetry.ts, which is outside this PR's openai-compat scope. Worth tracking separately if it hasn't been fixed already.

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%)

@tim-smart
tim-smart enabled auto-merge (squash) August 7, 2026 22:06

@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 fix is correct, but the new commit deletes the regression test that guarded it, so the type-level bug this PR fixes can silently regress.

Reviewed changes

This incremental pass covers the single new commit since the prior approved review.

  • Removed the reproduction type test packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts, which asserted that OpenAiTelemetryAttributes accepts gen_ai.openai.response.system_fingerprint and rejects gen_ai.openai.request.system_fingerprint. The source fix itself is unchanged and still in place.

For reference, the fix (src/OpenAiTelemetry.ts:31) now has no automated guard — see the inline note.

Technical details
# Regression test for the namespace fix was removed

## Affected sites
- packages/ai/openai-compat/typetest/OpenAiTelemetry.tst.ts — deleted by commit 3aa0b3b5e1

## Required outcome
- Keep an autoregressive guard asserting the response namespace (`gen_ai.openai.response`) is accepted and the request namespace (`gen_ai.openai.request`) is rejected, so the fix in src/OpenAiTelemetry.ts:31 cannot silently regress.

## Open questions for the human
- If the removal was intentional (e.g. type tests for this shape are considered noise), it would help to say so; otherwise restore the test or move the coverage elsewhere.

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 b588640 into main Aug 7, 2026
19 of 20 checks passed
@tim-smart
tim-smart deleted the audit/repro-b206fa5d76-openai-compat-telemetry-response-namespace branch August 7, 2026 22:12
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