Skip to content

lab: openai provider, any OpenAI-compatible API with its own key - #23

Merged
AdvayMonga merged 3 commits into
mainfrom
lab/agent-gateway
Oct 10, 2026
Merged

AdvayMonga merged 3 commits into
mainfrom
lab/agent-gateway

Conversation

@AdvayMonga

@AdvayMonga AdvayMonga commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Lets any model drive the agent loop with its provider's own API key, not only Claude. Replaces the earlier gateway approach (no local routing).

  • lab/agent_openai.py, selected with LAB_AGENT_PROVIDER=openai + LAB_MODEL:
    • Talks to any OpenAI-compatible chat-completions API (OpenAI, Gemini, DeepSeek, Mistral, OpenRouter). LAB_OPENAI_BASE_URL must be https and a public host (no localhost, private IPs, .local or .internal); defaults to OpenAI. The key comes from OPENAI_API_KEY.
    • The loop runs in the harness process, so the key never enters the jail.
    • Built-in tools: Read, Write, Edit, Glob, Grep, Bash. File tools are confined to the workspace, writes go through the same hooks.allowed guard as the Claude provider, and Bash runs through grader.jailed with no network. Lab tools are passed through unchanged.
    • The session ends through a finish tool with the usual {status, note}, or at max turns, timeout or the session's dollar cap. Failures come back as a reply and never raise.
    • Cost is usage × LAB_MODEL_PRICE="in,out" ($ per million tokens). The provider refuses to start without it. A response without usage is charged at the session cap (cost.estimated).
  • lab/agent.py: load() registers openai. The Claude provider is unchanged from main.
  • tests/test_lab_agent_openai.py: 13 tests against a scripted fake API. They cover the tools, write-guard refusals, workspace escape, Bash, lab tools, the "no tool call" turn, finish, the cost cap, missing usage, API failure, URL refusals, and required settings.
  • One line each in lab/README.md and CLAUDE.md.

Full lab suite: 231 passed, 5 skipped; ruff clean. Not yet run against a real provider API.

🤖 Generated with Claude Code

@AdvayMonga AdvayMonga changed the title lab: any agent model through an Anthropic-compatible gateway lab: openai provider, any OpenAI-compatible API with its own key Oct 10, 2026
AdvayMonga and others added 3 commits October 10, 2026 13:00
LAB_AGENT_PROVIDER=openai runs the session loop in the harness against any
OpenAI-compatible chat-completions API (OpenAI, Gemini, DeepSeek, Mistral,
OpenRouter), called directly: https and a public host only, so nothing is
routed locally. The key never enters the jail. Built-in tools (Read, Write,
Edit, Glob, Grep, Bash) stay in the workspace; writes pass the same write
guard as the Claude provider; Bash runs jailed with no network. Sessions end
through a `finish` tool with the usual {status, note}. Cost is usage times
LAB_MODEL_PRICE, required; a response without usage is charged at the cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A symlink written by jailed Bash let Grep (run outside the jail) read the lab's keys, ledger or held-out files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AdvayMonga
AdvayMonga merged commit 0a73453 into main Oct 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant