Skip to content

Comments

fix: accept empty string result in attempt_completion tool#11635

Open
ritwikj2 wants to merge 1 commit intoRooCodeInc:mainfrom
ritwikj2:fix/attempt-completion-empty-string
Open

fix: accept empty string result in attempt_completion tool#11635
ritwikj2 wants to merge 1 commit intoRooCodeInc:mainfrom
ritwikj2:fix/attempt-completion-empty-string

Conversation

@ritwikj2
Copy link

@ritwikj2 ritwikj2 commented Feb 20, 2026

Summary

Fixes #11404 — The attempt_completion tool 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)) in NativeToolCallParser.ts, allowing empty strings to pass through as valid results.

Testing

Added 3 regression tests to verify:

  • Empty string results are accepted
  • Whitespace-only results are accepted
  • Undefined/null results are still rejected

Checklist

  • Code changes
  • Tests added
  • Type checks pass

Start a new Roo Code Cloud session on this branch

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
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Feb 20, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 missing nativeArgs.
  • The fix to !== undefined in 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 via parseToolCall, 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.

@roomote
Copy link
Contributor

roomote bot commented Feb 20, 2026

Code Review Summary

The parser fix correctly allows empty strings through, but the downstream consumer still rejects them.


View task on Roo Code Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool execution fails: attempt_completion missing nativeArgs for Z-AI and Ollama after provider migrations

1 participant