Repository navigation
Description
Description
When using the AWF sandbox with --enable-api-proxy, the API proxy overrides OPENAI_BASE_URL inside the agent container to point to its internal proxy (http://172.30.0.30:10000/v1). The proxy then forwards all requests to the hardcoded api.openai.com (or api.anthropic.com), ignoring any custom OPENAI_BASE_URL or ANTHROPIC_BASE_URL set by the user.
This makes it impossible to use AWF with internal/self-hosted LLM endpoints, such as corporate LLM routers or proxies that provide an OpenAI-compatible API.
Reproduction
- Configure a workflow with a custom
OPENAI_BASE_URLpointing to an internal endpoint:
engine:
id: codex
model: gpt-5.3-codex
env:
OPENAI_BASE_URL: "https://llm-router.internal.example.com/v1"
OPENAI_API_KEY: ${{ secrets.LLM_ROUTER_KEY }}-
Compile and run the workflow. The compiled lock file includes
--enable-api-proxyautomatically. -
The AWF API proxy:
- Overrides
OPENAI_BASE_URLtohttp://172.30.0.30:10000/v1inside the agent container - Strips
OPENAI_API_KEYfrom the agent container (credential isolation) - Forwards all requests to
api.openai.cominstead of the custom endpoint
- Overrides
-
Result:
401 Unauthorizedbecause the internal API key is sent toapi.openai.com, which doesn't recognize it.
Evidence from logs
[health-check] ✓ OpenAI/Codex credentials NOT in agent environment (correct)
[health-check] Testing connectivity to OpenAI API proxy at http://172.30.0.30:10000/v1...
...
Request completed method=POST url=http://172.30.0.30:10000/v1/responses status=401 Unauthorized
headers={... "Domain=api.openai.com" ...}
Incorrect API key provided: sk-****
The Domain=api.openai.com in the response cookies confirms the proxy is forwarding to OpenAI's API, not our internal endpoint.
Expected behavior
The API proxy should respect the user-configured OPENAI_BASE_URL / ANTHROPIC_BASE_URL and forward requests to that endpoint instead of the hardcoded defaults. This would allow AWF's credential isolation and firewall features to work with:
- Corporate/internal LLM routers
- Azure OpenAI endpoints
- Self-hosted OpenAI-compatible APIs (e.g., vLLM, TGI, etc.)
Suggested implementation
A --openai-api-target <url> flag (similar to the existing --copilot-api-target <host> flag) that configures the API proxy's upstream for OpenAI requests. Similarly, --anthropic-api-target <url> for Anthropic.
The gh-aw compiler could automatically set these flags when it detects a custom OPENAI_BASE_URL or ANTHROPIC_BASE_URL in engine.env.
Current workaround
The only workaround is to disable the AWF sandbox entirely (sandbox.agent: false + strict: false + threat-detection: false), which removes all firewall protection and credential isolation. This is not ideal for production use.
Documentation reference
The API proxy limitations are documented at docs/api-proxy-sidecar.md:
- Only supports OpenAI and Anthropic APIs
- No support for Azure OpenAI endpoints
Environment
- gh-aw CLI: v0.53.6
- AWF: v0.23.0
- Engine: codex (OpenAI Codex CLI)
- Runner: Self-hosted (Amazon Linux 2023)
Activity
feat: add --openai-api-target and --anthropic-api-target flags for cu…
feat: emit --openai-api-target / --anthropic-api-target from OPENAI/A…
feat: add --openai-api-target and --anthropic-api-target flags for cu…
feat: add --openai-api-target and --anthropic-api-target flags for cu…
feat: emit --openai-api-target / --anthropic-api-target from OPENAI/A…
feat: add --openai-api-target and --anthropic-api-target flags for cu…
Rubyj commentedon Mar 11, 2026
Agentic Implementation Plan
After researching the codebase and working on this, here is a complete implementation plan for a core team member to pick up.
Summary
When a workflow sets
OPENAI_BASE_URLorANTHROPIC_BASE_URLinengine.env(to route requests to an internal LLM endpoint), the compiler should extract the hostname and emit the corresponding--openai-api-target/--anthropic-api-targetAWF flags — provided gh-aw-firewall PR #1247 is also merged first (which adds those flags to AWF).Prerequisite: gh-aw-firewall PR #1247
See github/gh-aw-firewall#1247 — this adds
--openai-api-targetand--anthropic-api-targetto AWF's CLI and proxy. The gh-aw change depends on it.Implementation:
pkg/workflow/awf_helpers.go1. Add
"net/url"to imports:2. In
BuildAWFArgs(), after the--enable-api-proxyline (~line 190), add:3. Add the
extractHostnamehelper function:Tests:
pkg/workflow/enable_api_proxy_test.goAdd the following test functions:
Notes for the implementing agent
getEngineEnvOverrideshelper already exists inengine_helpers.go-- use itnet/urlis a standard library package, no new dependency needed--enable-api-proxy)make agent-finishto validatelpcox commentedon Mar 12, 2026
Thanks, @Rubyj working on a fix
lpcox commentedon Mar 12, 2026
@Rubyj waiting to mint a new awf version for a full end-to-end fix. Will ping you when it's ready.
Rubyj commentedon Mar 12, 2026
Thank you very much @lpcox!
Rubyj commentedon Mar 13, 2026
@lpcox it looks like v0.58.0 of gh-aw has the fix but it doesn't yet include the new version of AWF is that true?
lpcox commentedon Mar 13, 2026
@Rubyj yes that's correct. we're folding in the different parts of the solution bit by bit.