[GH-ISSUE #403] DeepSeek: a long string tool argument is held until its closing tag, so clients time out while the model is still writing #156

Closed
opened 2026-10-29 21:21:45 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @talisp on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/403

In short

The problem. When DeepSeek writes a long string argument in a tool call, for example the content of a file for a write tool, Maya sends the call's name and its short arguments right away. The long value itself is held until its closing tag. While the model keeps generating, the client receives no data. A client with a stream-idle limit cancels a request that is working fine, then retries it.

What it cost us. DeepSeek-V4.1-Flash wrote at ~16-18 tok/s on our card. DeepSeek Harness (pi-ai) gave up with pi-ai stream idle timeout after 300000ms after about 5,000 tokens of the file, and retried. One agent step made 1 attempt + 5 retries over ~31 minutes and then failed. The prompt was reused from the cache each time, so the cost was the repeated generation, not prompt reading.

Where it comes from. It is reproducible offline, without a server or GPU, with Maya's own parser:

  • DeepSeek (DSML): 0 argument events while the value is open. Everything arrives at the closing tag.
  • GLM, with the tool schema normalized as the HTTP path does: 20 argument events for the same 20 pieces. GLM is not affected. The gap is in the DSML path only.

How the sibling projects handle it.

  • Strata's server already sends a keep-alive at least every 10 s when a held-back tool argument keeps the stream quiet (KEEPALIVE_S).
  • Strata #1951 found that a keep-alive written as an SSE comment does not reset some clients' idle timers. Those clients needed a real (empty) chunk.
  • Xolotl turns tool streaming off for DeepSeek entirely, so the whole call arrives at the end.
  • Maya's DeepSeek path has neither the incremental string path nor the held-value keep-alive.

The proposal, in short:

  1. Stream DSML string="true" values as they are generated, as the GLM path already does for string arguments.
  2. As a quick, independent safety net, port Strata's held-value keep-alive, sent as an empty chunk rather than an SSE comment.

We raised the client's idle limit to 20 minutes as a workaround, but this only hides the problem. The technical details follow, for whoever implements or reviews this.


Technical notes

1. Versions and environment

Component Value
Maya deployment v1.1.21, 451f9cb6a21ea65673bdde2e57b4a670ae2b8859
Upstream main inspected 25deec505b525212e05faa58697d9d2b7d17fdb3
serve/frontend.py blob 85cb11fb2c6adcb8630aabe93c8aacb509bd3fec, identical in the deployment and in that main
Model / engine deepseek-v4.1-flash, unsloth UD-Q8_K_XL, maya-ds4, 262,144 context
Hardware 1× NVIDIA L40S-48Q (vGPU, 48 GB), 32 vCPU, ~504 GB RAM, Linux
Client DeepSeek Harness 0.2.1-rc.2 (Windows), pi-ai provider over OpenAI Chat Completions, streaming, idle limit 300,000 ms
Decode during the incident ~16-18 tok/s

2. The incident

The agent was writing a source file with a tool named write; the file content was a string argument. The step began at 21:03:26 and failed at 21:34:15 local time, after 1 attempt + 5 retries. The server's monitor showed the following attempts:

Request start Status Prompt tokens Reused Output before stop Decode Duration
21:03:26 Stopped 100,038 99,905 4,978 16.3 tok/s 307.2 s
21:08:33 Stopped 100,038 100,037 5,005 16.5 tok/s 302.7 s
21:13:37 Stopped 100,038 100,037 5,059 16.5 tok/s 307.7 s
21:18:47 Stopped 100,038 100,037 5,080 16.5 tok/s 307.7 s
21:23:58 Stopped 100,038 100,037 5,002 16.4 tok/s 305.2 s
  • Each attempt stopped about 300 s in, which is exactly the client's idle limit.
  • The "output before stop" column is what was generated before the cancel, not the file's full size.
  • The engine log shows the same ~100K prompts, ~5K generations and ~300 s decodes.
  • No sub-agents were in that session, and this is not the slot problem of #375 / #394: the prompt was reused every time.
  • We did not capture the live SSE stream. The offline reproduction below shows the mechanism.

3. Offline reproduction (no server, model or GPU)

Save as repro_maya_tool_argument_streaming.py and run it with the project's venv. It loads serve/frontend.py only.

python -B repro_maya_tool_argument_streaming.py --repo .
python -B repro_maya_tool_argument_streaming.py --repo . --require-incremental   # exit 1 while the bug is there
"""Offline parser reproduction. Loads frontend.py only; starts no server or GPU."""
from __future__ import annotations
import argparse, importlib.util, json, sys
from pathlib import Path

OPENAI_TOOLS = [{"type": "function", "function": {"name": "write", "parameters": {"type": "object",
                 "properties": {"path": {"type": "string"}, "content": {"type": "string"}}}}}]


def run_case(frontend, label, dsml, tools):
    parser = frontend.OutputParser(thinking=False, tools=tools, stream_tools=True, dsml=dsml)
    pieces = ['linha ção "x" \\ {json} ' * 12 + "\n"] * 20
    if dsml:
        tag = frontend.DSML
        prefix = (f'<{tag} calls>\n<{tag} invoke name="write">\n'
                  f'<{tag} parameter name="path" string="true">a.txt</{tag} parameter>\n'
                  f'<{tag} parameter name="content" string="true">')
        suffix = f'</{tag} parameter>\n</{tag} invoke>\n</{tag} calls>'
    else:
        prefix = ('<tool_call>write<arg_key>path</arg_key><arg_value>a.txt</arg_value>'
                  '<arg_key>content</arg_key><arg_value>')
        suffix = '</arg_value></tool_call>'
    events = parser.feed(prefix)
    during = []
    for piece in pieces:
        during.extend(parser.feed(piece))
    events += during + parser.feed(suffix) + parser.finish()
    calls = [e.call for e in events if e.kind == "tool_call"]
    args = [e for e in during if e.kind == "tool_args" and e.text]   # real argument data, not just an event
    return {"case": label, "input_chunks": len(pieces), "input_characters": sum(map(len, pieces)),
            "argument_events_before_closing": len(args),
            "argument_characters_before_closing": sum(len(e.text) for e in args),
            "final_content_matches": bool(calls) and calls[-1].arguments.get("content") == "".join(pieces)}


def reproduce(frontend):
    # As the HTTP path does: OutputParser takes normalized tool dicts, not the API's {type, function} wrappers.
    _, normalized, _ = frontend.openai_to_messages({"messages": [{"role": "user", "content": "parser test"}],
                                                    "tools": OPENAI_TOOLS})
    return [run_case(frontend, "DSML / normalized string schema", True, normalized),
            run_case(frontend, "GLM / normalized string schema", False, normalized),
            run_case(frontend, "CONTROL: GLM / API wrappers passed directly", False, OPENAI_TOOLS),
            run_case(frontend, "CONTROL: GLM / no schema", False, None)]


def load_frontend(repo):
    filename = Path(repo).resolve() / "serve" / "frontend.py"
    spec = importlib.util.spec_from_file_location("_maya_frontend_stream_repro", filename)
    module = importlib.util.module_from_spec(spec)
    sys.modules[spec.name] = module          # needed by dataclasses with annotations
    spec.loader.exec_module(module)
    return module


def main():
    ap = argparse.ArgumentParser(description=__doc__)
    ap.add_argument("--repo", type=Path, default=Path("."))
    ap.add_argument("--require-incremental", action="store_true")
    a = ap.parse_args()
    rows = reproduce(load_frontend(a.repo))
    print(json.dumps(rows, ensure_ascii=True, indent=2))
    if not all(r["final_content_matches"] for r in rows):
        return 2
    if a.require_incremental and any(r["argument_events_before_closing"] == 0 for r in rows[:2]):
        return 1
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Results on v1.1.21 and on main 25deec5, with 20 pieces totalling 5,540 characters:

Case Argument events while the value is open Final content matches
DSML, schema normalized by openai_to_messages() 0 yes
GLM, schema normalized by openai_to_messages() 20 yes
Control: GLM, API wrappers passed straight to OutputParser 0 yes
Control: GLM, no schema 0 yes

The two controls explain how a naive test can make GLM look affected. OutputParser expects the normalized {name, parameters} dicts that the HTTP path produces, not the public {type, function} wrappers. With the server's normalization, GLM streams its string arguments.

4. Where the value is held

Links are pinned to 25deec5.

  • DsmlRewriter._plain(): while in_param is set, the text goes to parameter_text and the method returns "".
  • DsmlRewriter._tag() releases the value at </|DSML| parameter>.
    • For string="true", it is json.dumps(parameter_text) with < replaced by <, so that literal legacy delimiters survive the rewrite to GLM's form.
    • Inside a parameter, other DSML tags are literal data, as in the reference decoder.
    • These protections are worth keeping.
  • OutputParser sets schemas = {} in DSML mode, because DSML carries its own string-or-JSON flag. The scanner therefore cannot take the schema-driven string path that streams GLM strings, and a value can sit on its raw path until the terminator. A fix in DsmlRewriter alone may leave this second hold in place.
  • serve/server.py:
    • Service.run() passes stream_tools=True.
    • openai_chunks() turns tool_start / tool_args into deltas.
    • The OpenAI route flushes each chunk.
    • The heartbeat (yield "ping") comes only from the engine's no-token beat. While tokens flow into a held value, nothing is written. When a heartbeat is written, it is the SSE comment : keep-alive.

5. How the sibling projects handle it

Strata (Qwen) Xolotl (DeepSeek fork of Strata) Maya GLM Maya DS4
Long string arguments streamed (only array and object arguments are sent whole) stream_tools = False for DSML: the whole call arrives at the end streamed (normalized schema) held until the closing tag
Keep-alive while a value is held yes: KEEPALIVE_S = 10.0 in serve/server.py (0.2.1.x), "a held-back tool argument leaves the stream quiet: ping at least this often" no n/a no
Keep-alive format SSE comment : keep-alive - SSE comment SSE comment

Related Strata reports:

  • #1951: a keep-alive sent as an SSE comment does not reset the idle timer of clients that drop comments before counting activity. OpenCode was the example, with a 300 s chunkTimeout. The client aborts a healthy request and retries. PR #1953 proposed an empty chat.completion.chunk for /v1/chat/completions and event: ping for /v1/messages. It was closed without being merged. We have not checked whether pi-ai counts SSE comments; the timeout we saw is consistent with no data at all being written.
  • #1619: a request waiting for the single turn received no bytes, and clients with an idle timeout aborted it. Strata now sends a keep-alive every QUEUE_BEAT_S. Maya's server already beats while queued.
  • #3623 (open): the same family of problem in a GUI watchdog, which ended a turn while the engine was still reading a long prompt.

6. Possible fixes

A. Stream DSML string values (the real fix).

  • Carry DSML's string="true" flag through the rewrite into the scanner, or emit tool_args events directly from the DSML path. Then:
    1. send the opening quote when the value starts;
    2. send each piece as json.dumps(piece, ensure_ascii=False)[1:-1], with < → < as today (per-piece JSON escaping is safe, since an escape never spans two characters);
    3. send the closing quote at </|DSML| parameter>.
  • Hold back only a suffix that could still become the closing tag. feed() already has that "could still become a tag" check.
  • Keep the literal-tag rule. Do not escape twice between the two layers.
  • string="false" values (JSON: numbers, booleans, null, objects, arrays) can stay whole-value, as Strata does for arrays and objects. They are rarely long.

B. A keep-alive while a value is held (a safety net, independent of A).

  • Port Strata's KEEPALIVE_S. While tokens are being generated and the parser has returned no events for N seconds, yield a ping.
  • Write it as a real chunk (an empty-delta chat.completion.chunk; event: ping on /v1/messages), per Strata #1951, rather than an SSE comment.
  • This prevents the cancel but does not deliver content progressively, so it does not replace A's test.

7. Tests a fix should pass

  1. Delivery before the closing tag: a long DSML string produces argument data before its closing tag; a header event alone is not enough.
  2. Exact reconstruction: the concatenated deltas equal today's final arguments, with nothing missing, duplicated or quoted twice.
  3. Characters and delimiters: Portuguese and other Unicode, quotes, backslashes, newlines, JSON-looking text, and literal DSML/GLM tags inside the value, with piece boundaries inside tags and inside escape sequences.
  4. Types: string="true"/"false", strings that look like numbers or JSON, null, booleans, numbers, arrays and objects keep their meaning.
  5. Protocol: several parameters and calls, namespaces, tool-call ids, finish_reason, cancellation, answers without tools, and finish().
  6. No GLM regression: the normalized GLM string case still streams.
  7. Timing: a scripted engine and a streaming client with a short idle limit (a few seconds) keep receiving chunks while a long value is open. A final-JSON check alone misses this bug.
  8. Existing suites: test_ds41_conformance.py, test_tools.py and test_tool_images.py keep passing.

8. What we did and did not do

  • Done: offline reproduction on both revisions, and a source comparison. On the client, the idle limit was raised to 1,200,000 ms and the agent was told to write files in smaller pieces. These are workarounds; the long request was not re-run to confirm them.
  • Not done: no patch, no restart, no live SSE capture, and no comparison with Strata on the same workload.
  • Search: we found no existing Maya issue or PR about DSML tool-argument streaming or idle timeouts. That is a search result, not a guarantee.

We can test a branch on the machine above and report the same timings.

Originally created by @talisp on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/403 ## In short **The problem.** When DeepSeek writes a long string argument in a tool call, for example the content of a file for a `write` tool, Maya sends the call's name and its short arguments right away. The long value itself is **held until its closing tag**. While the model keeps generating, the client receives no data. A client with a stream-idle limit cancels a request that is working fine, then retries it. **What it cost us.** DeepSeek-V4.1-Flash wrote at ~16-18 tok/s on our card. DeepSeek Harness (pi-ai) gave up with `pi-ai stream idle timeout after 300000ms` after about 5,000 tokens of the file, and retried. One agent step made **1 attempt + 5 retries over ~31 minutes** and then failed. The prompt was reused from the cache each time, so the cost was the repeated generation, not prompt reading. **Where it comes from.** It is reproducible **offline, without a server or GPU**, with Maya's own parser: - **DeepSeek (DSML):** 0 argument events while the value is open. Everything arrives at the closing tag. - **GLM, with the tool schema normalized as the HTTP path does:** 20 argument events for the same 20 pieces. **GLM is not affected.** The gap is in the DSML path only. **How the sibling projects handle it.** - Strata's server already sends a keep-alive at least every 10 s when a held-back tool argument keeps the stream quiet (`KEEPALIVE_S`). - Strata #1951 found that a keep-alive written as an SSE comment does not reset some clients' idle timers. Those clients needed a real (empty) chunk. - Xolotl turns tool streaming off for DeepSeek entirely, so the whole call arrives at the end. - Maya's DeepSeek path has neither the incremental string path nor the held-value keep-alive. **The proposal, in short:** 1. Stream DSML `string="true"` values as they are generated, as the GLM path already does for string arguments. 2. As a quick, independent safety net, port Strata's held-value keep-alive, sent as an empty chunk rather than an SSE comment. We raised the client's idle limit to 20 minutes as a workaround, but this only hides the problem. The technical details follow, for whoever implements or reviews this. --- ## Technical notes ### 1. Versions and environment | Component | Value | |---|---| | Maya deployment | v1.1.21, `451f9cb6a21ea65673bdde2e57b4a670ae2b8859` | | Upstream main inspected | `25deec505b525212e05faa58697d9d2b7d17fdb3` | | `serve/frontend.py` | blob `85cb11fb2c6adcb8630aabe93c8aacb509bd3fec`, identical in the deployment and in that main | | Model / engine | `deepseek-v4.1-flash`, unsloth UD-Q8_K_XL, `maya-ds4`, 262,144 context | | Hardware | 1× NVIDIA L40S-48Q (vGPU, 48 GB), 32 vCPU, ~504 GB RAM, Linux | | Client | DeepSeek Harness 0.2.1-rc.2 (Windows), pi-ai provider over OpenAI Chat Completions, streaming, idle limit 300,000 ms | | Decode during the incident | ~16-18 tok/s | ### 2. The incident The agent was writing a source file with a tool named `write`; the file content was a string argument. The step began at 21:03:26 and failed at 21:34:15 local time, after 1 attempt + 5 retries. The server's monitor showed the following attempts: | Request start | Status | Prompt tokens | Reused | Output before stop | Decode | Duration | |---|---|---:|---:|---:|---:|---:| | 21:03:26 | Stopped | 100,038 | 99,905 | 4,978 | 16.3 tok/s | 307.2 s | | 21:08:33 | Stopped | 100,038 | 100,037 | 5,005 | 16.5 tok/s | 302.7 s | | 21:13:37 | Stopped | 100,038 | 100,037 | 5,059 | 16.5 tok/s | 307.7 s | | 21:18:47 | Stopped | 100,038 | 100,037 | 5,080 | 16.5 tok/s | 307.7 s | | 21:23:58 | Stopped | 100,038 | 100,037 | 5,002 | 16.4 tok/s | 305.2 s | - Each attempt stopped about 300 s in, which is exactly the client's idle limit. - The "output before stop" column is what was generated before the cancel, not the file's full size. - The engine log shows the same ~100K prompts, ~5K generations and ~300 s decodes. - No sub-agents were in that session, and this is not the slot problem of #375 / #394: the prompt was reused every time. - We did not capture the live SSE stream. The offline reproduction below shows the mechanism. ### 3. Offline reproduction (no server, model or GPU) Save as `repro_maya_tool_argument_streaming.py` and run it with the project's venv. It loads `serve/frontend.py` only. ```text python -B repro_maya_tool_argument_streaming.py --repo . python -B repro_maya_tool_argument_streaming.py --repo . --require-incremental # exit 1 while the bug is there ``` ```python """Offline parser reproduction. Loads frontend.py only; starts no server or GPU.""" from __future__ import annotations import argparse, importlib.util, json, sys from pathlib import Path OPENAI_TOOLS = [{"type": "function", "function": {"name": "write", "parameters": {"type": "object", "properties": {"path": {"type": "string"}, "content": {"type": "string"}}}}}] def run_case(frontend, label, dsml, tools): parser = frontend.OutputParser(thinking=False, tools=tools, stream_tools=True, dsml=dsml) pieces = ['linha ção "x" \\ {json} ' * 12 + "\n"] * 20 if dsml: tag = frontend.DSML prefix = (f'<{tag} calls>\n<{tag} invoke name="write">\n' f'<{tag} parameter name="path" string="true">a.txt</{tag} parameter>\n' f'<{tag} parameter name="content" string="true">') suffix = f'</{tag} parameter>\n</{tag} invoke>\n</{tag} calls>' else: prefix = ('<tool_call>write<arg_key>path</arg_key><arg_value>a.txt</arg_value>' '<arg_key>content</arg_key><arg_value>') suffix = '</arg_value></tool_call>' events = parser.feed(prefix) during = [] for piece in pieces: during.extend(parser.feed(piece)) events += during + parser.feed(suffix) + parser.finish() calls = [e.call for e in events if e.kind == "tool_call"] args = [e for e in during if e.kind == "tool_args" and e.text] # real argument data, not just an event return {"case": label, "input_chunks": len(pieces), "input_characters": sum(map(len, pieces)), "argument_events_before_closing": len(args), "argument_characters_before_closing": sum(len(e.text) for e in args), "final_content_matches": bool(calls) and calls[-1].arguments.get("content") == "".join(pieces)} def reproduce(frontend): # As the HTTP path does: OutputParser takes normalized tool dicts, not the API's {type, function} wrappers. _, normalized, _ = frontend.openai_to_messages({"messages": [{"role": "user", "content": "parser test"}], "tools": OPENAI_TOOLS}) return [run_case(frontend, "DSML / normalized string schema", True, normalized), run_case(frontend, "GLM / normalized string schema", False, normalized), run_case(frontend, "CONTROL: GLM / API wrappers passed directly", False, OPENAI_TOOLS), run_case(frontend, "CONTROL: GLM / no schema", False, None)] def load_frontend(repo): filename = Path(repo).resolve() / "serve" / "frontend.py" spec = importlib.util.spec_from_file_location("_maya_frontend_stream_repro", filename) module = importlib.util.module_from_spec(spec) sys.modules[spec.name] = module # needed by dataclasses with annotations spec.loader.exec_module(module) return module def main(): ap = argparse.ArgumentParser(description=__doc__) ap.add_argument("--repo", type=Path, default=Path(".")) ap.add_argument("--require-incremental", action="store_true") a = ap.parse_args() rows = reproduce(load_frontend(a.repo)) print(json.dumps(rows, ensure_ascii=True, indent=2)) if not all(r["final_content_matches"] for r in rows): return 2 if a.require_incremental and any(r["argument_events_before_closing"] == 0 for r in rows[:2]): return 1 return 0 if __name__ == "__main__": raise SystemExit(main()) ``` Results on v1.1.21 and on main `25deec5`, with 20 pieces totalling 5,540 characters: | Case | Argument events while the value is open | Final content matches | |---|---:|---| | **DSML, schema normalized by `openai_to_messages()`** | **0** | yes | | GLM, schema normalized by `openai_to_messages()` | 20 | yes | | Control: GLM, API wrappers passed straight to `OutputParser` | 0 | yes | | Control: GLM, no schema | 0 | yes | The two controls explain how a naive test can make GLM look affected. `OutputParser` expects the normalized `{name, parameters}` dicts that the HTTP path produces, not the public `{type, function}` wrappers. With the server's normalization, GLM streams its string arguments. ### 4. Where the value is held Links are pinned to `25deec5`. - [`DsmlRewriter._plain()`](https://github.com/mw00/project-maya/blob/25deec505b525212e05faa58697d9d2b7d17fdb3/serve/frontend.py#L693): while `in_param` is set, the text goes to `parameter_text` and the method returns `""`. - [`DsmlRewriter._tag()`](https://github.com/mw00/project-maya/blob/25deec505b525212e05faa58697d9d2b7d17fdb3/serve/frontend.py#L712) releases the value at `</|DSML| parameter>`. - For `string="true"`, it is `json.dumps(parameter_text)` with `<` replaced by `<`, so that literal legacy delimiters survive the rewrite to GLM's form. - Inside a parameter, other DSML tags are literal data, as in the reference decoder. - These protections are worth keeping. - [`OutputParser`](https://github.com/mw00/project-maya/blob/25deec505b525212e05faa58697d9d2b7d17fdb3/serve/frontend.py#L733) sets `schemas = {}` in DSML mode, because DSML carries its own string-or-JSON flag. The scanner therefore cannot take the schema-driven string path that streams GLM strings, and a value can sit on its `raw` path until the terminator. A fix in `DsmlRewriter` alone may leave this second hold in place. - `serve/server.py`: - [`Service.run()`](https://github.com/mw00/project-maya/blob/25deec505b525212e05faa58697d9d2b7d17fdb3/serve/server.py#L2227) passes `stream_tools=True`. - [`openai_chunks()`](https://github.com/mw00/project-maya/blob/25deec505b525212e05faa58697d9d2b7d17fdb3/serve/server.py#L2637) turns `tool_start` / `tool_args` into deltas. - The [OpenAI route](https://github.com/mw00/project-maya/blob/25deec505b525212e05faa58697d9d2b7d17fdb3/serve/server.py#L3597) flushes each chunk. - The heartbeat (`yield "ping"`) comes only from the engine's no-token beat. While tokens flow into a held value, nothing is written. When a heartbeat is written, it is the SSE comment `: keep-alive`. ### 5. How the sibling projects handle it | | Strata (Qwen) | Xolotl (DeepSeek fork of Strata) | Maya GLM | Maya DS4 | |---|---|---|---|---| | Long string arguments | streamed (only array and object arguments are sent whole) | `stream_tools = False` for DSML: the whole call arrives at the end | streamed (normalized schema) | **held until the closing tag** | | Keep-alive while a value is held | yes: `KEEPALIVE_S = 10.0` in `serve/server.py` (0.2.1.x), "a held-back tool argument leaves the stream quiet: ping at least this often" | no | n/a | no | | Keep-alive format | SSE comment `: keep-alive` | - | SSE comment | SSE comment | Related Strata reports: - **#1951:** a keep-alive sent as an SSE comment does not reset the idle timer of clients that drop comments before counting activity. OpenCode was the example, with a 300 s `chunkTimeout`. The client aborts a healthy request and retries. PR #1953 proposed an empty `chat.completion.chunk` for `/v1/chat/completions` and `event: ping` for `/v1/messages`. It was closed without being merged. We have not checked whether pi-ai counts SSE comments; the timeout we saw is consistent with no data at all being written. - **#1619:** a request waiting for the single turn received no bytes, and clients with an idle timeout aborted it. Strata now sends a keep-alive every `QUEUE_BEAT_S`. Maya's server already beats while queued. - **#3623 (open):** the same family of problem in a GUI watchdog, which ended a turn while the engine was still reading a long prompt. ### 6. Possible fixes **A. Stream DSML string values (the real fix).** - Carry DSML's `string="true"` flag through the rewrite into the scanner, or emit `tool_args` events directly from the DSML path. Then: 1. send the opening quote when the value starts; 2. send each piece as `json.dumps(piece, ensure_ascii=False)[1:-1]`, with `<` → `<` as today (per-piece JSON escaping is safe, since an escape never spans two characters); 3. send the closing quote at `</|DSML| parameter>`. - Hold back only a suffix that could still become the closing tag. `feed()` already has that "could still become a tag" check. - Keep the literal-tag rule. Do not escape twice between the two layers. - `string="false"` values (JSON: numbers, booleans, null, objects, arrays) can stay whole-value, as Strata does for arrays and objects. They are rarely long. **B. A keep-alive while a value is held (a safety net, independent of A).** - Port Strata's `KEEPALIVE_S`. While tokens are being generated and the parser has returned no events for N seconds, yield a ping. - Write it as a real chunk (an empty-delta `chat.completion.chunk`; `event: ping` on `/v1/messages`), per Strata #1951, rather than an SSE comment. - This prevents the cancel but does not deliver content progressively, so it does not replace A's test. ### 7. Tests a fix should pass 1. **Delivery before the closing tag:** a long DSML string produces argument data before its closing tag; a header event alone is not enough. 2. **Exact reconstruction:** the concatenated deltas equal today's final arguments, with nothing missing, duplicated or quoted twice. 3. **Characters and delimiters:** Portuguese and other Unicode, quotes, backslashes, newlines, JSON-looking text, and literal DSML/GLM tags inside the value, with piece boundaries inside tags and inside escape sequences. 4. **Types:** `string="true"/"false"`, strings that look like numbers or JSON, null, booleans, numbers, arrays and objects keep their meaning. 5. **Protocol:** several parameters and calls, namespaces, tool-call ids, `finish_reason`, cancellation, answers without tools, and `finish()`. 6. **No GLM regression:** the normalized GLM string case still streams. 7. **Timing:** a scripted engine and a streaming client with a short idle limit (a few seconds) keep receiving chunks while a long value is open. A final-JSON check alone misses this bug. 8. **Existing suites:** `test_ds41_conformance.py`, `test_tools.py` and `test_tool_images.py` keep passing. ### 8. What we did and did not do - **Done:** offline reproduction on both revisions, and a source comparison. On the client, the idle limit was raised to 1,200,000 ms and the agent was told to write files in smaller pieces. These are workarounds; the long request was not re-run to confirm them. - **Not done:** no patch, no restart, no live SSE capture, and no comparison with Strata on the same workload. - **Search:** we found no existing Maya issue or PR about DSML tool-argument streaming or idle timeouts. That is a search result, not a guarantee. We can test a branch on the machine above and report the same timings.
Author
Owner

@mw00 commented on GitHub (Oct 23, 2026):

Thanks for the clear write-up. Fixed in v1.1.26: a DeepSeek tool call's string arguments (string="true", e.g. a file's content) now stream to the client as they are written instead of arriving at the closing tag, so clients with a stream-idle timeout keep receiving data. The streamed pieces join to exactly the same arguments as the final call (new test in serve/test_ds41_conformance.py).

<!-- gh-comment-id:6373122066 --> @mw00 commented on GitHub (Oct 23, 2026): Thanks for the clear write-up. Fixed in v1.1.26: a DeepSeek tool call's string arguments (`string="true"`, e.g. a file's content) now stream to the client as they are written instead of arriving at the closing tag, so clients with a stream-idle timeout keep receiving data. The streamed pieces join to exactly the same arguments as the final call (new test in serve/test_ds41_conformance.py).
Sign in to join this conversation.
No labels
pull-request
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
mw00/project-maya#156
No description provided.