Repository navigation
perf(tier3): index Claude tool results by call ID - #733
Conversation
Signed-off-by: Afloat <ShuffleMonkey@163.com>
chrisknvidia
left a comment
There was a problem hiding this comment.
Thanks. I checked this two ways. First, equivalence: I ran the old and new Claude parser over 3000 randomly generated streams (mixed call/result order, repeated and reused IDs, empty and unknown IDs, string vs list results, error flags, string-only assistant messages, garbage lines) and the output dictionaries were identical every time. Second, timing: 5000 batched calls went from about 0.39 s to 0.016 s here, reversed order the same, and the interleaved case stayed flat, matching your table.
The new tests pass on main as well, which is what you want for a refactor like this; they pin the pairing rules rather than catch a bug, and that is fine. Two notes, neither blocking: this adds a line directly above the loop that #729 changes, so whichever lands second needs a small rebase; and a non-object JSON line still raises in both the old and new code, which #728 handles separately.
rng1995
left a comment
There was a problem hiding this comment.
Thanks for your contribution, @Afloat16. Reviewed afc218af51a0; no new actionable defects found. The call-ID index preserves chronological pairing, delayed/batched result order, reused IDs, unknown/empty IDs, and error metadata. Tool results still attach to the latest preceding matching step.
Validation: All 4 new pairing tests and 28 existing converter tests passed; 3,000 seeded random streams produced trajectories identical to the base parser.
The prior notes about adjacent parser work describe separate changes or pre-existing behavior; I found no regression introduced by this index.
rng1995
left a comment
There was a problem hiding this comment.
Thanks @Afloat16 for this contribution! I reviewed afc218af51. I reproduced the problem on main, confirmed this change fixes it, and ran the new and related tests on this head (all pass). I left 1 inline comment (1 P3); please take a look.
Merge current main while retaining this change and the published release notes. Signed-off-by: Afloat <ShuffleMonkey@163.com>
|
Addressed in 03ac3b0: the tool-result indexing note is now in a new |
Summary
Claude Code log recovery currently searches every preceding step and its tool calls for each tool result. A large batch of calls makes that repeated search quadratic.
Index the latest preceding assistant step by normalized call ID and attach results directly. Preserve delayed/out-of-order results, repeated results, reused IDs, orphan handling and observation order. The index holds references to existing steps and uses O(unique call IDs) additional entries.
Verification
python -m pytest tests/tier3/test_claude_tool_result_pairing.py tests/tier3/test_log_converters.py tests/test_harbor_collector_runtime_failures.py -q— 217 passed.The interleaved call/result control has small index overhead: 5,000 calls measured 0.030563 s before and 0.033816 s after. The gain is for batched/delayed results that previously required repeated long searches; these fixtures do not measure live model execution.
make lintequivalent:python -m ruff check src testsmake testdid not complete successfully in this environment (see below)make buildequivalent:python -m build(wheel and sdist)The unchanged base
8fe9723, tested withpython -m pytest -x -q, stops after 456 passed and 19 deselected attests/ci/test_gateway_benchmark_workflows.py::test_gitlab_enriched_tier1_applies_the_keyless_job_baselines[extra0-expected0]. The sandbox has no/tmp, while that workflow fixture explicitly invokesmktemp -d /tmp/skillevaluator-enriched-tier1.XXXXXX. The same test fails for the same reason on the retry branch. No full-suite pass is claimed.Release Impact
CHANGELOG.md