Skip to content

refactor(agent): materialize protocol-aware model connections - #226

Merged
zpzjzj merged 2 commits into
mainfrom
refactor/adapter-materialization
Sep 4, 2026
Merged

refactor(agent): materialize protocol-aware model connections#226
zpzjzj merged 2 commits into
mainfrom
refactor/adapter-materialization

Conversation

@zpzjzj

@zpzjzj zpzjzj commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • resolve one model connection after the adapter protocol is known
  • make adapter construction consume that applied connection instead of reinterpreting flattened credential fields
  • preserve agent-local authentication and routing, including explicit-empty overrides
  • reuse the runner connection for inherited agent judges while resolving different providers independently

Why this scope

This is PR 4b of #196 and builds on #221 and #222. It migrates adapter materialization without adding native agent config, installation or version checks, or an independent judge-engine schema.

Compatibility

  • existing v1alpha1 YAML, CLI, and GitHub Action forms remain unchanged
  • flat provider credentials still work
  • nested OpenAI and Anthropic endpoints now select by adapter protocol
  • missing credentials and endpoints continue to delegate to local agent state
  • rejected Codex provider config does not leak into local fallback

Validation

  • make verify
  • make test
  • make test-action
  • make build
  • make e2e
  • go test -race ./internal/credential ./internal/agent ./internal/evaluator ./internal/runner ./internal/cli

Part of #196.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T02:22:17.487439Z a893956 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@JHWang-1997 JHWang-1997 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When judge.model selects a different provider, the runner-sourced connection values are still carried into the judge connection.

For example, with a runner endpoint at runner.example.test and a judge provider configured with judge-key and judge.example.test, the final Claude environment contains judge-key but still uses runner.example.test as ANTHROPIC_BASE_URL. This can send the judge credential to the wrong endpoint.

I confirmed that this behavior also exists on the base commit, so it is not introduced by this PR. However, this PR makes AppliedConnection authoritative and states that different judge providers are resolved independently. Could we resolve the judge connection entirely from its own provider and protocol, and add a regression test covering different runner and judge providers?

@zpzjzj

zpzjzj commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for catching this. Fixed in f51eb56: runner key and endpoint fallback now requires the same provider namespace. A judge selecting a different provider resolves its own connection using the inherited adapter protocol; missing values no longer fall back to the runner connection. Same-provider inheritance and agent-local delegation remain unchanged.

Added regression coverage for flat and protocol-specific credentials, missing keys/endpoints, explicit-empty values, and nil-resolver inheritance. The cross-provider tests cover both Anthropic and OpenAI-compatible adapters through factory construction and the generated credential environment.

Validation passed: make verify, make test (race-enabled), make test-action, make build, and make e2e (quick mode; credential-dependent cases remain gated).

@zpzjzj
zpzjzj requested a review from JHWang-1997 September 3, 2026 02:18

@JHWang-1997 JHWang-1997 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@zpzjzj
zpzjzj added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 8051d18 Sep 4, 2026
12 checks passed
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.

2 participants