# Streaming Types > Reference for SendHandlers, ToolCall and ToolResult, the types you meet while an answer streams While `send` or `retry` runs, the SDK reports progress through `SendHandlers`. Tool activity arrives as `ToolCall` and `ToolResult` values. This page lists each type and its fields. ## SendHandlers `struct SendHandlers: Sendable` The handlers you set in the `configure` closure of `send(_:conversationId:configure:)` and `retry(conversationId:messageId:configure:)`. ```swift public struct SendHandlers: Sendable { public var onTextDelta: (@Sendable (String) -> Void)? public var onToolCall: (@Sendable (ToolCall) -> Void)? public var onToolResult: (@Sendable (ToolResult) -> Void)? public init() } ``` | Handler | Type | Description | | - | - | - | | `onTextDelta` | `(@Sendable (String) -> Void)?` | Called for each piece of the agent's text. Add it to the current bubble. | | `onToolCall` | `(@Sendable (ToolCall) -> Void)?` | Called when the agent calls a tool: one you registered, or one the server runs. | | `onToolResult` | `(@Sendable (ToolResult) -> Void)?` | Called when a tool finishes, whether your handler or the server ran it. | Handlers you don't set are ignored: ```swift let response = try await client.send("Hello") { handlers in handlers.onTextDelta = { piece in print(piece, terminator: "") } // onToolCall and onToolResult not set } ``` > [!NOTE] > > There's no `onStart`, `onFinish` or `onError`. The call returns a `ChatResponse` when it works and throws when it doesn't. See [Streaming](/docs/ios-sdk/streaming). > [!WARNING] > > Handlers are synchronous and run on the client's actor, not the main thread. Use `Task { @MainActor in … }` before touching your UI, and keep them quick: the SDK reads the next piece of the answer after your handler returns. ## ToolCall `struct ToolCall: Sendable, Equatable` Passed to `onToolCall`, and kept in `MessagePart.toolCall`. ```swift public struct ToolCall: Sendable, Equatable { public let id: String public let name: String public let input: JSONValue } ``` | Property | Type | Description | | - | - | - | | `id` | `String` | An ID for this call. Use it to match the call with its `ToolResult`. | | `name` | `String` | The tool's name, which is the action's **Action name**. | | `input` | `JSONValue` | Everything the agent passed to the tool. See [JSONValue](/docs/ios-sdk/json-value). | ```swift handlers.onToolCall = { call in let orderNumber = call.input["order_number"]?.stringValue Task { @MainActor in model.showToolCard(id: call.id, name: call.name, detail: orderNumber) } } ``` ## ToolResult `struct ToolResult: Sendable, Equatable` Passed to `onToolResult`, and kept in `MessagePart.toolResult`. ```swift public struct ToolResult: Sendable, Equatable { public let id: String public let name: String public let output: JSONValue } ``` | Property | Type | Description | | - | - | - | | `id` | `String` | The `id` of the `ToolCall` this result answers. | | `name` | `String` | The tool's name. | | `output` | `JSONValue` | What the tool returned. An object with an `error` key means it failed. See [JSONValue](/docs/ios-sdk/json-value). | ```swift handlers.onToolResult = { result in let failed = result.output["error"] != nil Task { @MainActor in model.completeToolCard(id: result.id, failed: failed) } } ``` > [!TIP] > > Both handlers also run for tools the server runs, such as API actions and integrations, so one piece of UI can show every tool the agent uses. ## Tool handlers ```swift @Sendable (JSONValue) async throws -> JSONValue ``` The shape of a handler you register with `client.tool(_:handler:)`: it receives the call's `input` and returns the result. See [Client-Side Tools](/docs/ios-sdk/client-side-tools). ## Lower-level stream The SDK reads the answer stream itself and turns it into handler calls and the finished `ChatResponse`. The stream's events are not public types. > [!WARNING] > > There's no way to read the raw events as they arrive: `QwryClient` has no `AsyncSequence` or Combine publisher for them. Use `send` with handlers. Events the SDK doesn't recognize are skipped, so an app you've shipped keeps working as QwryAI adds new kinds of events. ## Related > [card] Streaming | /docs/ios-sdk/streaming | Using the handlers in practice. > [card] Client-Side Tools | /docs/ios-sdk/client-side-tools | Registering tools the agent can run. > [card] ChatResponse | /docs/ios-sdk/chat-response | What a finished answer contains. > [card] JSONValue | /docs/ios-sdk/json-value | Reading tool data.