Skip to content

Keep output deterministic and add quiet and verbose controls - #392

Merged
saioai merged 33 commits into
mainfrom
codex/universal-output-20261008
Oct 9, 2026
Merged

saioai merged 33 commits into
mainfrom
codex/universal-output-20261008

Conversation

@saioai

@saioai saioai commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Forced color could put ANSI escapes into piped JSON. Structured streams could also wait for another event before printing.
This keeps piped results undecorated and emits stream events promptly.
Quiet and verbose controls cover command setup, API saves, image feedback, and local manpage generation.

What changes

  • Pipes and files receive no added ANSI decoration, including forced color. Terminal JSON also respects NO_COLOR.
  • Noninteractive streams emit each event immediately. Early exits close owned SDK streams and preserve cleanup failures.
  • Quiet suppresses optional hints and image progress. Saved image paths, selected API events, and explicitly requested final previews remain.
  • API save and manpage receipts use stderr. Manpage completion waits for writes, compression, and file closes; failures return nonzero.
  • Models retain ID/owner display and complete records through p. Quiet keeps graceful Ctrl+C status 130 and suppresses fallback hints.
  • Verbose reports command details, elapsed time, and the final result on stderr, including request-setup failures.
  • Quiet, machine errors, and interruptions suppress optional verbose details. Tokenizer SIGHUP keeps status 129 and terminal cleanup.
  • Command and cleanup failures retain their causes and exit codes. Summary-hint failures retain stderr and iteration errors together.
  • Human API errors include accepted returned request IDs and concise recovery guidance. Structured error bytes remain unchanged.
  • Existing formats, extraction, list records, limits, pagination, raw strings, and binary bytes retain their contracts.
  • The dormant compact-table helper now follows the shared hint policy. Generated table activation remains separately gated.

Commands

The new flags are --quiet and --verbose, grouped under Output in root help.
Quiet overrides verbose. -v still means version.

openai files list --format jsonl --quiet > files.jsonl
openai files content FILE --output saved.bin --quiet
openai @manpages --text --gzip=false --quiet -o man
openai models list --verbose                    # details on stderr
openai models list --format jsonl --verbose --format-error text > models.jsonl
openai responses create --model MODEL --input "Hello" --stream=true --format jsonl

The default remains readable text, including pipes. A destination filename does not select a format.
JSON lists still emit independent values. This change introduces no arrays, JSON/raw aliases, or CI output mode.
Explicit explore retains terminal interaction in CI. Quiet does not disable requested interaction.
--debug remains a separate troubleshooting control.
Manpage formats and filenames stay the same. Disabling both formats creates no files and emits no save receipt.

Code

pkg/custom owns feedback policy, human errors, image orchestration, and local manpage file completion.
main.go wraps the existing request-configuration runner so verbose reporting includes setup and cleanup failures.
The manpage action retains generated flags and uses the existing document renderer through the existing flattened command view.
One private helper finishes compression and closes each file before the shared receipt.
Future generated manpage flag or output changes require compatibility review with this local action.
Models selection/viewer hooks and Images stop/stage callbacks remain intact.
Output and binary receipts reuse the same diagnostic predicate. Transformers remain unchanged against main.
This adds no package or dependency and does not change generated sources.

Tested

Candidate: 44f7564 against main 217ff2ea, including merged Tokenizer #386.
Independent adversarial review approved the committed source and its focused evidence.
Focused custom, public, and race checks pass without skips.
These include 45 new cases for local utility data, quiet/verbose, machine errors, offline startup, and private helper protocols.
Manpage checks include the new public commands and exclude both private helpers.
Build, focused vet, module verification, and trusted local budget checks pass. The budget remains 21/1000 lines.

At 68a3e87, a macOS native comparison reproduced 77 unwanted stderr bytes after Tokenizer SIGHUP.
The corrected binary passed all five signal cases, preserving statuses 129/130/143, terminal bytes, restoration, and helper cleanup.
Both focused hangup tests fail before the correction and pass afterward.
These signal checks use drained output; native Linux/Windows editor behavior remains outside this probe.

The table-hint follow-up passes 42 parsed-policy cases, preserving exact table/fallback data and metadata.
Fifteen cases fail before the correction. Focused rendering/navigation/Models checks, race checks, and vet pass afterward.
Those tests exercise the dormant renderer; current generated Files/Batches/Projects commands still use their existing iterator path.

Earlier API, large-payload, binary-save, Models, Images, and manpage evidence retains its recorded source identities.
Current native checks pass on macOS, Linux, and Windows at 44f7564.
Each platform passes all 45 utility composition cases and 16 manpage cases; required shells also pass.
Windows passes all eight console lifecycle cases. Optional and platform-specific skips remain documented.
Full tests and artifacts, CodeQL, and the trusted budget check pass at the same head.
Automatic code and security reviews completed. No new public automated findings appeared after the corrections.
Broader graphics appearance remains outside this scoped validation.

Demo

The retained demo compares real CLI binaries against a synthetic loopback API on macOS.
Before uses da762ff; After uses af738605.
It shows piped JSON parsing, event timing, quiet data preservation, and verbose stderr separation.
Current integration checks cover Models, Images, Shell, manpages, and Tokenizer.
The Tokenizer signal correction preserves identical terminal content and removes the unwanted stderr report.

The capture validator checked exact bytes, request counts, event timing, and all process statuses.
The terminal replay uses Menlo on macOS. Separate quality captures cover 40 and 100 columns.
The manpage compatibility checks compare complete generated files and stdout/stderr separately.

Deterministic output comparison

Before:

Before: forced color and buffered events

After:

After: plain pipes and immediate events

Recording recipe.
Current output contract.
Recordings remain outside Git.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Castiron custom code

Evaluated main: 217ff2ea1e853040ba08c3c170e05586424386aa.

✅ No new custom-code files detected.

2 mixed files remain; 0 existing customizations changed.

Compared 217ff2ea1e85 → 44f75644aa0f. Generated baselines verified.

2 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/audiovoice.go

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 37908606254 --repo openai/openai-cli \
  --name castiron-custom-code-37908606254-1 --dir /tmp/castiron-custom-code-37908606254-1
git apply --stat /tmp/castiron-custom-code-37908606254-1/custom-code.patch
cat /tmp/castiron-custom-code-37908606254-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 217ff2ea1e853040ba08c3c170e05586424386aa 44f75644aa0f1dadb481a251a92b25600cbc6057
python3 scripts/castiron/custom_code_report.py report \
  --base 217ff2ea1e853040ba08c3c170e05586424386aa \
  --head 44f75644aa0f1dadb481a251a92b25600cbc6057 --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-44f75644aa0f
cat /tmp/castiron-custom-code-44f75644aa0f/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@saioai
saioai changed the base branch from main to codex/flag-descriptions-20261007 October 8, 2026 10:02
@saioai

saioai commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Please review commit d5ca5b4ee037221b07cd204c22abe95000405417 against this PR's current base. Check public-command behavior, preserved input/output contracts, errors, and cancellation. Distinguish code defects from the documented validation limits.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 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-10-09T08:57:42.447547Z 44f7564 New commits
🔒 Security Review ✅ Completed 2026-10-09T08:55:22.465188Z 44f7564 New commits
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: d5ca5b4ee0

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: d5ca5b4ee0

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ 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.

@saioai
saioai marked this pull request as ready for review October 8, 2026 17:20
@saioai
saioai requested a review from a team as a code owner October 8, 2026 17:20

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd1449a5cb

ℹ️ 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".

Comment thread pkg/custom/output_policy.go
Comment thread pkg/custom/image_loading_feedback.go
Comment thread pkg/custom/output_policy.go Outdated
Base automatically changed from codex/flag-descriptions-20261007 to main October 8, 2026 17:32

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af738605da

ℹ️ 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".

Comment thread pkg/custom/readable_errors.go
Comment thread pkg/custom/resource_summaries.go

@markstuart-oai markstuart-oai 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.

Reviewed cd44152959d582cab48e95c426b90d8de5d1a85c against 390a9c3d68e93f7348509ffec169bb5ab38d68cc. I found no blocking issue in output separation, quiet/verbose policy, stream ownership, save receipts, or manpage completion. The earlier receipt, image-progress, and startup-reporting findings are addressed. One P3 comment removes an unreachable error branch.

Hosted tests, build, artifact, lint, platform help, CodeQL, and Castiron checks passed. The exact-head Help compatibility workflow also passed. This was a source-only review; I did not run local tests, native consoles, recordings, or live API calls.

Comment thread pkg/custom/readable_output.go

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68a3e87171

