Fix Codex threat-detection config pointing at the Anthropic api-proxy port - #56404
Fix Codex threat-detection config pointing at the Anthropic api-proxy port#56404davidslater with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: davidslater <12449447+davidslater@users.noreply.github.com>
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. No ADR enforcement needed: PR #56404 does not have the implementation label and has 79 new lines in business logic directories (below the 100-line threshold).
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Ponytail Reviewer completed successfully! Lean already. Ship.
|
|
✅ PR Code Quality Reviewer completed the code quality review. Reviewed PR #56404 and found no actionable changed-line issues to comment on; submitting no-op safe output as required.
|
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs — the fix is correct and well-targeted.
📋 Assessment
Root cause & fix
The three-step path ResolveLLMProvider → llmProviderProfileFor → gatewayPort defaulted to the Anthropic port (10001) for any non-openai/github provider. Replacing it with getOpenAIProxyProviderBaseURL — the same resolution the agent job uses — eliminates the divergence cleanly. Minimal diff, no collateral changes.
Test coverage
TestExternalDetectorCodexConfigUsesOpenAIProxyPort covers both the happy path (default provider) and the exact reproducer (model-provider: anthropic). It asserts base_url, api_base, and wss_base land on the OpenAI ingress and explicitly rejects the Anthropic host:port. That's a solid regression guard.
Positive highlights
- ✅
netimport correctly removed;strconvretained (still used elsewhere in the file) - ✅ Explanatory comment in the fix makes the constraint self-documenting
- ✅ PR description traces root cause → divergence → fix clearly
- ✅ No lock-file regeneration needed — accurate and verified
One minor observation: the negative assertion covers base_url but not wss_base against the Anthropic host. Since codexProxyWebsocketBaseURL derives from codexAPIBase they're consistent in practice, but an explicit wss_base negative check would make the test fully watertight. Not blocking.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet46 · 19.2 AIC · ⌖ 13.8 AIC · ⊞ 7.6K
Comment /matt to run again
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment.
|
There was a problem hiding this comment.
The fix correctly replaces the broken provider-aware port resolution (which could land on the Anthropic ingress, port 10001) with getOpenAIProxyProviderBaseURL, which always returns an OpenAI-compatible ingress. The inline comment clearly explains the root cause. The regression test covers the critical Anthropic-provider-override case that triggered the original bug. No concerns.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet46 · 17.4 AIC · ⌖ 9.04 AIC · ⊞ 6.2K
There was a problem hiding this comment.
Pull request overview
Routes Codex threat-detection configuration through Codex-compatible API proxy ingresses.
Changes:
- Reuses Codex endpoint resolution for detection configuration.
- Adds regression coverage for default and Anthropic provider settings.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/threat_detection_external.go |
Resolves Codex detection proxy URLs consistently. |
pkg/workflow/threat_detection_isolation_test.go |
Tests generated proxy ports. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
| // which rejects Codex requests with 403 "Credentials for Anthropic ... are | ||
| // not configured"). Codex speaks the OpenAI Responses wire API, so only the | ||
| // OpenAI (10000) or Copilot (10002) ingress can serve it. | ||
| codexAPIBase := NewCodexEngine().getOpenAIProxyProviderBaseURL(detectionData) |
The
Prepare Codex config for threat-detectstep could emit aconfig.tomlpinned tohttp://172.30.0.30:10001— the Anthropic ingress of the AWF api-proxy sidecar. Codex speaks the OpenAI Responses wire API, so every detection request was rejected with403 Forbidden: Credentials for Anthropic (port 10001) are not configured, the engine exited without a verdict, and the job failed withERR_SYSTEM: Detection result file not found.Root cause
The detection step resolved the port via
llmProviderProfileFor(provider).gatewayPort, whose default branch isClaudeLLMGatewayPort(10001). Any Codex workflow whose engine config resolves to a provider other thanopenai/github— e.g.engine: {id: codex, model-provider: anthropic}, or an inherited/unrecognized provider value — got an unusable endpoint. The agent job never hit this because it usesCodexEngine.getOpenAIProxyProviderBaseURL, which is constrained to Codex-compatible ingresses. That divergence is why only detection broke.Changes
pkg/workflow/threat_detection_external.go: drop the provider→profile→port mapping and reuseCodexEngine.getOpenAIProxyProviderBaseURL(detectionData)— Copilot ingress (10002) forcopilot/models, OpenAI ingress (10000) otherwise.wss_baseis derived from the same base URL, so all three URLs stay consistent.pkg/workflow/threat_detection_isolation_test.go:TestExternalDetectorCodexConfigUsesOpenAIProxyPortcompiles a Codex workflow with the default provider and withmodel-provider: anthropic(the case that reproduces the bug), assertingbase_url/api_base/wss_baseresolve to the OpenAI ingress and never to the Anthropic port.No
.lock.ymlregeneration is required — no workflow in this repo exercises the broken branch, so compiled output is unchanged.Prepare Codex config for threat-detectpoints Codex at the Anthropic api-proxy port (10001), breaks detection #56397