[PR #2057] [CLOSED] serve: an opt-in "stream_all_tool_args" sends a tool call's non-string argument in pieces as the model writes it (#1666) #3831

Closed
opened 2026-11-07 15:31:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2057
Author: @psqq
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: f-1666-stream-all-tool-args


📝 Commits (2)

  • e8f12ee serve: an opt-in "stream_all_tool_args" sends a tool call's non-string argument in pieces as the model writes it
  • 4506d64 serve: stream_all_tool_args streams only a value that is JSON text; the rest goes out quoted as before

📊 Changes

5 files changed (+331 additions, -25 deletions)

View changed files

📝 docs/DETAILS.md (+26 -7)
📝 serve/frontend.py (+64 -17)
📝 serve/runconfig.py (+2 -0)
📝 serve/server.py (+7 -1)
➕ serve/test_tool_args_stream.py (+232 -0)

📄 Description

Resolves #1666 (the keep-alive that already covers the idle timeout is in main as 14b9dd2e; this is the
other half: the argument itself stops being silence)

Summary

A tool-call parameter whose declared type is not a string - an array, an object, a number - is held until
</parameter> and goes out as one tool_args piece, so an app that shows the arguments as they arrive sits on
{"edits": for minutes and then shows the finished call at once. "stream_all_tool_args": true in
strata-<model>.json sends that text as it is written, the way a string parameter already does. Off by default.

What changed

  • serve/frontend.py: OutputParser gains stream_all_args. In the raw state the value's JSON text passes
    through as it arrives, holding back a possible partial </parameter> (the same _hold the str state uses) and a
    candidate end whose follower has not arrived yet, so #210 still holds: a </parameter> inside the value stays part
    of the value. When the parameter ends, only what has not gone out yet is sent. _close_scan closes a call cut
    inside such a value with the rest of that text, not with a JSON string of it.
  • serve/server.py: the config key stream_all_tool_args (must be true or false) reaches the parser.
  • serve/runconfig.py: the key is editable from the About tab's Model settings card.
  • docs/DETAILS.md: a bullet with the measurements; the streaming bullet now says a non-string parameter waits for
    its end unless the switch is on.
  • serve/test_tool_args_stream.py: 8 cases.

What it leaves alone: without the key the stream is byte-identical to before; string parameters are untouched; the
final tool_call of a call that was streamed is still not sent again, so the pieces a client joins are the
arguments; the value is still parsed and checked at the end, so a broken argument is still the error it was. With it
on, what the model wrote is what goes out, so the whitespace is no longer normalized.

Extra Notes

Parser, an edit call whose edits is an array of two objects (217 characters), fed at a token width of 8: 15
argument pieces with one of 217 without the switch, 44 pieces with none longer than 9 with it. End to end over
/v1/chat/completions with MockEngine (one token per step): 17 argument deltas, largest 247 characters, without
the switch; 263 deltas, largest 8, with it; finish_reason: tool_calls and the joined pieces equal to the reported
arguments in both cases. On a real agent turn (Qwen3.8 Flash-Next IQ3_S, an edit call with two edits): 27 argument
deltas, 26 of them carrying 78 characters in all and one carrying 3,145 - 97% of the arguments in a single piece.
Checked with python -m unittest serve.test_tool_args_stream serve.test_parser_track serve.test_reasoning_tools serve.test_reasoning_rescue serve.test_frontend serve.test_runconfig serve.test_structured (87 tests, OK) and
serve.test_server (291 tests; the only errors are the three that import the regex module, the same on an
unmodified tree). Not tested: Windows and AMD paths beyond their suites.

🤖 Fully generated by an LLM (qwen3.8-flash-next-iq3_s)


🔄 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/2057 **Author:** [@psqq](https://github.com/psqq) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `f-1666-stream-all-tool-args` --- ### 📝 Commits (2) - [`e8f12ee`](https://github.com/Niko1221/Strata/commit/e8f12ee646a1a90cc6c5ecbe1fa1002f5695e234) serve: an opt-in "stream_all_tool_args" sends a tool call's non-string argument in pieces as the model writes it - [`4506d64`](https://github.com/Niko1221/Strata/commit/4506d6447d474da142060ff9babd4e711a61dff7) serve: stream_all_tool_args streams only a value that is JSON text; the rest goes out quoted as before ### 📊 Changes **5 files changed** (+331 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+26 -7) 📝 `serve/frontend.py` (+64 -17) 📝 `serve/runconfig.py` (+2 -0) 📝 `serve/server.py` (+7 -1) ➕ `serve/test_tool_args_stream.py` (+232 -0) </details> ### 📄 Description Resolves #1666 (the keep-alive that already covers the idle timeout is in main as 14b9dd2e; this is the other half: the argument itself stops being silence) ## Summary A tool-call parameter whose declared type is not a string - an array, an object, a number - is held until `</parameter>` and goes out as one `tool_args` piece, so an app that shows the arguments as they arrive sits on `{"edits":` for minutes and then shows the finished call at once. `"stream_all_tool_args": true` in `strata-<model>.json` sends that text as it is written, the way a string parameter already does. Off by default. ## What changed - `serve/frontend.py`: `OutputParser` gains `stream_all_args`. In the `raw` state the value's JSON text passes through as it arrives, holding back a possible partial `</parameter>` (the same `_hold` the `str` state uses) and a candidate end whose follower has not arrived yet, so #210 still holds: a `</parameter>` inside the value stays part of the value. When the parameter ends, only what has not gone out yet is sent. `_close_scan` closes a call cut inside such a value with the rest of that text, not with a JSON string of it. - `serve/server.py`: the config key `stream_all_tool_args` (must be true or false) reaches the parser. - `serve/runconfig.py`: the key is editable from the About tab's Model settings card. - `docs/DETAILS.md`: a bullet with the measurements; the streaming bullet now says a non-string parameter waits for its end unless the switch is on. - `serve/test_tool_args_stream.py`: 8 cases. What it leaves alone: without the key the stream is byte-identical to before; string parameters are untouched; the final `tool_call` of a call that was streamed is still not sent again, so the pieces a client joins are the arguments; the value is still parsed and checked at the end, so a broken argument is still the error it was. With it on, what the model wrote is what goes out, so the whitespace is no longer normalized. ## Extra Notes Parser, an `edit` call whose `edits` is an array of two objects (217 characters), fed at a token width of 8: 15 argument pieces with one of 217 without the switch, 44 pieces with none longer than 9 with it. End to end over `/v1/chat/completions` with `MockEngine` (one token per step): 17 argument deltas, largest 247 characters, without the switch; 263 deltas, largest 8, with it; `finish_reason: tool_calls` and the joined pieces equal to the reported arguments in both cases. On a real agent turn (Qwen3.8 Flash-Next IQ3_S, an `edit` call with two edits): 27 argument deltas, 26 of them carrying 78 characters in all and one carrying 3,145 - 97% of the arguments in a single piece. Checked with `python -m unittest serve.test_tool_args_stream serve.test_parser_track serve.test_reasoning_tools serve.test_reasoning_rescue serve.test_frontend serve.test_runconfig serve.test_structured` (87 tests, OK) and `serve.test_server` (291 tests; the only errors are the three that import the `regex` module, the same on an unmodified tree). Not tested: Windows and AMD paths beyond their suites. *🤖 Fully generated by an LLM (qwen3.8-flash-next-iq3_s)* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:31:04 +07:00
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#3831
No description provided.