Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:A9T9 RPA AI Conversation Initiation

From Leeroopedia
Knowledge Sources
Domains AI_Agent, Conversation_Orchestration
Last Updated 2026-10-22 00:00 GMT

Overview

Mechanism for driving an AI conversation loop with tool calling: sending the user prompt and context, receiving AI responses with tool calls, executing tools, feeding results back, and iterating until a final response.

Description

AI Conversation Initiation is the sampling loop that drives the AI macro agent. The `MacroAgentService.run(prompt)` method:

  • Builds initial context: gathers the current editor macro and recent log lines as context for the AI
  • Sends to the AI provider: calls the configured provider (Anthropic Claude, OpenRouter/OpenAI-compatible, local model, or Ui.Vision free tier) with the system prompt, conversation history, and tool definitions
  • Processes tool calls: when the AI response contains tool calls, dispatches each to `MacroAgentTools.executeToolCall` and appends the result to the conversation history
  • Iterates: sends the updated conversation back to the AI for the next response
  • Terminates: the loop ends when the AI produces a text response without tool calls, or the loop limit (50 turns) is reached, or the user stops the run

A generation counter orphans abandoned turns: if a new run or `createNewChat` is called while a previous run is in flight, the old run's results are discarded.

Usage

Use this principle when designing an AI agent that drives automation through a tool-calling conversation loop with an LLM.

Theoretical Basis

The conversation loop is an iterative refinement:

history0=[system,context]

historyi+1=historyi∪AI(historyi)∪Tools(AI(historyi))

Until AI(historyn) has no tool calls.

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment