Skip to content

refactor: centralize client tool result construction - #217

Merged
renal128 merged 2 commits into
nextfrom
simplify-client-tool-results
Aug 4, 2026
Merged

refactor: centralize client tool result construction#217
renal128 merged 2 commits into
nextfrom
simplify-client-tool-results

Conversation

@renal128

@renal128 renal128 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the string and Encodable sendToolResult overloads with one method accepting ClientToolResultEvent.
  • Move JSON encoding into a throwing ClientToolResultEvent initializer while preserving verbatim string construction.
  • Update SDK examples and tool-result tests to use the event-based API.

Test plan

  • swiftformat 'Sources' 'Tests' --lint --strict
  • Focused startup/client/audio/tool tests
  • swift test

Note

Medium Risk
Breaking public API for tool results and callbacks; behavior is straightforward but every integrator must update call sites. No auth or connection-path changes.

Overview
sendToolResult on Conversation and ConversationClient now takes a single ClientToolResultEvent instead of separate for / result / isError overloads. Callers build results with ClientToolResultEvent.init(...) — string payloads stay verbatim; Encodable values are JSON-encoded via a new throwing initializer on the event type.

The client-tool callback is renamed from onUnhandledClientToolCall to onClientToolCall, and incoming clientToolCall events invoke that callback (not only “unhandled” cases). README, Usage docs, and tests follow the event-based pattern.

Reviewed by Cursor Bugbot for commit de20107. Bugbot is set up for automated code reviews on this repo. Configure here.

@renal128
renal128 force-pushed the simplify-client-tool-results branch from e5f6f76 to 3ca038f Compare July 20, 2026 10:29
@renal128
renal128 force-pushed the simplify-client-tool-results branch 2 times, most recently from d722e0f to e58d3c8 Compare July 20, 2026 13:38
@renal128
renal128 force-pushed the simplify-client-tool-results branch 2 times, most recently from 2924c48 to e88b2d0 Compare July 20, 2026 15:54
@renal128
renal128 force-pushed the simplify-client-tool-results branch from e88b2d0 to e4f8248 Compare July 20, 2026 16:20
@renal128
renal128 force-pushed the simplify-client-tool-results branch from e4f8248 to 5034ee6 Compare July 20, 2026 16:40
@renal128
renal128 force-pushed the simplify-client-tool-results branch 3 times, most recently from 47a03ee to eadd79b Compare July 20, 2026 21:29
@renal128
renal128 force-pushed the simplify-client-tool-results branch from eadd79b to 9dfd832 Compare July 20, 2026 21:53
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 9dfd832 to 6eea761 Compare July 20, 2026 22:32
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 6eea761 to 0001a68 Compare July 20, 2026 23:28
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 0001a68 to 2d43478 Compare July 21, 2026 10:51
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 2d43478 to 1200edb Compare July 21, 2026 12:28
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 1200edb to c919259 Compare July 21, 2026 23:02
@renal128
renal128 marked this pull request as ready for review July 21, 2026 23:04
@renal128
renal128 force-pushed the simplify-client-tool-results branch from c919259 to 07b86cd Compare July 22, 2026 13:21
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 07b86cd to 7f4c635 Compare July 22, 2026 15:33
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 7f4c635 to 069c41d Compare July 23, 2026 09:06
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 069c41d to 97d8172 Compare July 23, 2026 09:10
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 97d8172 to 352ac92 Compare August 4, 2026 15:47
Comment thread Sources/ElevenLabs/Public/Conversation/ConversationClient.swift
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 352ac92 to e6e9a64 Compare August 4, 2026 16:38
@renal128
renal128 force-pushed the simplify-client-tool-results branch from e6e9a64 to 6c92aa7 Compare August 4, 2026 18:33

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6c92aa7. Configure here.

Comment thread Sources/ElevenLabs/Public/Conversation/ConversationCallbacks.swift
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 6c92aa7 to 2428c5e Compare August 4, 2026 18:38
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 2428c5e to 4e4bbca Compare August 4, 2026 18:44
Base automatically changed from remove-livekit-track-reexports to next August 4, 2026 18:49
renal128 and others added 2 commits August 4, 2026 19:49
Let ClientToolResultEvent own string and Encodable result creation so the client and session expose one focused send method.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@renal128
renal128 force-pushed the simplify-client-tool-results branch from 4e4bbca to de20107 Compare August 4, 2026 18:49
@renal128
renal128 merged commit bc60960 into next Aug 4, 2026
2 checks passed
@renal128
renal128 deleted the simplify-client-tool-results branch August 4, 2026 19:11
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.

3 participants