ℹ️ 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".

Comment thread pkg/custom/list_navigation.go

@jbeckwith-oai jbeckwith-oai 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.

Reviewed deterministic output selection, quiet/verbose controls, error propagation and request IDs, stream cleanup, color and diagnostic routing, image feedback, and manpage output/lifecycle. No blocking findings; the previously reported issues appear addressed.

On the exact head, focused custom output/deterministic/manpage/request-ID/readable/table tests and public output/manpage/request-ID tests pass. Focused vet and changed-file gofmt checks are clean. Removing the quiet-mode table-hint guard caused TestRenderListNavigationPageHintPolicy to fail as expected; restored source passed. Hosted checks pass. I did not independently run native Windows tests.

@saioai
saioai added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 866d877 Oct 9, 2026
27 checks passed
@saioai
saioai deleted the codex/universal-output-20261008 branch October 9, 2026 16:26
Tmwakalasya pushed a commit to Tmwakalasya/openai-cli that referenced this pull request Oct 9, 2026
The existing upload alias requires `--file`; metadata and contents use
`retrieve` and `content`.
This adds a plain upload path, `get` for metadata, and `download` for
contents.
Help shows the workflow and gives runnable examples.

This inherits the merged output, stdin, and save policies from openai#392 and
openai#395.

### What changes

- Upload accepts one quoted local path and keeps purpose explicit.
- Files help lists upload, get, and download in workflow order.
- Shell completion supports the first upload path and preserves literal
leading `@` filenames.
- Bash completion also preserves colon-separated filename prefixes and
Readline's replacement suffix.
- Interactive uploads show returned values and a safely quoted,
read-only metadata command.
- Suggestions reuse the executable or development checkout, including
`go run` and `scripts/run`.
- Suggested commands preserve the selected project, organization, and
safe base URL. Sensitive overrides suppress the suggestion.
- Error-output options leave successful upload receipts unchanged.
Processing errors retain complete details through JSON inspection.
- Malformed known receipt fields use complete response output. Existing
null values and large integer timestamps remain supported.
- Interactive `get` shows complete metadata, full IDs, and UTC
timestamps.
- Existing names, flags, machine output, extraction, and download bytes
remain available.

### Commands

`get` and `download` are new routes. The existing `upload` route gains
positional paths.

```sh
openai files --help
openai files upload "upload space.txt" --purpose user_data
openai files get file-example
openai files download file-example --output "downloaded copy.txt"
openai files download file-example > copy.txt
openai files get file-example --format json  # complete metadata for scripts
cat upload.bin | openai files upload --file - --purpose user_data
```

Use one positional path or `--file PATH`. `create`, `retrieve`,
`content`, `-o`, and extraction options remain available.
Paths are literal. Quote a leading `@` in PowerShell, or use `./@name`.
Reload an existing completion adapter after updating the CLI.

Receipts and readable timestamps require terminal stdout and stderr,
text/auto output, and no extraction or raw output.
`--quiet` suppresses the upload receipt and retains selected metadata.
The suggested inspection command never selects a download destination or
overwrites the upload source.
Keep the same environment when copying it; credentials are never
included in suggestions.
Development hints retain their checkout with `go -C CHECKOUT run
./cmd/openai`.

