mirror of
https://github.com/larsbaunwall/vscode-copilot-bridge.git
synced 2025-10-05 22:22:59 +00:00
1.8 KiB
1.8 KiB
Copilot Usage Notes
Always skim AGENTS.md before making changes—the document is the single source of truth for architecture, performance targets, and workflow expectations.
Hot-path rules
- Reuse the helpers in
src/http/utils.ts(writeUnauthorized,writeNotFound,writeRateLimit,writeErrorResponse) instead of hand-written JSON responses. - Preserve the SSE contract in
src/http/routes/chat.ts: emit role chunk first, follow withdata: { ... }payloads, and terminate withdata: [DONE]. - When streaming, keep
socket.setNoDelay(true)on the response socket to avoid latency regressions. - Honor
state.activeRequestsconcurrency guard and return early 429s viawriteRateLimit.
Tool calling compatibility
mergeToolsalready merges deprecatedfunctions; prefer extending it over new code paths.- The bridge treats
tool_choice: "required"like"auto"and ignoresparallel_tool_calls—reflect this limitation in docs if behavior changes. - Stream tool call deltas using
delta.tool_callschunks containing JSON-encoded argument strings. Downstream clients should replace, not append, argument fragments.
Scope & contracts
- Public endpoints are
/health,/v1/models,/v1/chat/completions. Changing contracts requires README updates and a version bump. - Keep the bridge loopback-only unless a new configuration knob is explicitly approved.
- Update configuration docs when introducing new
bridge.*settings and runnpm run compilebefore handing off changes.
Workflow
- Plan with the todo-list tool, keep diffs minimal, and avoid formatting unrelated regions.
- Capture limitations or behavior differences (e.g., missing OpenAI response fields) in comments or docs so clients aren’t surprised.
- Summarize reality after each change: what was touched, how it was verified, and any follow-ups.