fix(prism): delegate structured/embeddings/images calls in TracingProvider - #2
Merged
cybernerdie merged 1 commit intoAug 6, 2026
Conversation
…vider
Prism's base Provider class defines concrete (non-abstract) default
methods for structured(), embeddings(), images(), moderation(),
textToSpeech(), speechToText(), and stream() that throw
"X is not supported by {class}". Because TracingProvider only
overrode text(), calls to these other methods resolved directly to
the inherited default on Provider instead of falling through to
__call(), so the exception incorrectly named "TracingProvider" as
the unsupported provider instead of the real wrapped driver.
TracingProvider now explicitly overrides each of these methods to
delegate to the wrapped provider via callInner(), same as text().
When the wrapped provider doesn't support the action either, the
error now correctly names that provider instead of TracingProvider.
Also updates the Prism test stubs to mirror the real package's
Provider default-throwing behavior, since the previous empty stub
class didn't reproduce this bug.
cybernerdie
self-requested a review
August 6, 2026 04:48
Owner
|
Hey @olivM , awesome find, and great write-up in the PR description!, this has been tested Thanks for the contribution, really appreciated! 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes:
Structured is not supported by TracingProvider(and the same class of error forembeddings(),images(),moderation(),textToSpeech(),speechToText(),stream()) when using the Prism auto-instrumentation driver.Root cause
Prism's base
Prism\Prism\Providers\Providerclass defines concrete (non-abstract) default methods forstructured(),embeddings(),images(),moderation(),textToSpeech(),speechToText(), andstream(). Each throws:Cybernerdie\Glint\Instrumentation\Prism\TracingProviderextendsProviderbut only overrodetext(). Since the other methods are already concrete on the parent (not abstract), PHP resolves calls to them directly against the inherited implementation instead of falling through toTracingProvider::__call(). That means$thisinside the thrown exception is theTracingProviderwrapper, not the real underlying driver — so the error always says "TracingProvider" regardless of which provider (OpenAI, Anthropic, Ollama, etc.) is actually configured, and the call never reaches the real driver even when it does support the action.Fix
TracingProvidernow explicitly overridesstructured(),embeddings(),images(),moderation(),textToSpeech(),speechToText(), andstream(), delegating to the wrapped provider via the existingcallInner()helper (same pattern already used fortext()). If the wrapped provider doesn't support the action either, the error now correctly names that provider instead ofTracingProvider.Tests
The bug wasn't caught previously because the test double at
tests/Stubs/Prism/Providers/Provider.phpwas justabstract class Provider {}— it didn't reproduce Prism's real default-throwing behavior. This PR:Providerclass to mirror the real package (default methods that throw"X is not supported by {class}").Structured,Embeddings,Images,Moderation,Audio,Exceptions\PrismException).TracingProvidernow correctly delegatesstructured()/embeddings()when the wrapped provider supports them, and that the "unsupported" error names the wrapped provider (e.g.Anthropic), neverTracingProvider.embeddings()with an incompatible signature (now fatal once the stub declares the real signature).Checks
composer test— 619 passedcomposer stan— no errorscomposer pint— passed