← Back to PRs

#15509: fix(session): drop tool_use blocks with empty or missing name

by aldoeliacim open 2026-02-13 15:02 View on GitHub →
stale
## Summary `repairToolCallInputs()` already drops tool calls without `input`/`arguments`, but passes through blocks with an empty `name` field. The Anthropic API rejects these with: ``` tool_use.name: String should have at least 1 character ``` This corrupts the session permanently — every subsequent message fails until `/new`. ## Changes - Add `hasToolCallName()` guard in `session-transcript-repair.ts` - Drop tool call blocks where `name` is empty string or missing - Add 2 test cases covering empty and missing name scenarios ## Testing All 12 tests pass in `session-transcript-repair.e2e.test.ts`. Closes #15485 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR tightens transcript sanitization in `src/agents/session-transcript-repair.ts` by additionally dropping assistant tool-call blocks whose `name` is empty or missing, preventing provider-side 400s (`tool_use.name` must be non-empty) that can permanently break a session. It adds two E2E tests in `src/agents/session-transcript-repair.e2e.test.ts` to cover empty-name and missing-name tool blocks and asserts the sanitizer removes those blocks (and drops the now-empty assistant message when applicable). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Change is narrow and defensive (dropping invalid tool-call blocks already known to be rejected by providers) and is covered by new test cases; no behavioral changes outside transcript repair/sanitization logic were observed in the diff. - No files require special attention <sub>Last reviewed commit: 3296ced</sub> <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs