---
name: "ChatGPT agent backend via OpenAI API"
agent: coder-opus
---

# Story 344: ChatGPT agent backend via OpenAI API

## User Story

As a project owner, I want to run agents using ChatGPT (GPT-4o, o3, etc.) via the OpenAI API, so that I can use OpenAI models for coding tasks alongside Claude.

## Acceptance Criteria

- [ ] Implement OpenAiRuntime using the AgentRuntime trait from refactor 343
- [ ] Supports GPT-4o and o3 models via the OpenAI chat completions API
- [ ] Manages a conversation loop: send prompt + tool definitions, execute tool calls, continue until done
- [ ] Agents connect to huskies's MCP server for all tool operations — no custom file/bash tools needed
- [ ] MCP tool definitions are converted to OpenAI function calling format
- [ ] Configurable in project.toml: runtime = 'openai', model = 'gpt-4o'
- [ ] OPENAI_API_KEY passed via environment variable
- [ ] Token usage tracked and logged to token_usage.jsonl
- [ ] Agent output streams to the same event system (web UI, bot notifications)

## Out of Scope

- TBD
