mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
fix(hunter): bound every tool result; show the provider's reason for an HTTP error
FUXA failed every hunt with HTTP 400, and neither run could say why. The client discarded the response body. With the body shown, the reason was "This model's maximum context length...": FUXA ships minified bundles whose single lines run to megabytes, and grep_repo returned a matched line whole. - grep_repo and find_refs quote a matched line (240 characters), never the whole line. - Every tool result is capped at 16 x max_chars, with a truncation marker. - OpenRouterChatClient errors carry the provider's response body (first 500 characters). That would also have exposed the rejected model id in one call instead of eighteen days. After the fix, FUXA candidates verify normally at $0.004-0.013 each. A test covers the megabyte-line case. verify_sinks.py: skip futures cancelled at the spend ceiling instead of reading them (the run crashed with CancelledError). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3ffb8b4c54
commit
8794884a64
@@ -143,3 +143,14 @@ def test_grep_reads_the_tree_once_and_sees_an_edit(tmp_path, monkeypatch) -> Non
|
||||
stamp = source.stat().st_mtime_ns + 10_000_000
|
||||
os.utime(source, ns=(stamp, stamp))
|
||||
assert [m["line"] for m in hunter_tools.grep_repo(tmp_path, r"query\(", max_matches=5)] == [3], "a stale read survived an edit"
|
||||
|
||||
|
||||
def test_a_match_in_a_minified_line_is_quoted_not_returned_whole(tmp_path) -> None:
|
||||
"""FUXA's minified bundles have megabyte lines; one match overflowed the model's context for the whole hunt."""
|
||||
from openultrasast import hunter_tools, tool_hunter
|
||||
|
||||
(tmp_path / "bundle.js").write_text("var a=1;" + "x" * 500_000 + ";eval(q);\n")
|
||||
[match] = hunter_tools.grep_repo(tmp_path, r"var a", max_matches=5)
|
||||
assert len(match["text"]) <= 240
|
||||
call = tool_hunter.ToolCall(id="c", name="grep_repo", arguments={"pattern": "x+", "max_matches": 50})
|
||||
assert len(tool_hunter._run_tool(tmp_path, call, 4000)) <= 16 * 4000 + 64
|
||||
|
||||
Reference in New Issue
Block a user