feat: emit --openai-api-target / --anthropic-api-target when OPENAI/ANTHROPIC_BASE_URL is set in engine.env#20596
Closed
Rubyj wants to merge 1 commit intogithub:mainfrom
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates AWF command compilation so that when a workflow sets custom OPENAI_BASE_URL and/or ANTHROPIC_BASE_URL in engine.env, the compiler extracts the hostname and emits --openai-api-target / --anthropic-api-target so the AWF API proxy sidecar forwards to the intended upstream.
Changes:
- Parse
OPENAI_BASE_URL/ANTHROPIC_BASE_URLfromengine.envand emit--openai-api-target/--anthropic-api-targetwith the extracted hostname. - Add
extractHostname(rawURL string)helper usingnet/urlparsing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
…NTHROPIC_BASE_URL When engine.env sets OPENAI_BASE_URL or ANTHROPIC_BASE_URL pointing to a custom endpoint, extract the hostname and pass it as --openai-api-target / --anthropic-api-target to the AWF command. This allows the API proxy sidecar to forward requests to internal LLM routers or other custom OpenAI/Anthropic-compatible endpoints, rather than the hardcoded api.openai.com / api.anthropic.com defaults. Depends on gh-aw-firewall PR github#1247 which adds the --openai-api-target and --anthropic-api-target flags to AWF. Closes: github#20590
54d2fdc to
4734c05
Compare
Contributor
|
File an issue thanks. |
Author
I did! After reading the community guidelines I added agentic instructions here #20590 (comment) |
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
When a workflow sets a custom
OPENAI_BASE_URLorANTHROPIC_BASE_URLinengine.env(e.g., to point to an internal LLM router), the compiler now extracts the hostname and emits the corresponding--openai-api-target/--anthropic-api-targetflags in the AWF command, so the API proxy sidecar forwards requests to the correct upstream.Depends on github/gh-aw-firewall#1247 which adds
--openai-api-targetand--anthropic-api-targetto AWF.Closes #20590
Problem
When users configure a custom endpoint in
engine.env:The AWF API proxy overrides
OPENAI_BASE_URLinside the agent container to point to its internal sidecar, then forwards requests to the hardcodedapi.openai.com. The custom endpoint is never used, and requests fail with 401 because the internal key is rejected by OpenAI's public API.Changes
pkg/workflow/awf_helpers.goIn
BuildAWFArgs(), after the--enable-api-proxyflag is appended:engine.envforOPENAI_BASE_URL— if set, parse the hostname and emit--openai-api-target <hostname>engine.envforANTHROPIC_BASE_URL— if set, parse the hostname and emit--anthropic-api-target <hostname>Added
extractHostname(rawURL string) stringhelper that usesnet/urlto safely parse the URL and return just the hostname.Example
Given this frontmatter:
The compiled
awfcommand will now include:Backward compatibility
Fully backward compatible. The new flags are only emitted when
OPENAI_BASE_URL/ANTHROPIC_BASE_URLare present inengine.env. Workflows without these env vars produce identical compiled output.