KoogBackend

class KoogBackend(executor: PromptExecutor, model: LLModel, tools: List<AgentTool> = emptyList(), instructions: String = "", approver: ToolApprover = ToolApprover.AlwaysApprove, maxIterations: Int = 50, strategy: AIAgentGraphStrategy<String, String> = singleRunStrategy()) : ChatBackend(source)

A JetBrains Koog agent as a ChatBackend: each turn runs a Koog AIAgent on executor / model with tools and instructions, and its lifecycle (LLM calls and streaming frames, tool calls) is mapped onto chat events. Tools run through AI Elements' tool handling, so approvals, progress and sub-agent updates work as with the built-in loop.

Plug it into an in-app harness as its model binding — Koog then drives the harness' capabilities (files, sandbox, skills, MCP…):

val harness = AgentHarness(
model = { tools, instructions, approver -> KoogBackend(simpleOpenAIExecutor(key), OpenAIModels.Chat.GPT5, tools, instructions, approver) },
capabilities = { listOf(fileSystem, shell, skills) },
)

Earlier turns are passed to Koog as text (user and assistant messages); strategy defaults to Koog's singleRunStrategy(). A streaming strategy's frames are forwarded as they arrive; otherwise each LLM response appears when it completes.

Constructors

Link copied to clipboard
constructor(executor: PromptExecutor, model: LLModel, tools: List<AgentTool> = emptyList(), instructions: String = "", approver: ToolApprover = ToolApprover.AlwaysApprove, maxIterations: Int = 50, strategy: AIAgentGraphStrategy<String, String> = singleRunStrategy())

Functions

Link copied to clipboard
open override fun stream(history: List<Message>): Flow<ChatEvent>