[PR #1678] [CLOSED] serve: keep-alive while a tool call's held-back argument is generated (#1666) #3604

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1678
Author: @nekomario28
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: fix-1666-arg-keepalive


📝 Commits (1)

  • 30d2bf5 serve: keep-alive while a tool call's held-back argument is generated (#1666)

📊 Changes

2 files changed (+48 additions, -0 deletions)

View changed files

📝 serve/server.py (+12 -0)
📝 serve/test_server.py (+36 -0)

📄 Description

Fixes #1666. (The patch is the reporter's, applied to main; this adds the ping-cadence unit test the issue offered.)

With stream_tools, OutputParser holds an array/object argument until </parameter> — a large one (a measured 66 KB edit_file call) left the stream silent for minutes while tokens were generated, so a client's idle timeout ended a healthy request. Forge's is 120 s; the reporter hit it on a real agent turn.

Change

Service.run's token loop now tracks last_out (set on the heartbeat ping and whenever the parser emits events). When a token produces no event and nothing has gone out for KEEPALIVE_S (10 s), it yields the same "ping" the engine-quiet heartbeat sends — no new event type; clients already ignore SSE comments. Ordinary answers are untouched: a token that streams content keeps resetting last_out.

Test plan

  • New HeldBackArgKeepalive in serve/test_server.py: a fake engine whose generated <tool_call> is held whole by the frontend (the same silence a long array argument makes), over a patched clock — asserts a ping still goes out and the request reaches done; and a control that an ordinary answer emits no ping.
  • Full serve.test_server: 273 tests, 3 errors all ModuleNotFoundError: regex — the missing optional dep in this environment, identical on a clean checkout; unrelated.
  • Reporter's live reproduction: longest gap between SSE events 27.8 s → 10.0 s, the 7.6 KB array arriving intact; an 880 s Forge agent turn with a 66 KB argument kept alive.

Not tested here: a real 120 s idle-timeout client (the reporter measured that end); the keep-alive itself is covered above.


🔄 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/1678 **Author:** [@nekomario28](https://github.com/nekomario28) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-1666-arg-keepalive` --- ### 📝 Commits (1) - [`30d2bf5`](https://github.com/Niko1221/Strata/commit/30d2bf540118cdc0a521e3ef7e4bbc8ae6f0ceb2) serve: keep-alive while a tool call's held-back argument is generated (#1666) ### 📊 Changes **2 files changed** (+48 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+12 -0) 📝 `serve/test_server.py` (+36 -0) </details> ### 📄 Description Fixes #1666. (The patch is the reporter's, applied to main; this adds the ping-cadence unit test the issue offered.) With `stream_tools`, `OutputParser` holds an array/object argument until `</parameter>` — a large one (a measured 66 KB `edit_file` call) left the stream silent for minutes while tokens were generated, so a client's idle timeout ended a healthy request. Forge's is 120 s; the reporter hit it on a real agent turn. ## Change `Service.run`'s token loop now tracks `last_out` (set on the heartbeat ping and whenever the parser emits events). When a token produces no event and nothing has gone out for `KEEPALIVE_S` (10 s), it yields the same `"ping"` the engine-quiet heartbeat sends — no new event type; clients already ignore SSE comments. Ordinary answers are untouched: a token that streams content keeps resetting `last_out`. ## Test plan - New `HeldBackArgKeepalive` in `serve/test_server.py`: a fake engine whose generated `<tool_call>` is held whole by the frontend (the same silence a long array argument makes), over a patched clock — asserts a `ping` still goes out and the request reaches `done`; and a control that an ordinary answer emits no ping. - Full `serve.test_server`: 273 tests, 3 errors all `ModuleNotFoundError: regex` — the missing optional dep in this environment, identical on a clean checkout; unrelated. - Reporter's live reproduction: longest gap between SSE events 27.8 s → 10.0 s, the 7.6 KB array arriving intact; an 880 s Forge agent turn with a 66 KB argument kept alive. Not tested here: a real 120 s idle-timeout client (the reporter measured that end); the keep-alive itself is covered above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29:29 +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#3604
No description provided.