Principle:A9T9 RPA AI Conversation Initiation
| 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:
Until has no tool calls.