Skip to content

feat(provider): make complete/stream overridable for in-process providers - #4

Merged
ayman3000 merged 1 commit into
mainfrom
feat/in-process-provider-support
Jul 27, 2026
Merged

feat(provider): make complete/stream overridable for in-process providers#4
ayman3000 merged 1 commit into
mainfrom
feat/in-process-provider-support

Conversation

@ayman3000

Copy link
Copy Markdown
Owner

Summary

Groundwork for on-device inference (Phase 8 / MLX): make LLMProvider.complete(_:) and stream(_:) overridable.

They were defined only in an extension, so through any LLMProvider (how Agent/LLMService call providers) they were statically dispatched to the HTTP implementation — an in-process provider's override would never run. This promotes them to protocol requirements (the existing HTTP code becomes the default impl), so a provider that runs locally (MLX, llama.cpp, a mock) can override complete/stream directly.

Also adds default (throwing/empty) implementations for the HTTP-shaped hooks (prepareRequest, parseStreamLine, parseResponse) so an in-process provider only implements complete/stream + name/configuration.

Existing HTTP providers (Ollama/OpenAI/Anthropic/Gemini) are unaffected — they implement all three hooks and rely on the default complete/stream.

Tests

New InProcessProviderTests with an EchoLocalProvider (no HTTP):

  • complete override wins dispatch through any LLMProvider.
  • stream override wins dispatch.
  • the HTTP hooks throw by default.

All 38 tests pass.

Why

Unblocks a future MLXProvider that plugs into the same Agent/UI with no changes — the on-device stretch for Naseem.

🤖 Generated with Claude Code

…ders

Promotes complete(_:) and stream(_:) to LLMProvider protocol requirements
(existing HTTP impls become the defaults), so an on-device provider — MLX,
llama.cpp, etc. — can override them and be dispatched correctly through
`any LLMProvider`. Previously they were extension-only (static dispatch),
so an override was never called via the existential and the HTTP path won.

Also adds default (throwing/empty) impls for the HTTP-shaped hooks
(prepareRequest/parseStreamLine/parseResponse) so an in-process provider
only implements complete/stream + name/configuration. Existing HTTP
providers are unchanged.

Regression: an in-process EchoLocalProvider overrides complete/stream and
wins dispatch through the existential; HTTP hooks throw by default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@ayman3000
ayman3000 merged commit e1702e9 into main Jul 27, 2026
1 check passed
@ayman3000
ayman3000 deleted the feat/in-process-provider-support branch July 27, 2026 19:58
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