Skip to content

fix(cli): honor token controls for builtin documents - #7897

Merged
morluto merged 1 commit into
mainfrom
codex/builtin-document-token-controls
Oct 29, 2026
Merged

morluto merged 1 commit into
mainfrom
codex/builtin-document-token-controls

Conversation

@morluto

@morluto morluto commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

--llms-full --token-count previously printed the complete manifest, and --token-limit 1 ignored the requested window. Built-in manifest, index and schema documents now honor the caller's token controls. Fixes #7581.

Problem and expected behavior

Incur emits built-in documents outside command-result handlers, bypassing REA's token output owner. A requested count or text window must apply to the selected emitted document.

Change and scope

Capture only the SDK's built-in document output when token controls apply, then use the existing token estimator and text-window projection. Retain built-in help/version/completion precedence and non-JSONL SDK error rendering. No target execution or new authority is introduced.

Contract and boundary impact

  • Semantic owner and changed stage: CLI SDK-output delivery; ordinary result formatting remains owned by its existing path.
  • Contribution scope and maintainer decision: existing CLI output behavior, not applicable.
  • CLI and MCP: built-in CLI document token count/window now reflects the requested document. MCP contracts are unchanged.
  • Provider, Evidence and cleanup: unchanged; these checks need no provider.
  • Generated metadata, package and installation: no authored generated output changes.

Evidence and regression coverage

The built CLI regression checks full/index manifests and schemas, text windows, JSON counts, structured-window rejection, invalid schema diagnostics, and help/version/completion precedence. It would fail on the old behavior that emitted a full document instead of a count or window.

Validation performed

  • npm run test:focused -- tests/acceptance/cliBuiltinDocumentTokens.test.ts — 1 test passed.
  • npm run test:focused -- tests/boundary/cli/cliTokenWindowOutput.test.ts tests/boundary/cli/jsonLinesOutput.test.ts — 68 tests passed.
  • npm run check:fast and git diff --check — passed.

Compatibility, safety, and release

Token-controlled built-in requests now return their requested count/window rather than a complete document. No provider or target was used; non-macOS behavior was not separately verified.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable defect was established.

Summary

Built-in manifests and schemas now pass through REA's token count and text-window output path when requested.

  • Built-in CLI documents honor token counts and text windows.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CLI arguments] --> B{Built-in document with token controls?}
  B -->|Yes| C[Capture SDK output]
  B -->|No| D[Existing output path]
  C --> E{SDK exit status}
  E -->|Success| F[Count tokens or apply text window]
  E -->|Failure| G[Keep SDK diagnostics]
  F --> H[Write stdout]
  G --> H
Loading

Reviews (1) · Last reviewed commit: "fix(cli): honor token controls for built..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review October 28, 2026 20:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T21:03:58.901468Z 42df93f Draft marked ready
ℹ️ 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.

@morluto
morluto merged commit c7722c8 into main Oct 29, 2026
43 of 44 checks passed
@morluto
morluto deleted the codex/builtin-document-token-controls branch October 29, 2026 00:11
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Manifest and schema requests emit complete documents when token controls are selected

1 participant