fix(runtime): stop counting insignificant tool-argument whitespace as stream activity - #4888
Draft
jsiu93 wants to merge 1 commit into
Draft
fix(runtime): stop counting insignificant tool-argument whitespace as stream activity#4888jsiu93 wants to merge 1 commit into
jsiu93 wants to merge 1 commit into
Conversation
… stream activity Track JSON string and escape state independently for each streaming tool call. Keep whitespace inside string literals active across split and escaped deltas. Let the existing idle watchdog cancel whitespace stalls and apply its recovery. Cover interleaved calls and preserve text and reasoning stream behavior. Refs apache#4861 Generated-by: pi (gpt-6-astra)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Insignificant JSON whitespace in tool-argument deltas no longer counts as stream activity; the existing idle watchdog and its recovery handle the stall.
Track string and escape state independently for each tool-call ID. Spaces, tabs, carriage returns, and line feeds outside JSON strings leave the activity clock unchanged. Whitespace inside strings remains activity, including across escaped quotes and split deltas. Other stream parts retain their existing behavior.
The criterion follows JSON syntax. The existing 120-second idle timeout, recovery policy, strict settings, and tool schemas remain unchanged. This patch adds no threshold or content heuristic.
Refs #4861
Verification
@maka/runtimetest:dist: 3,268 tests, 3,255 passed, 13 skipped, 0 failed.gpt-6-astra, captured relay traffic: a Bash argument loop emitted 4,129 argument bytes. Its last meaningful delta arrived at 5.015 seconds; Maka closed the HTTP stream at 125.025 seconds, 120.010 seconds later. On unpatched main a comparable loop lasted about 902 seconds.Retrying in 2s (2/2), thenRetrying (2/2). The retry completedpwd. Canonical accounting records attempt 0 asabortedwith missing usage and attempt 1 ascompletedwith reported usage under the same logical call ID. Provider code and retryable fields remain absent on the aborted attempt, following the existing watchdog accounting path.Security
The change lets the existing watchdog cancel a provider stream that only appends insignificant JSON whitespace. Permission checks, sandbox boundaries, and execution authority remain unchanged. The existing single idle-recovery allowance and observable-output safety gates still govern replay.
AI use
Tool(s) and scope: OpenAI Codex-family model via pi implemented the patch, tests, and this description; human-reviewed.
Checklist
Does this PR entail a change in behavior?
Open questions for maintainers
Should whitespace-only text or reasoning deltas eventually share this activity definition? This draft preserves their current behavior because whitespace in those streams can carry presentation meaning; tool-argument JSON supplies an explicit syntax-level distinction.