Skip to content

feat(run): create the OpenAI run-scoped provider only when the runtime needs it - #6925

Merged
waynesun09 merged 5 commits into
mainfrom
openai-credential-seeder
Sep 3, 2026
Merged

feat(run): create the OpenAI run-scoped provider only when the runtime needs it#6925
waynesun09 merged 5 commits into
mainfrom
openai-credential-seeder

Conversation

@waynesun09

Copy link
Copy Markdown
Member

Summary

Makes the OpenAI credential path (ADR 0092) runtime-neutral and creates the run-scoped provider only when the run needs it.

  • runtime.OpenAICredentialSeeder: the runner asks the selected backend for the credential-file re-seed fragment and file instead of hard-coding pi's auth.json. pi implements it with its existing fragments; codex gets the stub filled in PR D. Backends without a seeder degrade to provider-only refresh.
  • runtime.NeedsOpenAIProvider(backend, runModel, agentModel): a harness-declared openai provider is materialised for codex, or for pi when the effective model resolves to pi's openai provider; otherwise it is skipped with an informational note and not attached (no credential, no egress route), so fleet harnesses can declare both providers without an overlay per adopter.
  • runtime.EffectiveModel / AgentDefinitionModel: one chain for the provider decision and pi's launch — the agent-frontmatter fallback previously diverged (a frontmatter openai/ agent had its provider skipped; a Vertex agent under FULLSEND_PI_PROVIDER=openai got one).
  • fullsend-openai profile binaries += **/codex (the codex native binary makes the HTTPS calls).

Review rounds

sol + Grok: HIGH (frontmatter fallback divergence) fixed with the shared chain and end-to-end tests in both directions; skip note is informational, not a warning; doc sentences corrected; test gaps closed. Grok confirmed rejectReservedProfileID must stay ahead of the skip.

Verification (live, macOS, OpenShell gateway)

  • pi openai/gpt-5.6-luna through the run-scoped provider: call succeeded, provider deleted — with the model on the harness, and again with the model only in the agent frontmatter.
  • pi Vertex model with FULLSEND_PI_PROVIDER=openai and providers: [openai]: informational skip, no profile import, no provider instance.

Part of a five-PR stack for #6920 (Codex as an agent runtime): A image pin → B stream parser → C OpenAI credential seeder → D runtime core (ADR 0099) → E enable + docs. Each PR is reviewable on its own diff; they merge bottom-up. Plan and verified Codex facts: research/fullsend-codex-runtime-plan.md in the ai-workspace-public research repo (to be linked once pushed).

Refs #6920

Assisted-by: Claude (implementation and review orchestration), Codex gpt-5.6-sol (review), Grok 4.6 (review)

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Create OpenAI run-scoped providers only when required

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Creates OpenAI providers only for runtimes and effective models that require them.
• Generalizes credential reseeding through backend capabilities with provider-only refresh fallback.
• Allows Codex binary egress and documents portable multi-runtime harness declarations.
Diagram

