AgentHarness
An in-app agent: a model plus capabilities (tools, skills, MCP servers…), served as a ChatBackend for dev.ai.elements.core.chat.ChatController — the Kotlin counterpart of a Pydantic AI agent with Harness capabilities.
Every turn re-reads the providers (they are suspend so they can reflect the user's current settings and do I/O such as listing MCP tools). Sub-agents are exposed through SubAgents (delegate_task): localSubAgents run on this harness with its capabilities, remoteSubAgents are ready-made (e.g. A2A agents from ai-elements-a2a). Delegation is limited to maxDepth levels, counting the top-level run, like Harness' max_depth.
val harness = AgentHarness(
model = profile.model(apiKey),
capabilities = { listOf(Skills.from(library), mcpServers.toolset()) },
localSubAgents = { listOf(LocalSubAgent("researcher", "Researches topics", "Be thorough.")) },
)
val chat = ChatController(backend = harness::backend, scope = viewModelScope)Constructors
Functions
The backend of the next turn; pass it as ChatController(backend = harness::backend).
runHeadless on this harness. Nobody can approve tools here, so calls that need approval are denied unless approver says otherwise.