[PR #4230] [TUI] strata connect: use bigger output caps on bigger context windows #4964

Open
opened 2026-11-07 16:31:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4230
Author: @qwertie
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: connect-output-cap


📝 Commits (1)

  • b9ef6b4 Bug fix: strata connect capped every reply at 4,096 tokens

📊 Changes

2 files changed (+29 additions, -8 deletions)

View changed files

📝 strata_cli/launch/harness.py (+16 -7)
📝 tests/terminal/test_launch.py (+13 -1)

📄 Description

Problem and result

strata connect writes a 4,096-token output cap into every config it makes[1], no matter how big the context window is.

Thinking counts against the cap, so on a wide window a long reply is cut off. The usual case is a whole file written in one tool call.

On my server with Claude Code set up from strata connect claude-code: a sub-agent writing one source file hit the cap three times in a row. Claude Code threw each cut-off reply away and asked again. The engine log:

strata serve: prompt 36438 tokens = 36393 reused + 45 read in 670 ms (67.2 tok/s), 4096 generated in 99426 ms (41.2 tok/s)
strata serve: prompt 37391 tokens = 36433 reused + 958 read in 2403 ms (398.7 tok/s), 4096 generated in 101750 ms (40.3 tok/s)
strata serve: prompt 42316 tokens = 42272 reused + 44 read in 586 ms (75.0 tok/s), 4096 generated in 88599 ms (46.2 tok/s)

Each retry's prompt reuses the history only up to the start of the dropped reply. The three cut-off replies cost 290 s of decoding. The model's next reply began: "The long single write keeps getting truncated. I'll build engine.ts in three smaller chunks."

After this change the cap grows with the window (the tested window is still 4096):

Context Output cap before after
up to 32,768 4,096 4,096
65,536 4,096 8,192
131,072 4,096 16,384
204,800 4,096 25,600
524,288 4,096 65,536

None for this cause. #2708 (closed in the 0.2.0-beta reset) reported a related symptom: Codex replies ending at max_output_tokens.

Approach

 class Target:
     input_limit = max(1024, context - OUTPUT_CAP)        # unchanged
+    output_cap  = max(OUTPUT_CAP, context // 8)

The five configs that set an output cap use Target.output_cap instead of OUTPUT_CAP. The Claude Code limits note now prints the actual value instead of a hard-coded 4096. An eighth of the window has no upper limit, because I've seen long thinking alone exceeding 32K in Qwen3.8 27B and I'm unsure if that ever happens in Qwen-flash-next.

Compatibility:

  • At the tested window (32,768) and below, every config is byte-identical. The existing tests check those values and pass unchanged.
  • The input limit, and with it where each app compacts its conversation (compact_at), is unchanged at every size. So the configs for wider windows change only in their output cap.
  • The server still fits each request's cap to the room its prompt leaves (fit_max_tokens). So a request near the end of the window is not refused because of the larger cap.

Validation

Passed:

  • python -m unittest tests.terminal.test_launch on b9ef6b46, Windows 11, Python 3.14: 115 tests OK (1 skipped). This includes the new test_the_output_cap_grows_with_the_window (caps at 8K to 512K, the Claude Code env and limits note at 204,800, opencode's limits at 128K).
  • python strata.py connect claude-code --url http://127.0.0.1:8080 --context 204800: CLAUDE_CODE_MAX_OUTPUT_TOKENS is 4096 on 4b9e05a2 (main), 25600 on b9ef6b46.

Failed:

  • python -m unittest discover -s tests/terminal hangs (stopped after 25 minutes), both on unmodified main (4b9e05a2) and on a local branch that has this commit merged with others. Both runs hang in tests/terminal/test_runtime.py: at test_failed_generation_probe_does_not_report_ready on main, at test_failed_new_port_rolls_back_previous_owned_launch on the local branch. Those tests pass when run alone on both. An earlier quiet run of the suite on this branch alone also hung (no test names printed). pytest was not installed in this environment.

Not run:

  • A Claude Code session with a freshly generated config. I measured the problem above on the same machine with the 4,096 config, then set the cap by hand. A full agent run has not been measured since.
  • No engine, server or GPU code changed, so no backend builds apply.

Limits

  • An eighth of the window is a judgement, not a measurement: it leaves most of the window for the conversation. I have no measured distribution of Qwen3.8-Flash-Next's uncapped reply lengths. The log above comes from replies capped at 4,096.
  • Near the end of a wide window an app may ask for more than is left. The server's default (fit_max_tokens) shortens such a request. A server started with --no-fit-max-tokens (or "fit_max_tokens": false) answers it with a 400, so with that setting the larger cap makes 400s more likely late in a long conversation.

[1] into Claude Code's CLAUDE_CODE_MAX_OUTPUT_TOKENS, opencode's limit.output, and maxTokens for pi, omp and openclaw

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4230 **Author:** [@qwertie](https://github.com/qwertie) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `connect-output-cap` --- ### 📝 Commits (1) - [`b9ef6b4`](https://github.com/Niko1221/Strata/commit/b9ef6b46fab244a3624d40199d050f59941e3d54) Bug fix: strata connect capped every reply at 4,096 tokens ### 📊 Changes **2 files changed** (+29 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `strata_cli/launch/harness.py` (+16 -7) 📝 `tests/terminal/test_launch.py` (+13 -1) </details> ### 📄 Description ## Problem and result `strata connect` writes a 4,096-token output cap into every config it makes[1], no matter how big the context window is. Thinking counts against the cap, so on a wide window a long reply is cut off. The usual case is a whole file written in one tool call. On my server with Claude Code set up from `strata connect claude-code`: a sub-agent writing one source file hit the cap three times in a row. Claude Code threw each cut-off reply away and asked again. The engine log: ```text strata serve: prompt 36438 tokens = 36393 reused + 45 read in 670 ms (67.2 tok/s), 4096 generated in 99426 ms (41.2 tok/s) strata serve: prompt 37391 tokens = 36433 reused + 958 read in 2403 ms (398.7 tok/s), 4096 generated in 101750 ms (40.3 tok/s) strata serve: prompt 42316 tokens = 42272 reused + 44 read in 586 ms (75.0 tok/s), 4096 generated in 88599 ms (46.2 tok/s) ``` Each retry's prompt reuses the history only up to the start of the dropped reply. The three cut-off replies cost 290 s of decoding. The model's next reply began: "The long single write keeps getting truncated. I'll build `engine.ts` in three smaller chunks." After this change the cap grows with the window (the tested window is still 4096): | Context | Output cap before | after | |---|---|---| | up to 32,768 | 4,096 | 4,096 | | 65,536 | 4,096 | 8,192 | | 131,072 | 4,096 | 16,384 | | 204,800 | 4,096 | 25,600 | | 524,288 | 4,096 | 65,536 | ## Related discussion None for this cause. #2708 (closed in the 0.2.0-beta reset) reported a related symptom: Codex replies ending at `max_output_tokens`. ## Approach ```diff class Target: input_limit = max(1024, context - OUTPUT_CAP) # unchanged + output_cap = max(OUTPUT_CAP, context // 8) ``` The five configs that set an output cap use `Target.output_cap` instead of `OUTPUT_CAP`. The Claude Code limits note now prints the actual value instead of a hard-coded 4096. An eighth of the window has no upper limit, because I've seen long thinking alone exceeding 32K in Qwen3.8 27B and I'm unsure if that ever happens in Qwen-flash-next. Compatibility: - At the tested window (32,768) and below, every config is byte-identical. The existing tests check those values and pass unchanged. - The input limit, and with it where each app compacts its conversation (`compact_at`), is unchanged at every size. So the configs for wider windows change only in their output cap. - The server still fits each request's cap to the room its prompt leaves (`fit_max_tokens`). So a request near the end of the window is not refused because of the larger cap. ## Validation **Passed:** - `python -m unittest tests.terminal.test_launch` on b9ef6b46, Windows 11, Python 3.14: 115 tests OK (1 skipped). This includes the new `test_the_output_cap_grows_with_the_window` (caps at 8K to 512K, the Claude Code env and limits note at 204,800, opencode's limits at 128K). - `python strata.py connect claude-code --url http://127.0.0.1:8080 --context 204800`: `CLAUDE_CODE_MAX_OUTPUT_TOKENS` is `4096` on 4b9e05a2 (main), `25600` on b9ef6b46. **Failed:** - `python -m unittest discover -s tests/terminal` hangs (stopped after 25 minutes), both on unmodified main (4b9e05a2) and on a local branch that has this commit merged with others. Both runs hang in `tests/terminal/test_runtime.py`: at `test_failed_generation_probe_does_not_report_ready` on main, at `test_failed_new_port_rolls_back_previous_owned_launch` on the local branch. Those tests pass when run alone on both. An earlier quiet run of the suite on this branch alone also hung (no test names printed). `pytest` was not installed in this environment. **Not run:** - A Claude Code session with a freshly generated config. I measured the problem above on the same machine with the 4,096 config, then set the cap by hand. A full agent run has not been measured since. - No engine, server or GPU code changed, so no backend builds apply. ## Limits - An eighth of the window is a judgement, not a measurement: it leaves most of the window for the conversation. I have no measured distribution of Qwen3.8-Flash-Next's uncapped reply lengths. The log above comes from replies capped at 4,096. - Near the end of a wide window an app may ask for more than is left. The server's default (`fit_max_tokens`) shortens such a request. A server started with `--no-fit-max-tokens` (or `"fit_max_tokens": false`) answers it with a 400, so with that setting the larger cap makes 400s more likely late in a long conversation. [1] into Claude Code's `CLAUDE_CODE_MAX_OUTPUT_TOKENS`, opencode's `limit.output`, and `maxTokens` for pi, omp and openclaw 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4964
No description provided.