ToolCallContext

The tool call an AgentTool.execute is running for. Agent loops install it in the coroutine context, so a tool reaches it with current without the AgentTool interface growing parameters:

override suspend fun execute(arguments: JsonObject): String {
ToolCallContext.current()?.progress("Downloading…")
…
}

Types

Link copied to clipboard
Link copied to clipboard
sealed interface Update

What a running tool reports before it returns.

Properties

Link copied to clipboard

The approver of the enclosing chat; nested agents reuse it so their tools ask the same user.

Link copied to clipboard
open override val key: CoroutineContext.Key<*>
Link copied to clipboard

The model's id for this call.

Functions

Link copied to clipboard
suspend fun content(mediaType: String, url: String)

Return url to the model as well, as Pydantic AI's ToolReturn.content: on-device model loops send it in a user message right after the tool results, so a vision model sees it (e.g. a browser screenshot); the chat shows it with the call, like file. Servers' protocols carry tool results as text, so it reaches only models the device calls.

Link copied to clipboard
suspend fun data(id: String, name: String, data: JsonElement)

Add or replace a data part of the reply while the tool runs — e.g. plan for the Plan element. In-process only: servers use their protocol's own channel for this.

Link copied to clipboard
suspend fun file(mediaType: String, url: String)

Attach a file the call produced — a screenshot of what it did, a generated image — as a file part right after the call (AI SDK file part; the steps view shows it with this call). url is a data: or http(s) URL.

Link copied to clipboard
open override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
Link copied to clipboard
open operator override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
Link copied to clipboard
open override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
Link copied to clipboard
open operator fun plus(context: CoroutineContext): CoroutineContext
Link copied to clipboard
suspend fun progress(output: String)

Show output as an interim result (AI SDK preliminary tool result).

Link copied to clipboard
suspend fun subagent(message: Message)

Publish the live run of a delegated agent (rendered by the Subagent element).