Add runAgent to Engine.hs:
Function
runAgent :: EngineConfig -> AgentConfig -> IO (Either Text AgentResult)
AgentConfig
- tools :: [Tool]
- systemPrompt :: Text
- userPrompt :: Text
- maxIterations :: Int
AgentResult
- finalMessage :: Text
- toolCallCount :: Int
- iterations :: Int
- totalCost :: Int (cents)
- totalTokens :: Int
Loop Logic
1. Send messages to LLM via chat
2. If response has tool_calls, execute each tool
3. Append tool results as ToolRole messages
4. Repeat until no tool_calls or maxIterations reached
5. Track cost/tokens, call callbacks
Integration Points
- Call engineOnCost after each LLM call
- Call engineOnActivity for status updates
- Call engineOnToolCall after each tool execution