llm/shellm: add OpenAI Responses completion protocol - #101
Open
24601 wants to merge 6 commits into
Open
Conversation
24601
force-pushed
the
feat/responses-api
branch
2 times, most recently
from
September 2, 2026 15:01
343cf9e to
6f41636
Compare
Add opt-in Responses create and SSE support for OpenAI, OpenRouter, and generic compatible endpoints. Preserve typed items, terminal response state, usage, reasoning summaries, and shellm continuation with exact replay fallback while keeping Chat Completions as the default. Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Basit Mustafa <basit.mustafa@gmail.com>
Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: Basit Mustafa <basit.mustafa@gmail.com>
Keep --stop-after-code-block on chat so shellm still cuts the stream at the first fence, but skip it for Responses (continuation needs the terminal event). Deduplicate previous_response_id error matching. Raise LOC_LIMIT to 11500 and the README/philosophy line-count claim so the protocol can land without silent core growth. Amp-Thread-ID: https://ampcode.com/threads/T-01a06587-820b-734b-a505-b10d58712e10 Co-authored-by: Basit Mustafa <basit.mustafa@gmail.com>
24601
force-pushed
the
feat/responses-api
branch
from
September 3, 2026 04:47
6f41636 to
678a8bc
Compare
Resolve Responses protocol overlaps with upstream context-scope help and cached-token accounting. Preserve cache_tok for both buffered and streamed Responses and add regression coverage. Co-authored-by: Basit Mustafa <basit.mustafa@gmail.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a0679e-60c1-72ca-a36f-2428be671374
Require terminal Responses events before accepting streamed output or executing it in shellm. Track the prior rendered context so continuation deltas cannot silently resend pinned prompts when bounded context drops their boundary. Preserve upstream cached-token accounting for buffered and streamed Responses. Co-authored-by: Basit Mustafa <basit.mustafa@gmail.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a0679e-60c1-72ca-a36f-2428be671374
Amp-Thread-ID: https://ampcode.com/threads/T-01a0679e-60c1-72ca-a36f-2428be671374 Co-authored-by: Basit Mustafa <basit.mustafa@gmail.com>
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.
What
Adds an opt-in OpenAI Responses completion protocol to the existing
bin/llmprovider seam and letsshellmcontinue Responses state safely within one run. Chat Completions remains the default and is unchanged.Set
LLM_API_FORMAT=responsesforllm, orSHELLM_API_FORMAT=responsesforshellm. This preserves native reasoning and response state across shellm turns and unlocks models and features available only through Responses.Completion contract
openai-compatibleuses the configured endpoint.LLM_RESPONSES_BODY_FILEaccepts a bounded compatible create surface, including tools,include, store, text format, metadata, truncation, service tier, and provider extensions. CLI-owned fields remain deterministic; conversation state and background mode are rejected.includewithreasoning.encrypted_contentso stateless replay can preserve reasoning.LLM_RESPONSE_FILEatomically records the full terminal Response or error envelope as mode 0600.shellm continuation
shellmkeeps response state process-local. Native OpenAI and compatible endpoints useprevious_response_idwhile retaining an exact typed replay chain. If continuation is rejected, shellm retries once from that replay and remains stateless for the rest of the run. OpenRouter starts in replay mode because its Responses API is stateless. Remote response IDs are not written to the durable trajectory.Retrieve, cancel, delete, input-item listing, Conversations, background jobs, compaction, and WebSocket lifecycle operations remain out of scope.
Verification
bash tests/test_llm_responses.sh— 27 passed, 0 failedbash tests/test_shellm_responses_continuation.sh— 14 passed, 0 failed