feat(sdk): expose headless patch generation - #774
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsBlocking findings (2)
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: e071faa9b1
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08cdfc9323
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f69987795
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9825b0b7a3
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55cb677e2a
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4e77a11af
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d9c787670
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 42d5d2eaf9
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
|
This API now matches approval-gated remediation use case: patch an isolated workspace, return structured verification, and leave authoritative diff capture, approval, commit creation, PR delivery, and finding closure to the caller. Before adoption, we need the remaining project-trust issue resolved. An SDK patch operation must fail closed regardless of system-level For an embedding-safe default, please consider disabling repository MCP servers for
|
|
I checked the structured finding path. Object findings are passed through One non-blocking SDK contract improvement would help embedding applications: Please consider exporting a reusable |
There was a problem hiding this comment.
💡 Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 7a0aaad402
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
patch() appears to drop command-authenticated custom provider configuration when it adds the trust overrides.
#createSessionCodex() first conditionally supplies configOverrides: modelProviderConfigOverride(sessionConfig) when commandAuth is true. That raw override is important because the function also deletes model_providers from the structured SDK config. But the later spread for the new configOverrides argument writes the same property again, so patch() replaces the provider override with only project_root_markers=[] and the untrusted-project entry.
A configuration using model_providers.<id>.auth can therefore work for existing SDK operations but lose the provider definition/auth command specifically in patch().
Could these arrays be merged instead of assigning configOverrides twice? I would add a patch test with a command-auth provider and assert that the final Codex options contain both the serialized model_providers=... override and the two trust overrides.
Summary
Fixes #681.
The TypeScript SDK can scan and validate findings, but generating a verified patch currently requires applications to launch and supervise the CLI. Add
CodexSecurity.patch()so approval-gated remediation systems can run the existing fix-finding workflow through the SDK without parsing terminal output or delegating commit and publication control.The required syntax is
patch({ repositoryPath, finding }). Authentication defaults to"auto"; model and reasoning effort default to the constructor configuration and can be overridden per call. The supplied workspace is intentionally mutable. The SDK never commits, pushes, publishes, opens a pull request, or changes remote finding state. Patch workspaces are pinned as untrusted Codex projects before the patch thread starts, so repository-local configuration and MCP servers are not loaded regardless of lower native configuration layers.Changes
PatchOptionsand a readonly, discriminatedPatchResultunion forverified,no_change,blocked, andfailedoutcomes. Successful/no-change outcomes require verification proof; blocked/failed outcomes require a reason. Use a Responses-compatible root object schema with required nullable wire fields, then normalize it back to the discriminated public result.fix-findingskill through the existing SDK runtime, authentication, provider, cancellation, activity, session-event, reconnect, and cost-tracking boundaries.repositoryPathitself as the native Codex project root and mark ituntrustedthrough highest-precedence raw SDK overrides before passing it asworkingDirectory. This prevents system, managed, profile, user, or constructor-levelproject_root_markersfrom selecting another root and prevents repository-local Codex configuration or MCP servers from loading.No public CLI commands, arguments, flags, accepted values, environment variables, or defaults change.
Testing
bun test --timeout 30000 tests-ts/api-patch.test.ts --seed 12345— 15 passed, 0 failed.apiandapi-patch, seed 12345) — 168 passed, 2 platform skips, 0 failed.cli-patch-trust, seed 12345) — 5 passed, 0 failed.api-patch,api,cli-skills, andcli-patch, seed 12345) — 210 passed, 2 platform skips, 0 failed.pnpm run types— passed, including generated models, MCP typecheck, and SDK TypeScript checks.pnpm run buildandpnpm run format— passed.pnpm run test:mcp— all 23 test files passed.pnpm pack— passed; the resulting archive contained 390 validated entries, andcheck-package.mjspassed.pnpm run check:plugin-source,python .github/scripts/check_plugin_source_compatibility.py, andgit diff --check— passed.pnpm run test --seed 12345was attempted on unsupported Node 25 and was not used as passing validation. It reached the same seven unchangedcodex-review.test.tsfixture failures reproducible onmain, then was interrupted after those deterministic failures appeared. The new patch tests had already passed in that run.@openai/codex@0.149.1dependency (ETARGET). Archive validation and strict local consumer compilation passed instead.Risk and rollout
This is an additive public SDK method and type surface. Existing scan, validation, CLI patch, authentication, and publication behavior is unchanged. The method can leave partial workspace edits when the model reports failure, the turn is interrupted, or result validation fails; callers must use a disposable or otherwise controlled workspace and inspect or discard its diff.
changedFilesis model-reported metadata rather than an authoritative patch artifact. Cost isnullwhen pricing or usage is unavailable.Every patch workspace is treated as an untrusted Codex project for the operation. Highest-precedence raw overrides pin
repositoryPathas the project root and mark it untrusted, so lower native configuration layers cannot redirect project-root discovery or activate repository-local configuration, hooks, rules, or MCP servers.The first SDK surface intentionally excludes patch-risk assessment, commit creation, pull-request creation, publication, and finding closure. Those remain existing CLI or caller-owned workflows.
Public disclosure review