Skip to content

Polish hasSuccessfulToolCall: tests, docs, and impl symmetry#263

Open
sethconvex wants to merge 1 commit into
mainfrom
polish-has-successful-tool-call
Open

Polish hasSuccessfulToolCall: tests, docs, and impl symmetry#263
sethconvex wants to merge 1 commit into
mainfrom
polish-has-successful-tool-call

Conversation

@sethconvex
Copy link
Copy Markdown
Contributor

Summary

Follow-ups to #241 (hasSuccessfulToolCall / willContinue fix) from the post-merge review.

Implementation

  • hasSuccessfulToolCall reads from step.content (matching tool-result parts by toolName) instead of step.toolResults. AI SDK's TypedToolResult already excludes error variants by type, so the prior implementation was correct in practice — but reading from the same source as willContinue removes the asymmetry flagged in review and is more obviously correct on inspection.
  • Expanded JSDoc: explicitly notes that tool-error parts do not match, and that the helper only inspects the last step (consistent with how stopWhen is applied per-step).
  • Clarifying comment on willContinue fallback: the step.content?.filter(...).length ?? step.toolResults.length pattern is defensive — under AI SDK v6 step.content is always defined (Array<ContentPart<TOOLS>>, non-optional), so the fallback is for non-v6 / mock callers, not load-bearing for the v6 bug fix.

Tests (src/client/utils.test.ts, new)

  • hasSuccessfulToolCall:
    • returns true on a tool-result part with matching name
    • returns false when only a tool-error is present for the named tool
    • returns false when no part matches the name
    • inspects only the last step
    • returns false on empty steps
  • willContinue:

Verified: with the polished hasSuccessfulToolCall impl reverted to the original step.toolResults-based code, the first test fails — so the test file actually catches the asymmetry, not just rubber-stamps it.

CHANGELOG

  • New ## Unreleased section documenting the public hasSuccessfulToolCall helper (with usage example) and the willContinue fix.

Test plan

Notes

Follow-ups to #241 from the post-merge review.

- hasSuccessfulToolCall now reads from `step.content` and matches a
  `tool-result` part by toolName, mirroring the pattern in willContinue.
  Previously it read `step.toolResults` — which already excludes errors
  by type, so behavior is unchanged in practice, but reading from the
  same source as willContinue removes the asymmetry the reviewer flagged
  and is more obviously correct on inspection.
- Expand JSDoc on hasSuccessfulToolCall: explicitly note that tool-error
  parts do not match, and that the helper is evaluated only against the
  last step (consistent with how stopWhen is applied after each step).
- Clarify the comment on the willContinue fallback: under AI SDK v6
  step.content is always defined, so the optional chain and the
  `?? step.toolResults.length` fallback are defensive (for non-v6 /
  mock callers), not load-bearing for the v6 fix.
- Add src/client/utils.test.ts with unit tests covering:
  * hasSuccessfulToolCall returns true on tool-result, false on
    tool-error, false on a different toolName, false on empty steps,
    and only inspects the last step.
  * willContinue does not stop when a tool-error fills in for a missing
    tool-result, stops when an output is genuinely missing, and stops
    when finishReason isn't tool-calls.
- Add CHANGELOG entry under Unreleased noting the new public helper and
  the willContinue fix.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Warning

Rate limit exceeded

@sethconvex has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 47 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: get-convex/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 28bfda52-76c2-4863-8bcc-c6ce3bb702e7

📥 Commits

Reviewing files that changed from the base of the PR and between 84534d3 and e7031d8.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/client/utils.test.ts
  • src/client/utils.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch polish-has-successful-tool-call

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/agent@263

commit: e7031d8

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants