summaryrefslogtreecommitdiff
path: root/z.scm
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-29 23:53:28 -0500
committerBen Sima <ben@bensima.com>2025-11-29 23:53:28 -0500
commita03642a75d94957846d4734f75e570694aeb41c4 (patch)
treee4b5603682dea4da16cb5c8f01295b99ae84f04c /z.scm
parent68dba338a7661563b752593b2fd522413cedd0b3 (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 'z.scm')
0 files changed, 0 insertions, 0 deletions