GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing github.com — fix(templates): read long stream-json lines and bound Claude Code shutdown by michaelxu2288 · Pull Request #542 · scaleapi/scale-agentex-python Conversation
|
| case | main |
this branch |
|---|---|---|
| 100,000-character stream-json line | ValueError: Separator is found, but chunk is longer than limit |
line read whole |
CLI ignores SIGTERM, consumer calls aclose() |
still hanging after 20 s | returns after 5.0 s |
tests/lib/cli/test_init_templates.py: 26 passed.tests/test_agent_offline.py: 7, 5 and 5 passed.ruff check is clean on the tutorial files, and all three compile.The PR appears safe to merge; the earlier missing-test concern is addressed.
What we checked:
Claude Code scaffolds now read stream-JSON lines up to 8 MiB and stop lingering CLI processes after a five-second grace period. The updates cover the generated templates and tutorial copies, with an offline subprocess test for both paths.
tool_result lines can reach the turn without hitting asyncio’s default line limit.Reviews (2) · Last reviewed commit: "test(templates): run the Claude Code sca..."
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…tdown The Claude Code scaffolds (sync, async and Temporal) and their tutorial copies read `claude -p --output-format stream-json` stdout through asyncio's StreamReader with the default 64 KiB line limit. Claude Code writes one JSON line per event, so a tool_result that echoes a large file read is a single line well past 64 KiB; readline() then raises "Separator is found, but chunk is longer than limit" and the turn aborts. Read with an 8 MiB limit, the same value `agentex agents run` uses for its child processes. Their cleanup also sent SIGTERM and then awaited proc.wait() with no bound, so a CLI that ignores or delays SIGTERM hangs request or activity cancellation. Wait at most 5 s, then SIGKILL. Verified with a fake `claude` on PATH, against the rendered sync and Temporal templates: - a 100,000-character line: main raises the ValueError, this branch reads it whole; - a CLI that ignores SIGTERM: main's aclose() is still hanging after 20 s, this branch returns after 5 s. tests/lib/cli/test_init_templates.py passes, and the three tutorials' test_agent_offline.py suites pass (7, 5 and 5 tests).
There was an error while loading. Please reload this page.
…ocess Render the sync Claude Code template, put a fake `claude` on PATH that prints a 100,000-character stream-json line and ignores SIGTERM, and drive _spawn_claude(): the long line must arrive whole and aclose() must return once the (shortened) grace period ends. Against main's template the test fails with "Separator is found, but chunk is longer than limit" after the unbounded wait sits out the child's 60 s sleep; here it passes in under 4 s.
|
@danielmillerp since you were just in the tutorials: this fixes the Claude Code templates and their three tutorial copies crashing on any stream-json line over 64 KiB (a large file read does it), plus an unbounded wait on cancel. Would you mind taking a look? CI needs a maintainer to approve the run since this is from a fork. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.