graph TD
  H["Harness config"] --> M["Effective model"] --> N{"OpenAI needed?"}
  B["Selected backend"] --> N
  N -- Yes --> P["Run provider"] --> S["Sandbox attach"] --> R["Credential refresh"]
  B --> R
  N -- No --> K["Skip provider"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Runtime provider-requirement interface
  • ➕ Encapsulates provider-selection rules inside each runtime.
  • ➕ Scales without extending a central backend-name switch.
  • ➖ Introduces another optional runtime contract and stub implementations.
  • ➖ Still requires a shared effective-model chain to prevent launch divergence.
2. Per-runtime harness overlays
  • ➕ Keeps provider selection declarative and outside runner logic.
  • ➕ Avoids runtime-specific decisions in the provider lifecycle code.
  • ➖ Duplicates harness configuration across adopters and runtimes.
  • ➖ Makes fleet-wide harnesses harder to maintain and easier to misconfigure.
  • ➖ Does not address runtime-neutral credential reseeding.

Recommendation: The PR's centralized decision helper and optional seeder interface are appropriate for the current small runtime set: they eliminate unnecessary credentials and egress without forcing configuration overlays. A runtime-owned provider-requirement interface would become preferable if additional multi-provider runtimes are added.

Files changed (13) +668 / -70

Enhancement (3) +108 / -4
run.goMaterialize OpenAI providers only when needed +40/-4

Materialize OpenAI providers only when needed

• Reads the agent-frontmatter model once, evaluates the selected runtime through 'NeedsOpenAIProvider', and skips unnecessary OpenAI providers with an informational message. Skipped providers are excluded from sandbox attachment while reserved-profile validation remains enforced.

internal/cli/run.go

codex.goDeclare Codex OpenAI seeder capability stub +15/-0

Declare Codex OpenAI seeder capability stub

• Implements the credential-seeder interface with empty methods until Codex bootstrap writes its runner-owned token file. This allows provider creation and refresh without attempting in-sandbox reseeding.

internal/runtime/codex.go

openai_seeder.goAdd OpenAI seeder and provider requirement contracts +53/-0

Add OpenAI seeder and provider requirement contracts

• Defines the optional runtime credential-seeding interface and centralizes whether Codex, pi, or another backend needs an OpenAI provider. Pi decisions reuse effective model and provider-prefix resolution.

internal/runtime/openai_seeder.go

Bug fix (2) +78 / -11
model.goCentralize effective model resolution +47/-0

Centralize effective model resolution

• Introduces the shared run-model and agent-frontmatter fallback chain used by launch and provider selection. Adds frontmatter model extraction with graceful fallback for unreadable or invalid definitions.

internal/runtime/model.go

pi_run.goShare pi model and OpenAI seeder resolution +31/-11

Share pi model and OpenAI seeder resolution

• Uses the common effective-model chain for pi launch and normalizes provider prefixes once for all runtime gates. Exposes pi's existing auth seed fragment and credential file through the new seeder interface.

internal/runtime/pi_run.go

Refactor (2) +97 / -39
run_openai.goMake provider refresh reseeding backend-driven +95/-39

Make provider refresh reseeding backend-driven

• Obtains credential seed fragments and files from the selected backend instead of hard-coding pi's 'auth.json'. Adds skipped-provider filtering and supports provider-only refresh when a backend lacks an active seeder.

internal/cli/run_openai.go

pi.goAssert pi credential-seeder support +2/-0

Assert pi credential-seeder support

• Adds the compile-time assertion that 'PiRuntime' implements the OpenAI credential-seeder interface.

internal/runtime/pi.go

Tests (3) +371 / -12
run_openai_test.goCover conditional providers and backend seeders +232/-12

Cover conditional providers and backend seeders

• Adds end-to-end coverage for skipped providers, frontmatter model fallback, sandbox attachment, runtime-selected seed files, and the embedded profile's Codex binary rule. Existing provider tests now supply the selected backend explicitly.

internal/cli/run_openai_test.go

model_test.goTest effective model fallback behavior +41/-0

Test effective model fallback behavior

• Verifies run-model precedence, agent-frontmatter fallback, runtime defaults, and graceful handling of missing or malformed agent definitions.

internal/runtime/model_test.go

openai_seeder_test.goTest runtime OpenAI provider decisions +98/-0

Test runtime OpenAI provider decisions

• Covers pi and Codex seeder contracts, backend/model combinations, environment-selected pi providers, frontmatter fallback, override precedence, and case-insensitive provider prefixes.

internal/runtime/openai_seeder_test.go

Documentation (2) +9 / -3
runtime-implementation.mdDocument runtime-neutral OpenAI credential seeding +4/-3

Document runtime-neutral OpenAI credential seeding

• Adds the optional OpenAI credential-seeder runtime contract, conditional provider creation behavior, and Codex binary egress. It also aligns model-provider terminology with the shared lowercase provider resolution.

docs/contributing/runtime-implementation.md

openai-workload-identity.mdExplain portable OpenAI provider declarations +5/-0

Explain portable OpenAI provider declarations

• Clarifies that harnesses may declare OpenAI for every runtime because runs that do not call OpenAI skip credential resolution and provider attachment.

docs/guides/infrastructure/openai-workload-identity.md

Other (1) +5 / -1
fullsend-openai.yamlPermit Codex native binary OpenAI egress +5/-1

Permit Codex native binary OpenAI egress

• Extends the trusted OpenAI profile from pi-only usage to pi and Codex. Allows the native 'codex' executable to issue restricted Responses API requests alongside Node.

internal/scaffold/fullsend-repo/profiles/fullsend-openai.yaml

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 6:54 PM UTC · Ended 7:03 PM UTC

Commit: 2457ce9 · View workflow run →

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Site preview

Preview: https://325a4555-site.fullsend-ai.workers.dev

Commit: c00acd8bf350b5a3c9bfaf45ef6bb87af721a1d1

@qodo-code-review

qodo-code-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Standalone refresh comment edits ✗ Dismissed 📘 Rule violation ⚙ Maintainability
Description
This hunk rewrites only comments describing credential refresh behavior without an accompanying code
change in the same hunk. The checklist expressly disallows standalone comment modifications of this
form.
Code

internal/cli/run_openai.go[R65-68]

+// static key only needs its provider expiry pushed out. The running agent
+// process follows every update because the runner re-seeds the credential
+// file that process re-reads per request — the file and the shell fragment
+// that writes it come from the selected backend
Relevance

●●● Strong

Repository history accepts factual comment corrections, and the explicit rule forbids standalone
comment-only edits.

PR-#2630
PR-#6003

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 1062072 requires modified comments to accompany a related non-comment code change in
the same hunk. Lines 65-68 are comment-only replacements, while the adjacent declaration remains
unchanged.

Rule 1062072: Do not add or modify comments outside code lines changed for the issue
internal/cli/run_openai.go[62-71]


2. ADR 0092 omits Codex 📘 Rule violation ⚙ Maintainability
Description
The profile now permits the Codex binary and credential handling is runtime-neutral, but ADR 0092
still defines a node-only, pi-specific contract. This leaves the architectural and security
documentation inconsistent with the changed behavior.
Code

internal/scaffold/fullsend-repo/profiles/fullsend-openai.yaml[41]

+  - "**/codex"
Relevance

●● Moderate

Documentation consistency updates are accepted, but accepted ADRs generally require annotation or
superseding ADR rather than substantive rewrites.

PR-#6375
PR-#2465

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 2748504 requires all documentation references to remain consistent when user-facing
or public behavior changes. The changed profile authorizes **/codex, while ADR 0092 still says the
profile is restricted to **/node and describes every refresh exclusively through pi's auth.json.

Rule 2748504: Update docs when changing CLI behavior or public API
internal/scaffold/fullsend-repo/profiles/fullsend-openai.yaml[36-41]
docs/ADRs/0092-openai-wif-credential-delivery.md[66-78]
docs/ADRs/0092-openai-wif-credential-delivery.md[130-145]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
ADR 0092 still describes the OpenAI profile and credential refresh path as node-only and pi-specific, while the implementation now permits Codex and defines runtime-neutral credential seeding.

## Issue Context
Because ADR 0092 is accepted architectural history, follow the repository's ADR supersession process rather than substantively rewriting the accepted decision. Document the expanded binary policy, conditional provider materialization, and backend-specific reseeding contract in a superseding ADR, then link the old ADR to it.

## Fix Focus Areas
- docs/ADRs/0092-openai-wif-credential-delivery.md[66-78]
- docs/ADRs/0092-openai-wif-credential-delivery.md[128-145]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 72 rules
Review mode: ⚖️ Balanced

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread internal/scaffold/fullsend-repo/profiles/fullsend-openai.yaml
Comment thread internal/cli/run_openai.go
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 7:05 PM UTC · Ended 7:18 PM UTC

Commit: 0d1ba26 · View workflow run →

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cli/run_openai.go 82.35% 5 Missing and 1 partial ⚠️
internal/runtime/pi_run.go 84.61% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:20 PM UTC · Completed 7:42 PM UTC

Commit: ae42a02 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $9.85

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Sep 2, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Moderate risk preserved from prior assessment. Tier 1 signals unchanged: 13 files, 827 lines, large blast radius across CLI + runtime + docs + scaffold, no protected or security-sensitive paths, feature-branch base. Tier 2 shows run.go is very hot but 4 of 13 files are brand new with zero contention, averaging out to moderate. PR C in a well-scoped 5-PR stack for security-labeled issue #6920, mitigated by incremental delivery.

Previous run

Risk Assessment: moderate (2/5)

Details

Moderate risk preserved from prior assessment. Tier 1 signals unchanged: 13 files, 827 lines, large blast radius across CLI + runtime + docs + scaffold, no protected or security-sensitive paths, feature-branch base. 5 of 13 files are brand new with zero contention. PR C in a well-scoped 5-PR stack for issue #6920.

Previous run (2)

Risk Assessment: moderate (2/5)

Details

Moderate risk. The change touches 13 files with 760 lines across a large blast radius (CLI + runtime + docs + scaffold), and the area has high recent churn with many distinct authors. However, 5 of 13 files are brand new (so contention is overstated by raw counts), no protected paths or security-sensitive files are changed, and the PR targets a feature branch (codex-runtime-stream-parser) giving a safe rollback path. It is PR C in a well-scoped 5-PR stack for issue #6920, with a test file ratio of 0.23. Tier 1 signals are unchanged from the prior assessment.

Previous run (3)

Risk Assessment: moderate (2/5)

Details

Moderate risk. The change touches 13 files with 738 lines across a large blast radius (CLI + runtime + docs + scaffold), and the area has high recent churn with many distinct authors. However, several files are brand new so contention is overstated by raw counts. The PR targets a feature branch, not main, giving a safe rollback path. It is PR C in a well-scoped 5-PR stack for issue #6920, with a test file ratio of 0.23. No protected paths, security-sensitive files, CI workflows, or dependency files are changed.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review

Findings

Medium

  • [test-integrity] internal/cli/run_openai_test.go:1019 — The TestReseedOpenAIAuth_VerifiesAndRepeatsTheSeed test script was silently broken: the grep verification case always exited 1 regardless of the condition, masked by the old seed() closure returning nil unconditionally. This PR correctly fixes both the test script (explicit if/then/fi with exit codes) and the production code (return lastErr instead of return nil), pinned by TestReseedOpenAIAuth_UnverifiedSeedIsAnError.

Low

  • [stale-docs] docs/ADRs/0092-openai-wif-credential-delivery.md:67 — Decision point 3 says the fullsend-openai profile scopes egress "for **/node binaries", but this PR adds **/codex to the profile's binaries list.
    Remediation: Update to mention **/codex alongside **/node.

  • [stale-docs] docs/cli/run.md:85 — The section heading "OpenAI credentials on pi" describes the credential path as pi-only, but NeedsOpenAIProvider now also returns true for the codex backend.
    Remediation: Rename the heading to "OpenAI credentials" and adjust the description to mention codex.

  • [stale-docs] docs/guides/dev/cli-internals.md:721 — The line count for run_openai.go is listed as "~550" but the file is now ~1020 lines. The staleness predates this PR but this change widens the gap.
    Remediation: Update the approximate line count to ~1020.

  • [edge-case] internal/runtime/model.go:33AgentDefinitionModel writes to os.Stderr on parse error, which could be confusing in normal operation. Minor UX concern; Bootstrap handles the same file later with a proper error path. See also: [naming-alignment] finding at this location.

  • [naming-alignment] internal/runtime/model.go:33AgentDefinitionModel delegates to parsePiAgent (pi-specific parser). The function name implies runtime-neutrality while the implementation is pi-specific. Works because all runtimes use the same Claude-style frontmatter format. See also: [edge-case] finding at this location.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run

Review

Findings

Low

  • [stale-docs] docs/ADRs/0092-openai-wif-credential-delivery.md:67 — Decision point 3 says the fullsend-openai profile scopes egress "for **/node binaries", but this PR adds **/codex to the profile's binaries list.
    Remediation: Add a parenthetical noting the codex addition, e.g. "(extended to also cover **/codex in Track Codex (openai/codex) as a supported agent runtime — same secretless GPT path as pi, pinned in the sandbox image #6920)".

  • [stale-docs] docs/cli/run.md:85 — The section heading "OpenAI credentials on pi" describes the credential path as pi-only, but NeedsOpenAIProvider now also returns true for the codex backend.
    Remediation: Rename the heading to "OpenAI credentials" and adjust the description to mention codex alongside pi.

  • [stale-docs] docs/guides/dev/cli-internals.md:721 — The line count for run_openai.go is listed as "~550" but this PR brings it to ~1020 lines.
    Remediation: Update the approximate line count.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (2)

Review

Findings

Low

  • [comment-formatting] internal/runtime/codex.go:79 — The doc comment for the OpenAIAuthSeed/OpenAIAuthFile pair is a free-floating paragraph above two separate methods separated by a blank line. Godoc will not associate it with either method.
    Remediation: Move the comment into the doc comment of each method, attached directly above the func keyword with no blank line.

  • [stale-docs] docs/ADRs/0092-openai-wif-credential-delivery.md:67 — Decision point 3 says the fullsend-openai profile scopes egress "for **/node binaries", but this PR adds **/codex to the profile's binaries list.
    Remediation: Add a parenthetical noting the codex addition, e.g. "(extended to also cover **/codex in Track Codex (openai/codex) as a supported agent runtime — same secretless GPT path as pi, pinned in the sandbox image #6920)".

  • [stale-docs] docs/cli/run.md:85 — The section heading "OpenAI credentials on pi" describes the credential path as pi-only, but NeedsOpenAIProvider now also returns true for the codex backend.
    Remediation: Rename the heading to "OpenAI credentials" (or "OpenAI credentials on pi and codex") and adjust the description to mention codex alongside pi.

  • [stale-docs] docs/guides/dev/cli-internals.md:721 — The line count for run_openai.go is listed as "~550" but this PR brings it to ~950 lines.
    Remediation: Update the approximate line count.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR
Previous run (3)

Review

Findings

Low

  • [redundant-inline-logic] internal/runtime/pi_run.go:509PiRuntime.Run still inlines the model fallback at two callsites (params.Model then m.Model) instead of calling EffectiveModel. Today they are equivalent so there is no bug, but a future change to EffectiveModel would not propagate here — undermining the "single fallback chain" invariant the PR's own doc-comment establishes.
    Remediation: Replace the inline block with a call to EffectiveModel(params.Model, m.Model).

  • [comment-formatting] internal/cli/run_openai.go:206 — The rewrap of the openAIBaselineAttempts comment introduced an overlong continuation line (~85 chars vs ~80 in surrounding comments).
    Remediation: Re-wrap the two lines together so they break at the same column width as surrounding comments.

  • [comment-formatting] internal/cli/run_openai.go:414 — The placeholder variable comment was re-wrapped into an awkward mid-sentence break: names; learned is stranded alone on its own comment line.
    Remediation: Re-flow so the break falls at a natural boundary.

  • [scope-boundary] internal/runtime/pi_run.go:226 — The refactoring of buildPiRunCommand to use piModelProvider() changes existing production behavior: provider string is now always lowercase (previously each gate used EqualFold). Semantically equivalent and well-tested (TestPiModelProviderIsLowercase).


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

fullsend-ai-review[bot]

This comment was marked as outdated.

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 7:57 PM UTC · Ended 8:01 PM UTC

Commit: 8ce6348 · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Ended 11:18 PM UTC

Commit: 3837543 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 2, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:20 PM UTC · Completed 11:42 PM UTC

Commit: c9d8436 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • internal/cli/run_openai_test.go (file-level): Line 1019 · [medium] test-integrity

The TestReseedOpenAIAuth_VerifiesAndRepeatsTheSeed test script was silently broken: the grep verification case always exited 1 regardless of the condition, masked by the old seed() closure returning nil. This PR correctly fixes both the test script (explicit if/then/fi) and the production code (return lastErr instead of nil), pinned by TestReseedOpenAIAuth_UnverifiedSeedIsAnError.

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the review comment for full details.

Comment thread internal/runtime/model.go
Comment thread internal/runtime/model.go
@waynesun09
waynesun09 dismissed stale reviews from fullsend-ai-review[bot], fullsend-ai-review[bot], fullsend-ai-review[bot], and fullsend-ai-review[bot] September 2, 2026 23:58

Outdated: every finding from this review is addressed in later commits and all threads are resolved; dismissed so the stack can enter the merge queue in order.

Base automatically changed from codex-runtime-stream-parser to main September 3, 2026 00:19
@waynesun09
waynesun09 force-pushed the openai-credential-seeder branch from c9d8436 to 98d5cff Compare September 3, 2026 00:19
The profile's binaries: rule decides which executable the gateway lets
open a connection to api.openai.com. pi issues its requests from node,
but codex's npm launcher (bin/codex.js) spawns the per-platform native
binary and that process makes the calls itself — so a codex run on this
profile would have every request refused by the proxy, with nothing in
the agent's log to explain it.

Refs #6920

Assisted-by: Claude (implementation)
Signed-off-by: Wayne Sun <gsun@redhat.com>
A harness that declares `providers: [openai]` made every run on it
resolve an OpenAI credential, whatever runtime was selected — so a fleet
harness could not carry the provider for the runs that need it without
breaking the Vertex runs that do not. The runner now materializes it only
when the selected backend will actually call OpenAI: codex, whose only
provider it is, or pi on a model that resolves to pi's openai provider.
Otherwise the entry is skipped with a note and nothing happens: no
credential is resolved, the profile is not imported, no instance is
created, and the name is not attached to the sandbox, so its egress rules
never open. runtime.NeedsOpenAIProvider decides, next to the runtimes,
off the same effective model the plan block prints.

The re-seed the refresher performs is no longer pi's. A credential
refresh has to reach the running agent, and the agent process cannot
follow it through the environment: OpenShell pins a placeholder to the
generation it was issued for. pi solves that by re-reading auth.json per
request; codex will do the same with a token file its auth command
prints. Both are now expressed as runtime.OpenAICredentialSeeder — the
in-sandbox file, and the sh fragment that writes the current placeholder
into it — and ensureOpenAIProvider asks the selected backend for them
instead of hard-wiring pi's. A backend without a seeder (Claude Code) or
with a stubbed one (codex until #6920 lands its Bootstrap) leaves both
empty, which already means "provider refreshed, nothing re-seeded".

buildPiRunCommand's provider gates and NeedsOpenAIProvider now share
piModelProvider, so the two cannot disagree about which spec is an
OpenAI one.

Refs #6920

Assisted-by: Claude (implementation)
Signed-off-by: Wayne Sun <gsun@redhat.com>
The skip rule read the harness model only, but that is not what pi
launches on: buildPiRunCommand falls back to the agent definition's
frontmatter `model:` when the runner resolved none, while the decision
fell back to translatePiModel's own default. Two fallback chains, and
both directions were wrong. An agent whose frontmatter pins an openai
model, run with no override, had its provider skipped and then failed
inside the sandbox with no credential and nothing pointing at why. The
inverse — FULLSEND_PI_PROVIDER=openai with a frontmatter-pinned Vertex
model — created a live OpenAI credential and opened its egress route for
a run that never calls OpenAI.

There is now one chain: EffectiveModel(runModel, agentModel), used by
buildPiRunCommand to build --model and by NeedsOpenAIProvider to decide,
so the launch and the decision cannot disagree. The runner reads the
frontmatter with the parser it already has (AgentDefinitionModel over
parsePiAgent); an unreadable or unparseable definition resolves to the
runtime default here and fails later in Bootstrap, where the message is
better.

Also from review: the skip line is StepInfo, not StepWarn — declaring
the provider on a harness several runtimes share is the documented way
to write a portable harness, so it must not bury real warnings. The
reserved-profile-id rejection keeps running before the skip, and now
says why: skipping first would leave a repo-controlled profile with the
reserved id live on the gateway. Docs: the `fullsend-openai` profile
sentence names `**/codex` alongside `**/node` and the materialization
rule, and the Grok-on-Vertex note no longer claims the gate uses
EqualFold.

Refs #6920

Assisted-by: Claude (implementation)
Signed-off-by: Wayne Sun <gsun@redhat.com>
…tiveModel

Run still inlined the params.Model-then-manifest fallback in two places
(model validation and the spec it hands the renderer), so the single
chain the provider decision relies on held only in buildPiRunCommand.
Call EffectiveModel in all three, and the invariant is structural rather
than a convention three call sites have to remember.

Also re-flows three comment blocks in run_openai.go that the
runtime-neutral rewording left overlong or broken mid-sentence.

Refs #6920

Assisted-by: Claude (implementation)
Signed-off-by: Wayne Sun <gsun@redhat.com>
After writing the credential file the refresher greps it for the new
placeholder, twice. Both greps failing returned success anyway, so the
refresh loop recorded the new generation while the file might still name
the old one — and the next rotation's settle wait would then compare
against a generation the agent never held. Return the last verification
error instead: the loop keeps the placeholder the agent actually holds,
retries under its existing policy, and gives up loudly rather than
silently drifting.

The existing "verifies and repeats the seed" test never exercised a
passing second verification — its stub's grep branch fell through to the
trailing `exit 1`, so every verification failed and the test only passed
because of this bug. The branch now exits explicitly, and a new test
covers both verifications failing, through reseedOpenAIAuth and through
refreshOpenAIProvider (which must return the old placeholder).

Also gives CodexRuntime's two seeder stubs their own doc comments
instead of one free-floating paragraph above the pair.

Refs #6920

Assisted-by: Claude (implementation)
Signed-off-by: Wayne Sun <gsun@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 3, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:22 AM UTC · Completed 1:00 AM UTC

Commit: c00acd8 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $9.93

@waynesun09
waynesun09 added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit 8ce4ac6 Sep 3, 2026
22 checks passed
@waynesun09
waynesun09 deleted the openai-credential-seeder branch September 3, 2026 00:46
@fullsend-ai-retro

fullsend-ai-retro Bot commented Sep 3, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 12:48 AM UTC · Completed 1:04 AM UTC

Commit: c00acd8 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $3.98

@fullsend-ai-review

Copy link
Copy Markdown

Review skipped — this PR is already merged.

The /fs-review command only reviews open PRs/MRs.

Posted by fullsend post-review check

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #6925 — OpenAI run-scoped provider

A human-authored, 13-file (739+/88−) PR that is part C of a five-PR stack for Codex runtime support (#6920). The PR introduces runtime.OpenAICredentialSeeder, NeedsOpenAIProvider, and EffectiveModel, refactoring the runner to create the OpenAI provider only when the selected backend needs it.

Timeline

  1. PR created by @waynesun09 (2026-09-02 18:52 UTC)
  2. Human review by @ralphbean — APPROVED (21:02 UTC) with one important inline comment identifying a real verification bug: reseedOpenAIAuth's seed() closure returned nil instead of the accumulated lastErr when both verification attempts failed, silently swallowing the error.
  3. Review agent run 1 (22:27–22:48 UTC, run 33690453026) — found 3 low-severity stale-docs findings. Did NOT catch the verification bug. Cost: $9.92, 18 min, 45 tool calls. 4 of 11 sub-agents initially failed due to sonnet model unavailability and were retried on opus.
  4. Author fixed the verification bug and the test that masked it (commits 7b30805, c00acd8).
  5. Review agent run 2 (23:18–23:43 UTC, run 33694446532) — found 6 findings (3 original stale-docs + 1 medium test-integrity noting the fix was correct + 2 low informational). 213 tool calls (5× run 1). Metrics recorded $0 cost and exit_code=-1 despite valid output.
  6. Review agent run 3 (run 33699074221) — started 00:20 UTC, still running when the PR merged at 00:46 UTC.
  7. PR merged to main (00:46 UTC).

Review quality

The review agent correctly identified stale-docs drift (ADR 0092, run.md, cli-internals.md). The human reviewer correctly identified a real correctness bug that the review agent missed across two review runs. The agent's second run did recognize and validate the bug fix, but only after the human flagged it.

Evidence for existing issues

  • #6922 / agents#1116: Sonnet 4.5 model unavailability continues to cause sub-agent failures. Both review runs in this PR saw 4–6 sub-agents fail on claude-sonnet-4-5@20250929 before being retried on opus, adding latency and cost.
  • #6806: Review agent metrics zeroed when exit_code=-1. Run 2 produced valid output (schema validation passed) but recorded 0 tokens and $0 cost in telemetry.
  • #6940 / #6939: Review run 3 was still in progress when the PR merged — wasted compute.
  • #1393: The verification bug missed by the review agent is a variant of the silent-failure-path pattern described in Review agent should detect silent failure paths in Go functions #1393. That issue covers functions without error returns; this PR's bug involved a function WITH an error return that fell through to return nil instead of returning the accumulated error. See the proposal below for the distinct sub-pattern.

Proposals filed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants