Make LLM Gateway errors name the gateway, not OpenAI - #17
Open
ericjohanson-langchain wants to merge 1 commit into
Open
Make LLM Gateway errors name the gateway, not OpenAI#17ericjohanson-langchain wants to merge 1 commit into
ericjohanson-langchain wants to merge 1 commit into
Conversation
The LangSmith LLM Gateway speaks the OpenAI API, so the agent talks to it with the OpenAI SDK client. When the gateway returns 403, that client raises OpenAIPermissionDeniedError -- naming a service that was never contacted. This cost real debugging time twice, mine and a reviewer's: the message points at OpenAI credentials while the actual problem is a LangSmith key against gateway.smith.langchain.com, and no request reaches api.openai.com at all. Wrap the gateway-backed model so authentication and permission failures are restated with the gateway URL, the underlying message, an explicit note that OpenAI is not involved, and which variable to check. Other errors pass through untouched. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The gateway speaks the OpenAI API, so the agent uses the OpenAI SDK client to
reach it. When the gateway returns a 403, that client raises:
which names a service that was never contacted. The request goes to
gateway.smith.langchain.comwith modelanthropic/claude-haiku-…; nothingreaches
api.openai.com, and the credential at fault is a LangSmith key.That misdirection cost real time twice in one session — it sends you to check
OpenAI billing and OpenAI keys when neither is involved.
Now:
Only authentication and permission errors are restated; everything else passes
through untouched. Two tests cover both paths.
76 tests, lint, actionlint and bandit green.