After an uncertain upload, inspect its known ID or recent same-project
files before uploading again.
Upload acceptance does not imply processing completion. Streamed uploads
do not retry automatically.
The [Files recovery
guide](https://github.com/openai/openai-cli/blob/bcd5af538bf254c80dd5884a1c1cbbb37389bc96/docs/files.md#recover-from-a-failed-command)
gives concrete recovery steps.

### Code

`pkg/custom` adds routes, request-context capture, and terminal
presentation over existing decorated handlers.
`pkg/transformers` formats file timestamps without changing machine
data.
`internal/autocomplete` opts upload into first-path completion and
preserves literal filenames across four shell adapters.
`internal/clihelp` keeps fallback example notes out of command-owned
examples.
Files receipt hints can follow one recognized Go parent through platform
process metadata.
Unknown callers, lookup errors, cancellation, or unavailable checkout
paths omit the optional hint.
Image and setup callers keep their existing shell detection.
Existing terminal escaping, shell quoting, input handling, save policy,
and download code remain in use.
No new package, external dependency, generated-source change, or startup
change is required against main.

### Tested

Candidate: `bcd5af5` against main `866d8770`.
Its complete source tree matches tested `48aee722`; the final merge
changes ancestry only.
Local checks used Go 1.26.9 on macOS arm64 with synthetic loopback APIs.
The latest two findings reproduced in eight public processes before
correction.
Independent review checked `3ae27da` and executed 31 corrected public
processes.
That matrix covered 24 uploads and seven metadata requests.
`go run` and copied hints passed through Bash, zsh, fish, and PowerShell
on macOS.
`scripts/run` passed in Bash and zsh.
An absolute `scripts/run` invocation remained copyable from outside the
checkout. Unknown wrappers did not use a misleading SHELL value.
Malformed, nullable, omitted, signed, and large fields retained their
expected output, including a 17 MiB fallback.

At `3ae27da`, custom/transformer checks passed 165 results, public
Files/help passed 109, and manpage integration passed 18.
None of those runs skipped tests.
Windows and Linux custom-package test compilation passed at `3ae27da`.
Native ancestry checks remain unverified on those systems.
At runtime `10c10cb`, eight independent binary probes passed, including
partial-page and receipt-write failures.
That composition passed 128 public Files/local-utility results and 14
additional output/routing results.
The custom run passed 193 results; five unavailable-shell checks passed
after adding the existing cached shells to PATH.
That focused rerun passed 29 results without skips.
Go module verification passed. The trusted budget passed with 21/1000
custom lines against current main `866d8770`.
Earlier focused vet passed at `3ae27da`.
Earlier Bash completion coverage passed 74 results at `520dc58`; the
completion source remains unchanged.
The earlier three findings retain their separately recorded before/after
and context/byte-preservation evidence.
The previous published head `ae2ad9e` passed hosted tests, builds,
platform help, permissions, cancellation, and baseline checks.
See the [CI
run](https://github.com/openai/openai-cli/actions/runs/37907274504) and
[platform help
run](https://github.com/openai/openai-cli/actions/runs/37907274438).
Current-head CI will run after publication and retargeting to main.
At `48aee722`, the final table-policy update passed 55 focused results
and seven public Files results, with zero skips.
Independent review confirms all 44 Files feature files remain unchanged
through the parent update and final main alignment.
Live API acceptance and native Windows Files workflows remain
unverified.
PowerShell execution on macOS does not establish Windows filesystem
behavior.

The inherited save policy stages explicit ordinary downloads and reports
successful saves on stderr.
Quiet and structured error modes suppress optional save receipts;
receipt-write failures return nonzero after retaining completed files.
Final local copies remain non-atomic. Redirection and automatic or
special destinations can retain partial output.
Malformed HTTP 200 metadata can still return success. The guide explains
these limits without promising rollback.

### Demo

macOS arm64, Bash, Menlo 18px, terminal replay, and a synthetic loopback
API.
Before: Output production `7901147`. After: Files `2d482e3`.
The recorded ordinary workflow remains unchanged in this candidate.
Separate public-process checks cover the later development-launcher and
malformed-response corrections.
Workflow uses 110×46 cells; discovery uses 110×54 cells.

The workflow verifies twelve requests and eight exact text/binary
download comparisons.

![Files workflow before and
after](https://github.com/user-attachments/assets/8ce1c9da-72e4-415c-878e-31df09eb6d8b)

Before:

![Before: existing Files
commands](https://github.com/user-attachments/assets/759af276-1175-4c27-b2ad-342289a22f65)

After:

![After: upload, inspect, and
download](https://github.com/user-attachments/assets/ca42f90b-ac0e-4584-8432-afd91dd1fb80)

Command discovery verifies workflow ordering, runnable examples, and
zero API requests.

![Files command discovery before and
after](https://github.com/user-attachments/assets/9305ea4f-ae35-446a-b9d9-3d7c6314b8eb)

Before:

![Before: Files
help](https://github.com/user-attachments/assets/96377ca2-151a-4b18-bd0f-c41552bea4d4)

After:

![After: workflow ordering and
examples](https://github.com/user-attachments/assets/5e0637e1-fa0d-4b81-aae4-b2706bdab9ff)

[Recording
recipes](https://github.com/openai/openai-cli/blob/2d482e3f62adf109bca5dfbb8bee6565c277701e/scripts/demos/files-workflow/README.md).
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.

4 participants