Skip to content

fix(cli): honor configured output token limits - #3385

Open
drormeir wants to merge 2 commits into
ultraworkers:mainfrom
drormeir:fix/output-token-limit
Open

drormeir wants to merge 2 commits into
ultraworkers:mainfrom
drormeir:fix/output-token-limit

Conversation

@drormeir

Copy link
Copy Markdown
Contributor

Summary

The CLI loads plugins.maxOutputTokens but previously ignored it when constructing conversation requests. A configured limit of 512 or 1024 still produced max_tokens: 64000 for the tested models. Local OpenAI-compatible servers with smaller context limits can reject such requests.

Carry the existing merged setting through runtime construction into the conversation client and apply the existing max_tokens_for_model_with_override helper on every request. Requests after tool results use the same configured limit. Omitting the setting preserves the existing per-model default. Document configuration in USAGE.md.

Add four HTTP-level integration tests: configured limits across an Anthropic tool roundtrip, project-local precedence over user configuration, default preservation, and an OpenAI-compatible tool roundtrip. The latter verifies both outgoing limits and that the second request contains the actual file-read result. All tests use temporary workspaces with spaces, isolated credentials/configuration, loopback mocks, and portable fixtures; no live model server or paid API is required. Each Claw subprocess has a 60-second deadline, with termination and captured output on timeout.

This PR changes three files and is based on upstream main at 6a29e0888308f0aff9724c108edfba5106a2f9bf (v0.1.13), which already includes the merged Windows compatibility fixes from #3378. A separate preparatory commit adds the existing current-directory lock to four CLI tests that depend on process-wide cwd, including subprocess launchers. This addresses Windows cleanup races without changing production behavior. No generated state or tool-alias/repeated-read changes are included.

Compatibility: there are no new flags, dependencies, configuration keys, or JSON response fields. Existing configured overrides now take effect, which is the intended behavior change. This does not automatically query server limits, validate the selected value against a server's remaining context, or configure separate sub-agent/claw-analog clients. Select a positive output limit that leaves room for the request input.

Anti-slop triage

  • Classification: actionable-fix.
  • Evidence: with the four new tests and unmodified upstream CLI code, the three configured-limit cases fail because 64000 is sent instead of 512 or 1024; the default case passes. With the CLI fix, all four pass. Both provider wire formats are exercised across a real tool roundtrip.
  • Non-destructive review result: candidate for maintainer review; local Windows verification passed and hosted CI remains pending. The implementation reuses the existing configuration merge and output-limit helper. No remote PR or issue was opened, merged, or closed during preparation.

Verification

  • Targeted tests/docs checks ran, or the gap is explicitly recorded.
  • git diff --check passes.
  • No live secrets, tokens, private logs, or unrelated generated churn are included.

Completed locally on Linux with Rust 1.99.1 for the final source:

  • Full workspace suite (cargo test --workspace --locked --no-fail-fast): 1,837 passed, zero failed, one existing ignored live-provider test. This includes 227 CLI unit tests and the four output-token integration tests.
  • Strict workspace Clippy (cargo clippy --workspace --all-targets --locked -- -D warnings): passed.
  • Formatting and strict Clippy for the CLI package and all its targets: passed.
  • Forced-stall control: the subprocess deadline terminated the child and reported a timeout; the temporary injection was removed and all 231 tests passed again.
  • Documentation consistency, release-readiness, and diff whitespace checks: passed.
  • The consolidated patch reproduces the complete original-plus-follow-up patch sequence byte-for-byte for all three changed files.

Regression evidence from the original feature validation: the three configured-limit cases fail on unmodified upstream request construction (64000 instead of the configured limit), while the default case passes.

Completed on native Windows on 2026-11-11:

  • Full workspace tests with normal temporary paths: passed, exit code 0.
  • Full workspace tests with actual 8.3 temporary paths: passed, exit code 0.
  • Formatting: passed, exit code 0.
  • Strict workspace Clippy: passed, exit code 0.

These Windows results cover the complete source included in the consolidated patch: output-token support, its test deadlines, and all four current-directory test guards. The source was reconstructed from the exact patch sequence applied before the successful local run. No additional test skips were introduced.

Pending: GitHub-hosted CI for this PR. Local Windows verification does not establish a hosted CI result.

Resolution gate

  • If this PR resolves an issue, the issue number and fix evidence are linked. No issue number is claimed; reproduction and regression evidence are recorded above.
  • If this PR should not merge, the rejection/defer rationale is evidence-backed and does not rely on vibes. Local Windows verification is complete; hosted CI remains the outstanding verification gate.
  • I did not merge/close remote PRs or issues from an automation lane without owner approval.

@drormeir drormeir changed the title Fix (CLI): Honor configured output token limits fix (cli): honor configured output token limits Nov 11, 2026
@drormeir drormeir changed the title fix (cli): honor configured output token limits fix(cli): honor configured output token limits Nov 11, 2026
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.

1 participant