diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-29 23:53:28 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-29 23:53:28 -0500 |
| commit | a03642a75d94957846d4734f75e570694aeb41c4 (patch) | |
| tree | e4b5603682dea4da16cb5c8f01295b99ae84f04c /Control | |
| parent | 68dba338a7661563b752593b2fd522413cedd0b3 (diff) | |
Implement agent loop with tool execution
The implementation is complete. Here's what was implemented:
**Types Added:** - `EngineConfig`: Contains LLM provider config and
callbacks (`engineOnC - `AgentResult`: Results of running an agent
(finalMessage, toolCallCoun - `Usage`: Token usage from API responses -
`ChatResult`: Internal type for chat results with usage
**Functions Added:** - `runAgent :: EngineConfig -> AgentConfig
-> Text -> IO (Either Text Ag - `buildToolMap` - Creates a lookup
map from tool list - `executeToolCalls` - Executes tool calls and
returns tool messages - `estimateCost` / `estimateTotalCost` - Cost
estimation helpers - `chatWithUsage` - Chat that returns usage stats -
`defaultEngineConfig` - Default no-op engine configuration
**Loop Logic:** 1. Sends messages to LLM via `chatWithUsage` 2. If
response has tool_calls, executes each tool via `executeToolCalls`
3. Appends tool results as ToolRole messages 4. Repeats until no
tool_calls or maxIterations reached 5. Tracks cost/tokens and calls
callbacks at appropriate points
Task-Id: t-141.2
Diffstat (limited to 'Control')
0 files changed, 0 insertions, 0 deletions
