Define Tool protocol and LLM provider abstraction

t-141.1·WorkTask·
·
·
·Omni/Agent/Engine.hs
Parent:t-141·Created3 months ago·Updated3 months ago

Description

Edit

Create Omni/Agent/Engine.hs with core abstractions:

Types

  • Tool: name, description, jsonSchema (Value), execute (Value -> IO ToolResult)
  • LLM: baseUrl, apiKey, model, extraHeaders
  • EngineConfig: llm, onCost callback, onActivity callback
  • Message: role, content, toolCalls, toolCallId
  • ToolCall, FunctionCall for OpenAI function calling protocol

Default LLM Config (OpenRouter)

  • baseUrl: https://openrouter.ai/api/v1
  • API key from OPENROUTER_API_KEY env var
  • Extra headers: HTTP-Referer, X-Title for OpenRouter tracking
  • Default model: anthropic/claude-sonnet-4-20250514

Functions

  • chat :: LLM -> [Tool] -> [Message] -> IO (Either Text Message)
  • OpenAI-compatible HTTP via http-conduit
  • Parse tool_calls from response
  • Include OpenRouter headers

Tests

  • JSON roundtrip for Message, ToolCall
  • Tool schema validation

Reference orphaned commit a41594ef for patterns (don't cherry-pick, reimplement).

Timeline (0)

No activity yet.