fix: accept empty string result in attempt_completion tool#11635
fix: accept empty string result in attempt_completion tool#11635ritwikj2 wants to merge 1 commit intoRooCodeInc:mainfrom
Conversation
Fixes RooCodeInc#11404 (partial) The attempt_completion tool's nativeArgs parsing used a truthy check (if (args.result)) which rejected empty strings as invalid. Changed to an existence check (!== undefined) in both streaming and finalize parse paths. Added regression tests for: - Empty string result in parseToolCall - Non-empty result in parseToolCall - Empty string result in streaming path
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b3e7ba70a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Reviewed the changes and verified locally. The fix is correct and well-tested.
Summary of review:
- The root cause is accurately identified:
if (partialArgs.result)/if (args.result)treats empty string""as falsy, causing valid empty-string completions to produce missingnativeArgs. - The fix to
!== undefinedin both the streaming path (line 452) and the finalize path (line 781) is minimal and targeted. - The three regression tests cover the key scenarios: empty string via
parseToolCall, non-empty string viaparseToolCall, and empty string via the streaming path (startStreamingToolCall+processStreamingChunk). - All existing tests continue to pass alongside the new ones (15/15).
- Lint, prettier, and type checks all clean.
One small note: null values would also pass the !== undefined check (unlike the original truthy check which rejected both). This is fine in practice since result comes from JSON-parsed tool call arguments where null would be an unusual edge case, and the downstream handling of attempt_completion will still treat it appropriately. If extra defensiveness is desired, result != null (loose equality covering both null and undefined) could be used instead, but that is not a blocker.
LGTM.
Code Review SummaryThe parser fix correctly allows empty strings through, but the downstream consumer still rejects them.
|
Summary
Fixes #11404 — The
attempt_completiontool was incorrectly rejecting empty string results.Problem
The existing code used a truthy check (
if (!result)) which treated empty strings ('') as falsy, causing valid empty-string completions to be rejected with an error.Solution
Changed the truthy check to an explicit existence check (
if (result === undefined || result === null)) inNativeToolCallParser.ts, allowing empty strings to pass through as valid results.Testing
Added 3 regression tests to verify:
Checklist
Start a new Roo Code Cloud session on this branch