Add OpenAI-compatible CLI AI provider - #4206
Closed
georgestephanis wants to merge 3 commits into
Closed
Conversation
Introduces a new `openai-compatible` provider in the CLI, including persisted config fields (base URL, API key, model) and provider selection support. It adds a local Anthropic-to-OpenAI compatibility gateway that maps `/v1/messages` requests to `/chat/completions` responses, with support for tool calls and streaming SSE translation. Also adds a `/openai-config` slash command for updating endpoint settings and updates provider availability tests.
Author
|
ugh, seems my fork I worked on for the pr was slightly out of date, fixing via a merge ... |
Author
|
Oof, much bigger out of date as it's now using pi as the harness. Closing this, I'll rebuild on top of current trunk. |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces a new
openai-compatibleprovider in the CLI, including persisted config fields (base URL, API key, model) and provider selection support. It adds a local Anthropic-to-OpenAI compatibility gateway that maps/v1/messagesrequests to/chat/completionsresponses, with support for tool calls and streaming SSE translation. Also adds a/openai-configslash command for updating endpoint settings and updates provider availability tests.Related issues
How AI was used in this PR
The PR was built with the help of Claude Sonnet 5 operating in VSCode. We also set up and ran local tests against Apfel running locally, as well as Qwen3.6-27b running on a networked vLLM install with a 64k context window.
For anyone unfamiliar with Apfel -- it generally has a 4k context window, and if you're testing on a Mac is trivial to set up with the Foundation Model that MacOS generally already has in place.
Proposed Changes
Testing Instructions
Prerequisites: a local OpenAI-compatible server. Easiest two, both already on this machine:
http://localhost:11435/v1, modelapple-foundationmodel) — 4096-token window, so compaction triggers almost immediately. Best for seeing the behavior.http://hostname:8000/v1, modelqwen3.6-27b) — 65536-token window. Best for confirming the fast-path (no needless compaction) and real summarization. -- if anyone wants to test against this machine, DM me on .org slack and I'll get you the port and an api key.Any OpenAI-compatible backend works too (LM Studio, Ollama, llama.cpp
--server).Expect 10 passing tests covering discovery (
context_window/max_model_len/ fallback), budget-triggered compaction, tool_use↔tool_result pairing safety, and rolling-summary reuse/divergence./openai-configand point it at Apfel (base URLhttp://localhost:11435/v1, no key, modelapple-foundationmodel).context_length_exceeded. Before this change, that same long conversation against a 4k backend would fail once history exceeded the window. The recent turns stay accurate; older context is represented by a summary the model folded into its system prompt./v1/modelsomits any context field, or an unreachable URL → gateway falls back to an 8192-token default and still works (verified: discovery never throws).Pre-merge Checklist
Verification: 10 new unit tests + all 98 existing ai-module tests pass, lint and typecheck are clean, and manual smoke tests against both real backends confirm the whole pipeline — discovery, budget math, splitting, live summarization, and normal chat flow — works end to end.