fix(autocomplete): preserve literal completion-token arguments - #171
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
Castiron custom code✅ No new custom-code files detected. 5 mixed files remain; 0 existing customizations changed. Compared 5 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 34223004647 --repo openai/openai-cli \
--name castiron-custom-code-34223004647-1 --dir /tmp/castiron-custom-code-34223004647-1
git apply --stat /tmp/castiron-custom-code-34223004647-1/custom-code.patch
cat /tmp/castiron-custom-code-34223004647-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 265cf6378ab2e6a27c17bc7c0b6a6cbe6dbd477b 12f7aafb368fe4b4e9accf4a33e531a21447287a
python3 scripts/castiron/custom_code_report.py report \
--base 265cf6378ab2e6a27c17bc7c0b6a6cbe6dbd477b \
--head 12f7aafb368fe4b4e9accf4a33e531a21447287a --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-12f7aafb368f
cat /tmp/castiron-custom-code-12f7aafb368f/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
There was a problem hiding this comment.
🟢 Approval recommended
The fix is narrowly scoped to the CLI entrypoint, aligns with the documented completion invocation contract, and is covered by targeted subprocess regression tests.
Pull request overview
This PR fixes an autocomplete edge case in the CLI entrypoint where a literal __complete value anywhere in os.Args (including flag values or argv0) unintentionally enabled completion-mode behavior across the command tree. The change restricts completion preparation to the intended invocation shape used by bundled shell completion scripts: __complete must be the first argument after the executable.
Changes:
- Only call
prepareForAutocompletewhenos.Args[1] == "__complete"(instead of scanning all args). - Add fresh-subprocess tests that execute the production
main()in a separate process and validate both ordinary parsing and completion protocol shapes across bash/zsh/fish/pwsh.
File summaries
| File | Description |
|---|---|
| cmd/openai/main.go | Limits completion-mode setup to the argv[1] == "__complete" case to avoid breaking normal flag/value parsing. |
| cmd/openai/main_dispatch_test.go | Adds subprocess-level regression tests for literal __complete values, argv0 shapes, and the four bundled completion argument forms/status codes. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Reviewed the complete exact-head diff. The entrypoint now enables autocomplete preparation only for the protocol position used by the bundled Bash, Zsh, Fish, and PowerShell scripts, while preserving ordinary parsing when __complete is a literal argument value or argv0. Fresh-process regression coverage exercises literal, empty, equals-form, prefixed-global-flag, and all four completion-protocol shapes/statuses. Focused and internal tests, race tests, vet, lint/build, formatting, and diff checks passed locally; hosted full test/mock, build, lint, Castiron, and CodeQL checks are green. No blocking correctness, security, architecture, performance, or test-coverage findings.
Automated Release PR --- ## [1.13.0](openai/openai-cli@v1.12.0...v1.13.0) (2026-09-08) ### Features * **api:** document GPT Image 2.5 models and image options ([openai#175](openai#175)) ([7a9994d](openai@7a9994d)) ### Bug Fixes * **autocomplete:** preserve literal completion-token arguments ([openai#171](openai#171)) ([01123b7](openai@01123b7)) * **output:** honor case-insensitive explore format ([openai#169](openai#169)) ([774c240](openai@774c240)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Summary
A literal
__completeargument value disabled flag parsing across the CLI command tree. For example,openai models retrieve --model __complete --helpfailed with unexpected arguments, while--model=__completeshowed normal help. A literal executable name could trigger the same problem.Prepare the command tree for completion only when
__completeis the first argument after the executable. Ordinary values and argv0 retain normal parsing. All bundled Bash, Zsh, Fish, and PowerShell completion entry forms use that position, so their completion path and statuses 0/10/11 remain intact.Add fresh-subprocess tests of the production
main()entrypoint covering literal local/global values, ordinary and equals-form controls, leading ordinary global flags, substrings, argv0, empty arguments, and all four bundled completion argument shapes. The change does not establish general support for manual global-prefix completion arrangements.Validation
Passed locally with Go 1.27.0 on Linux, with dependency manifests unchanged:
cmd/openaiand autocomplete tests; final regression tests fail against the original entrypoint and pass with the fix.go test ./internal/..., all-package compile-only checks, relevant race and vet checks,go mod verify, and./scripts/lint(build only).@behavior, and spaced/empty values.Full LOCAL mock suite NOT RUN: the pinned Steady launcher reports
Missing or linked Steady cache. The previously blocked setup route was not retried. Full hosted CI/mock validation remains required before SDK review solicitation.Hosted validation
CI passed for
12f7aafb368fe4b4e9accf4a33e531a21447287aon its tested merge with current main: pinned Steady security checks and mock startup, fullgo test ./..., Windows amd64 test cross-compilation, and mock cleanup all completed successfully. Lint, build, CodeQL, code-quality, and Castiron checks also passed. Codex code and security reviews completed on this head; Copilot recommended approval with no comments.