Skip to content

Commit 07f7cb0

Browse files
refactor(jsonl-parser): replace _parse_tool_result if/elif with dispa… (#31)
* refactor(jsonl-parser): replace _parse_tool_result if/elif with dispatch table Implement _TOOL_RESULT_DISPATCH as an ordered sequence of (predicate, builder) pairs with explicit _tool_result_pred_* / _tool_result_build_* helpers so new tool-result shapes register in one place. Preserve legacy branch order and unknown fallback; no intentional behavior change. * fix(jsonl-parser): safe web_search result_count + slug Optional typing (#29) * docs: align Issue 29 guide with PR framing for #29
1 parent e0e0a76 commit 07f7cb0

2 files changed

Lines changed: 254 additions & 126 deletions

File tree

tests/test_jsonl_parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ def test_web_search_result(self):
171171
assert r["query"] == "q"
172172
assert r["result_count"] == 1
173173

174+
def test_web_search_results_none_or_non_sized_yields_zero_count(self):
175+
r = _parse_tool_result({"query": "q", "results": None})
176+
assert r["result_type"] == "web_search"
177+
assert r["result_count"] == 0
178+
r2 = _parse_tool_result({"query": "q", "results": "not-a-list"})
179+
assert r2["result_count"] == 0
180+
174181
def test_web_fetch_result(self):
175182
r = _parse_tool_result({"url": "https://x", "code": 200, "durationMs": 40})
176183
assert r["result_type"] == "web_fetch"

0 commit comments

Comments
 (0)