ReActAgent

class ReActAgent(broker: LlmBroker, model: String, availableTools: List<LlmTool> = emptyList(), maxIterations: Int = 5, systemPrompt: String? = null, config: CompletionConfig = CompletionConfig())

Single-class reasoning-and-acting (ReAct) agent.

Runs a chat loop with a system prompt that asks the LLM to alternate Thought: / Action: / Observation: cycles and finish with a FINAL ANSWER: marker. The underlying LlmBroker handles tool dispatch recursively, so each iteration here is one round-trip of reasoning — the tool plumbing is already taken care of.

Mirrors the Python reference's ReAct example pattern, collapsed into a single Kotlin class. The multi-agent fan-out of the Python example is intentionally not ported — the broker's recursive tool execution is the Kotlin idiom for the same loop.

Constructors

Link copied to clipboard
constructor(broker: LlmBroker, model: String, availableTools: List<LlmTool> = emptyList(), maxIterations: Int = 5, systemPrompt: String? = null, config: CompletionConfig = CompletionConfig())

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun solve(query: String): String

Run the ReAct loop until the model emits a FINAL ANSWER: line or the iteration budget is exhausted. Returns the extracted final answer (or the last raw response when the budget runs out).

Link copied to clipboard

Snapshot of every ReActStep emitted during the most recent solve call.