Skip to content

Fix Codex threat-detection config pointing at the Anthropic api-proxy port - #56404

Open
davidslater with Copilot wants to merge 2 commits into
mainfrom
copilot/prepare-codex-config-threat-detect
Open

Fix Codex threat-detection config pointing at the Anthropic api-proxy port#56404
davidslater with Copilot wants to merge 2 commits into
mainfrom
copilot/prepare-codex-config-threat-detect

Conversation

Copilot AI commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

The Prepare Codex config for threat-detect step could emit a config.toml pinned to http://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 with 403 Forbidden: Credentials for Anthropic (port 10001) are not configured, the engine exited without a verdict, and the job failed with ERR_SYSTEM: Detection result file not found.

Root cause

The detection step resolved the port via llmProviderProfileFor(provider).gatewayPort, whose default branch is ClaudeLLMGatewayPort (10001). Any Codex workflow whose engine config resolves to a provider other than openai/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 uses CodexEngine.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 reuse CodexEngine.getOpenAIProxyProviderBaseURL(detectionData) — Copilot ingress (10002) for copilot/ models, OpenAI ingress (10000) otherwise. wss_base is derived from the same base URL, so all three URLs stay consistent.
-provider := NewCodexEngine().ResolveLLMProvider(detectionData)
-profile := llmProviderProfileFor(provider)
-codexAPIBase := "http://" + net.JoinHostPort(constants.AWFAPIProxyContainerIP, strconv.Itoa(profile.gatewayPort))
+codexAPIBase := NewCodexEngine().getOpenAIProxyProviderBaseURL(detectionData)
  • pkg/workflow/threat_detection_isolation_test.go: TestExternalDetectorCodexConfigUsesOpenAIProxyPort compiles a Codex workflow with the default provider and with model-provider: anthropic (the case that reproduces the bug), asserting base_url/api_base/wss_base resolve to the OpenAI ingress and never to the Anthropic port.

No .lock.yml regeneration is required — no workflow in this repo exercises the broken branch, so compiled output is unchanged.

Co-authored-by: davidslater <12449447+davidslater@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Codex config for threat detection Fix Codex threat-detection config pointing at the Anthropic api-proxy port Aug 27, 2026
Copilot AI requested a review from davidslater August 27, 2026 18:13
@pelikhan
pelikhan marked this pull request as ready for review August 27, 2026 19:36
Copilot AI balanced review requested due to automatic review settings August 27, 2026 19:37
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #56404

@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • net import correctly removed; strconv retained (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

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-27T00:00:00Z
review_event: COMMENT
top_themes:
  - codex threat-detection proxy port fix is covered by focused regression tests
  - no changed-line correctness or maintainability blocker found
files_reviewed:
  - pkg/workflow/threat_detection_external.go
  - pkg/workflow/threat_detection_isolation_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · pi · gpt54 · 9.27 AIC · ⌖ 8.1 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot mentioned this pull request Aug 27, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepare Codex config for threat-detect points Codex at the Anthropic api-proxy port (10001), breaks detection

3 participants