Skip to content

llm: /responses wire format, copilot provider, window from the model list - #420

Merged
rromenskyi merged 5 commits into
mainfrom
copilot-responses
Nov 28, 2026
Merged

rromenskyi merged 5 commits into
mainfrom
copilot-responses

Conversation

@rromenskyi

Copy link
Copy Markdown
Contributor

What

  • wire_api per connection: chat (default), responses, or auto. /responses requests send the whole conversation each turn (store: false); tool calls round-trip by call_id; the stream is complete only at response.completed / response.incomplete, and response.failed / error events get the same retry treatment as chat-stream errors.
  • auto reads the server's model list once per client and uses /responses for a model listed as served only there.
  • copilot built-in: https://api.githubcopilot.com, key from gh auth token (attached when resolving, only for that address, only with gh installed and no key set; never written to the config file). COPILOT_GITHUB_TOKEN also works.
  • Context window is read from capabilities.limits.max_prompt_tokens too. With api_key_cmd, the client reads it before its first request so a one-shot run trims against it instead of running with no window.

Verified

  • Unit tests for the stream parser, request body, auto selection, lookup, preset resolution, -m copilot: staying off disk, and the agent trimming against the client-found window. Each fix checked by breaking it (25/25 caught).
  • Live: -m copilot:gpt-4.1 -read-only on a clean config — window 64000 found before the first request, tool call, answer, config file untouched.
  • Live: /responses against llama-server with a local reasoning model — two tool rounds and a correct answer.
  • Not verified: a hosted reasoning model on /responses with tool rounds (no access from the test account).

🤖 Generated with Claude Code

…list

- wire_api ("chat" | "responses" | "auto") picks the request format per
  connection. /responses requests carry the conversation whole (store:false):
  leading system text as instructions, past calls as function_call items
  without the server's item id, outputs by call_id, tools flattened with
  strict off, max_output_tokens, reasoning_effort moved to reasoning.effort.
  The stream is complete only at response.completed/incomplete; failed and
  error events go through the chat path's transient/permanent split.
- "auto" reads the model list once per client and uses /responses for a
  model listed as served only there (supported_endpoints).
- Built-in "copilot" provider: api.githubcopilot.com, key from
  `gh auth token` — attached at resolve time, only for the template's own
  address, only when gh is installed and no key is set; never saved.
- The model list's capabilities.limits (max_prompt_tokens) gives the
  window. When the key comes from api_key_cmd, no probe can read it before
  the first task, so the client reads it before its first request and the
  run trims against it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

rromenskyi and others added 4 commits November 28, 2026 00:41
- Calls are kept by call_id; argument events without one find their call by
  item id, then output_index, then the call streaming now — a server that
  gives an item a new id per event no longer splits one call into several.
- A finished item or done event without arguments keeps the streamed ones;
  done arguments may come as an object.
- The finished response's output fills in calls and text the events left
  out; with calls streamed, it never adds one they don't match.
- The model-list read is retried (up to 3 tries) instead of pinning an auto
  client to chat after one failure; a cancelled request doesn't count.
- Body and path come from one read of the wire format.
- The runaway cap follows a window found in the model list.
- copilot's key command names github.com, so another default gh host's
  token isn't sent; its base URL matches with a trailing slash too.
- An unknown wire_api value stops the config from loading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r's file only

- A call streamed with no call_id takes it (and its name) from an unmatched
  item in the finished response, in order — the same call under new ids.
- A done event naming a call_id not seen yet finishes the call streaming now
  when that call had none, instead of starting a second one.
- An arguments event matched only to the call streaming now no longer
  records its ids as that call's, so a call announced after it isn't merged.
- Calls with no ids at all stay separate.
- An unknown wire_api in a workspace's .agent/config.json no longer stops the
  run: those connection settings are discarded anyway. The user's own file
  is still checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- An arguments event with an output_index nothing has claimed belongs to a
  call not announced yet; only an event with no index falls back to the call
  streaming now.
- A call_id shown late goes to the one call still without one, and is
  never guessed among several.
- The finished response names a streamed call only when exactly one lacks a
  call_id.
- A call left without a name or call_id stops the turn instead of running.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A call kept under its item id or output_index that later showed a call_id
was not found by that call_id: the finished response listing it under a new
item id could hand its call_id to another, unnamed call, and both ran. Calls
are now looked up by call_id through a map of their own; a finished-response
call that matches nothing is logged and not run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rromenskyi
rromenskyi merged commit 306195a into main Nov 28, 2026
2 checks passed
@rromenskyi
rromenskyi deleted the copilot-responses branch November 28, 2026 08:12
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