Repository navigation
fix(agents): handle truncated tool calls and reject empty findings (#21) - #33
Mahajan-Sachin wants to merge 2 commits into
Conversation
[Medium impact] The PR appears safe to merge; the remaining verifier test gap is non-blocking.
|
| @pytest.mark.asyncio | ||
| async def test_base_agent_handles_truncated_tool_call(session, tools): |
There was a problem hiding this comment.
The new tests cover HunterAgent, ValidatorAgent, and BaseAgent, but neither changed verifier loop is exercised. Each verifier has its own completion path, so the base-agent test cannot catch a regression that executes a truncated call or ends verification early.
Add tests for BrowserVerifierAgent and SandboxVerifierAgent with truncated action and completion calls. Assert that no handler runs, the error reaches the model, and a corrected retry succeeds.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/test_tool_call_truncation.py
Line: 177-178
Comment:
**Verifier fixes lack tests**
The new tests cover `HunterAgent`, `ValidatorAgent`, and `BaseAgent`, but neither changed verifier loop is exercised. Each verifier has its own completion path, so the base-agent test cannot catch a regression that executes a truncated call or ends verification early.
Add tests for `BrowserVerifierAgent` and `SandboxVerifierAgent` with truncated action and completion calls. Assert that no handler runs, the error reaches the model, and a corrected retry succeeds.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
@greptile-apps Addressed both findings:
All 10/10 regression tests in |
|
@greptile-apps is everything all right now? |
|
Yes — the follow-up changes address the remaining concerns. The handlers now validate types before calling The Tip: You can customize Greptile's behavior for this repo with |
|
Hi @ananay, This is ready for review and merge. It resolves #21 across the entire agent pipeline:
Whenever you have a moment, please take a look! |
Summary
Closes #21.
When a reasoning model emits a long tool call (such as
report_findingwith an exploit script or detailed context) and hitsmax_tokens(finish_reason: "length"), JSON decoding fails andtool_call.argumentsdefaults to{}withtool_call.parse_errorset. Previously, agent loops did not checkparse_error, causing:hunter.pyto record an empty "ghost" finding with missing file/category/description.validator.pyto classify truncated validation verdicts as false positives.Changes
parse_error: Before executing tool calls acrosshunter,validator,base,sandbox_verifier, andbrowser_verifier, checktool_call.parse_error. If set, return a structuredtool_call_truncatederror instructing the model to resend with concise arguments._handle_report_finding: Ensurefile_pathanddescriptionare non-empty before recording intoself.findings._handle_validate_finding: Require a non-emptystatusbefore recording validation results.tests/test_tool_call_truncation.pywith 7 unit tests verifying truncation handling and finding rejection across all agent scenarios.Testing
Ran
uv run pytest tests/test_tool_call_truncation.py: