Package-level declarations

Types

Link copied to clipboard
interface AgentTool

A function an agent loop can call: the on-device loops (OpenAI, Anthropic, Gemini, Ollama), and server agents that accept client-side tools (AG-UI frontend tools, AI SDK client tools). parameters is a JSON Schema object, shared verbatim by every API.

Link copied to clipboard

Lets the model ask the user multiple-choice questions mid-run — Pydantic AI Harness AskUser, with the same tool (ask_user_question), schema, limits, instruction and result, so prompts and servers written for it work unchanged.

Link copied to clipboard
data class AskUserQuestion(val header: String, val question: String, val options: List<AskUserQuestion.Option>, val multiSelect: Boolean)

One question of an ask_user_question call.

Link copied to clipboard

Built-in tool: evaluates an arithmetic expression (+ - * / % ^ and parentheses) without eval.

Link copied to clipboard
interface Capability

A composable bundle of what an agent can do: instructions added to the system prompt and tools it may call — the Kotlin counterpart of a Pydantic AI capability. SubAgents, dev.ai.elements.core.skills.Skills and MCP servers (dev.ai.elements.core.mcp.McpToolset) are capabilities; so is any app feature that pairs tools with guidance.

Link copied to clipboard

Built-in tool: the current date and time in an IANA timezone.

Link copied to clipboard
class StaticCapability(val instructions: String? = null, tools: List<AgentTool> = emptyList()) : Capability

A capability made of fixed tools and instructions.

Link copied to clipboard
class SubAgent(val name: String, val description: String, val backend: (ToolApprover) -> ChatBackend)

One delegate of SubAgents: a named agent with its own instructions, model and tools, reached through backend. Any ChatBackend works — an on-device loop, an AG-UI or AI SDK server, or a remote A2A agent.

Link copied to clipboard
class SubAgents(val agents: List<SubAgent>, val toolName: String = DELEGATE_TASK, clock: () -> Long = System::currentTimeMillis) : Capability

Lets the agent delegate self-contained tasks to named agents — the same contract as Pydantic AI Harness SubAgents, so on-device and server agents behave alike and UIs render both the same way:

Link copied to clipboard

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:

Link copied to clipboard
data class ToolResult(val text: String, val content: List<FilePart> = emptyList())

What a tool call gives the model: its text result and the content it returned for the model (ToolCallContext.content; Pydantic AI ToolReturn.content), which a model loop sends in a user message after the tool results.

Properties

Link copied to clipboard

The tools every on-device agent loop gets by default.

Functions

Link copied to clipboard
fun askUserAnswers(questions: List<AskUserQuestion>, content: JsonObject): JsonObject

The ask_user_question result for the user's content (an InputResponse.Accept of askUserSchema).

Link copied to clipboard
fun askUserQuestions(arguments: JsonObject): List<AskUserQuestion>

The questions of an ask_user_question call's arguments, validated as Pydantic AI Harness does.

Link copied to clipboard
fun askUserSchema(questions: List<AskUserQuestion>): JsonObject

The InputRequest schema for questions: standard JSON Schema, one property per question.

Link copied to clipboard
suspend fun collectTools(capabilities: List<Capability>): List<AgentTool>

All tools of capabilities; the first tool of a given name wins.

Link copied to clipboard
suspend fun composeInstructions(base: String, capabilities: List<Capability>): String

base, every capability's static instructions, then their per-turn Capability.context, separated by blank lines.

Link copied to clipboard
suspend fun FlowCollector<ChatEvent>.runTool(tools: List<AgentTool>, approver: ToolApprover, id: String, name: String, rawArgs: String): String

Execute one tool call of an agent loop, emitting the tool events. Tools with AgentTool.requiresApproval wait for approver first: a denial (with the user's reason) goes back to the model, edited arguments replace the proposed ones. While the tool runs, what it reports through ToolCallContext (interim output, a nested agent run) is streamed as ChatEvent.ToolOutput (preliminary) and ChatEvent.SubagentUpdate.

Link copied to clipboard
suspend fun FlowCollector<ChatEvent>.runToolWithContent(tools: List<AgentTool>, approver: ToolApprover, id: String, name: String, rawArgs: String): ToolResult

runTool, with the content the tool returned for the model.