Minify parallel tool results
Serialize parallel job results and started-job handles as compact JSON. Cover compact parallel result output.
linkliti committed
Aug 24, 2026 at 20:49 UTC
1615258ef6a67c5e6145791baa148c11267bc0b9
2 files changed
+10
-2
helpers/parallel_tools.py
+2
-2
@@ -364,7 +364,7 @@ def format_started_jobs(jobs: list[ParallelJob]) -> str:
364
"jobs": [_job_snapshot(job, include_result=False) for job in jobs],
365
"instruction": "Use the parallel tool with job_ids to await or cancel these background jobs.",
366
}
367
- return json.dumps(payload, indent=2, ensure_ascii=False)
367
+ return json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
368
369
370
def format_parallel_results(results: list[dict[str, Any]]) -> str:
@@ -393,7 +393,7 @@ def format_parallel_results(results: list[dict[str, Any]]) -> str:
393
"Some jobs are still running. Call `parallel` with `action: \"await\"` "
394
"and the listed `job_ids` to wait again, or `action: \"cancel\"` to stop them."
395
)
396
- return json.dumps(payload, indent=2, ensure_ascii=False)
396
+ return json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
397
398
399
async def _run_parallel_job(parent_context_id: str, job_id: str) -> None:
tests/test_parallel_tool.py
+8
@@ -1071,3 +1071,11 @@ def test_chats_sidebar_projects_parallel_children_as_indented_accordion() -> Non
1071
assert "left: 2px" in html
1072
assert "padding-left: 24px" in html
1073
assert "color: var(--color-text-muted)" in html
1074
+
1075
+
1076
+def test_parallel_result_json_is_compact() -> None:
1077
+ result = parallel_tools.format_parallel_results(
1078
+ [{"job_id": "wait-1", "tool_name": "wait", "state": "success"}]
1079
+ )
1080
+
1081
+ assert result == '{"status":"success","jobs":[{"job_id":"wait-1","tool_name":"wait","state":"success"}]}'