summaryrefslogtreecommitdiff
path: root/Omni/Agent/Engine.hs
AgeCommit message (Collapse)Author
2025-11-30Define Tool protocol and LLM provider abstractionBen Sima
The implementation is complete. Here's a summary of the changes made: 1. **Updated LLM type** to include `llmExtraHeaders` field for OpenRoute 2. **Changed `defaultLLM`** to use: - OpenRouter base URL: `https://openrouter.ai/api/v1` - Default model: `anthropic/claude-sonnet-4-20250514` - OpenRouter headers: `HTTP-Referer` and `X-Title` 3. **Updated `chatWithUsage`** to apply extra headers to HTTP requests 4. **Added `case-insensitive` dependency** for proper header handling 5. **Added tests** for OpenRouter configuration 6. **Fixed hlint suggestions** (Use `</` instead of `<$>`, eta reduce) Task-Id: t-141.1
2025-11-29Implement agent loop with tool executionBen Sima
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
2025-11-29Define Tool protocol and LLM provider abstractionBen Sima
The implementation is complete. I created [Omni/Agent/Engine.hs](file:// - **Types**: `Tool`, `LLM`, `AgentConfig`, `Message`, `Role`, `ToolCall` - **Functions**: `chat` for OpenAI-compatible HTTP via http-conduit, `de - **Tests**: JSON roundtrip for Tool, Message; validation of defaults All lints pass (hlint + ormolu) and tests pass. Task-Id: t-141.1