Repository navigation
perf(tier3): index Claude tool results by call ID #733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisknvidia
merged 4 commits into
NVIDIA:main
from
Afloat16:perf/index-claude-tool-results
Nov 19, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
afc218a
perf: index Claude tool results by call ID
Afloat16 03ac3b0
docs: move pending change notes into Unreleased
Afloat16 b7ab92f
Merge branch 'main' into perf/index-claude-tool-results
rng1995 dc5f8e8
Merge branch 'main' into perf/index-claude-tool-results
rng1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Claude result lookup must preserve chronological pairing and evidence ordering.""" | ||
|
|
||
| import json | ||
|
|
||
| import pytest | ||
|
|
||
| from skillevaluator.tier3.eval_core.log_converters import synthetic_trajectory_from_claude_stream_jsonl | ||
|
|
||
|
|
||
| def _message(role, content): | ||
| return {"type": role, "message": {"content": content}} | ||
|
|
||
|
|
||
| def _call(call_id, path="file.md"): | ||
| return {"type": "tool_use", "id": call_id, "name": "Read", "input": {"file_path": path}} | ||
|
|
||
|
|
||
| def _result(call_id, content, **extra): | ||
| return {"type": "tool_result", "tool_use_id": call_id, "content": content, **extra} | ||
|
|
||
|
|
||
| def _trajectory(*events): | ||
| return synthetic_trajectory_from_claude_stream_jsonl("\n".join(json.dumps(event) for event in events)) | ||
|
|
||
|
|
||
| def test_delayed_out_of_order_and_repeated_results_keep_their_steps(): | ||
| trajectory = _trajectory( | ||
| _message("assistant", [_call("a"), _call("b")]), | ||
| _message("assistant", "progress update"), | ||
| _message("assistant", [_call("c")]), | ||
| _message( | ||
| "user", | ||
| [ | ||
| _result("b", "failed", is_error=True), | ||
| _result("c", [{"type": "text", "text": "third"}]), | ||
| _result("a", "first"), | ||
| _result("b", "retry result"), | ||
| ], | ||
| ), | ||
| {"type": "result", "result": "finished"}, | ||
| ) | ||
|
|
||
| steps = trajectory["steps"] | ||
| assert len(steps) == 4 | ||
| assert steps[0]["observation"]["results"] == [ | ||
| {"source_call_id": "b", "content": "failed", "extra": {"tool_result_is_error": True}}, | ||
| {"source_call_id": "a", "content": "first"}, | ||
| {"source_call_id": "b", "content": "retry result"}, | ||
| ] | ||
| assert steps[1]["message"] == "progress update" | ||
| assert steps[1]["observation"]["results"] == [] | ||
| assert steps[2]["observation"]["results"] == [{"source_call_id": "c", "content": "third"}] | ||
| assert steps[3]["message"] == "finished" | ||
| assert steps[3]["observation"]["results"] == [] | ||
|
|
||
|
|
||
| def test_reused_ids_attach_once_to_the_latest_preceding_step(): | ||
| trajectory = _trajectory( | ||
| _message("user", [_result("same", "too early")]), | ||
| _message("assistant", [_call("same", "old.md"), _call("same", "duplicate.md")]), | ||
| _message("user", [_result("same", "old result")]), | ||
| _message("assistant", [_call("same", "new.md"), _call("")]), | ||
| _message("user", [_result("same", "new result"), _result("unknown", "orphan"), _result("", "empty")]), | ||
| ) | ||
|
|
||
| first, second = trajectory["steps"] | ||
| assert len(first["tool_calls"]) == 2 | ||
| assert first["observation"]["results"] == [{"source_call_id": "same", "content": "old result"}] | ||
| assert second["tool_calls"][0]["arguments"]["path"] == "new.md" | ||
| assert second["observation"]["results"] == [{"source_call_id": "same", "content": "new result"}] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("reverse", [False, True]) | ||
| def test_batched_calls_keep_result_order(reverse): | ||
| ids = [f"call-{index}" for index in range(256)] | ||
| result_ids = list(reversed(ids)) if reverse else ids | ||
| trajectory = _trajectory( | ||
| _message("assistant", [_call(call_id) for call_id in ids]), | ||
| _message("user", [_result(call_id, f"result {call_id}") for call_id in result_ids]), | ||
| ) | ||
|
|
||
| assert trajectory["steps"][0]["observation"]["results"] == [ | ||
| {"source_call_id": call_id, "content": f"result {call_id}"} for call_id in result_ids | ||
| ] |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.