refactor(providers): extract ProviderDef trait and OpenAiCompatibleProvider#6832
Merged
codefromthecrypt merged 5 commits intomainfrom Feb 2, 2026
Merged
refactor(providers): extract ProviderDef trait and OpenAiCompatibleProvider#6832codefromthecrypt merged 5 commits intomainfrom
codefromthecrypt merged 5 commits intomainfrom
Conversation
3 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the provider system by separating provider construction (ProviderFactory trait) from runtime behavior (Provider trait), reducing boilerplate for OpenAI-compatible providers.
Changes:
- Introduces
ProviderFactorytrait withmetadata()andfrom_env()methods, previously part ofProvider - Adds
OpenAiCompatibleProviderimplementation to consolidate shared OpenAI-compatible logic - Simplifies provider registration from
registry.register::<XaiProvider, _>(|m| Box::pin(XaiProvider::from_env(m)), false)toregistry.register::<XaiProvider>(false)
Reviewed changes
Copilot reviewed 37 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/goose/src/providers/base.rs | Adds ProviderFactory trait, removes metadata() from Provider trait |
| crates/goose/src/providers/openai_compatible.rs | New file containing shared OpenAI-compatible provider implementation and utility functions moved from utils.rs |
| crates/goose/src/providers/xai.rs | Refactored to use OpenAiCompatibleProvider, significantly reducing boilerplate |
| crates/goose/src/providers/azure.rs | Refactored to use OpenAiCompatibleProvider, removing duplicate implementation |
| crates/goose/src/providers/provider_registry.rs | Simplified registration using ProviderFactory trait |
| crates/goose/src/providers/factory.rs | Updated all provider registrations to use simplified syntax |
| crates/goose/src/providers/utils.rs | Removed OpenAI-compat utility functions (moved to openai_compatible.rs) |
| crates/goose/src/providers/openai.rs | Updated to use get_secrets() for better secret handling, implements ProviderFactory |
| crates/goose/src/providers/*.rs | All providers updated to implement ProviderFactory separately from Provider |
| crates/goose/tests/*.rs | Test mocks updated to implement ProviderFactory, removed metadata() from mock Provider impls |
| crates/goose-mcp/.gooseignore | Standard goose ignore file added for MCP crate |
| crates/goose-acp/tests/fixtures/mod.rs | Added recursion limit directive for consistency |
| clippy-baselines/too_many_lines.txt | Added build_canonical_models to allowed long functions |
7f73f14 to
efae4cd
Compare
michaelneale
reviewed
Feb 2, 2026
05776df to
c76df2d
Compare
…leProvider Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
7ecb327 to
218cbfc
Compare
michaelneale
approved these changes
Feb 2, 2026
Collaborator
michaelneale
left a comment
There was a problem hiding this comment.
I think this is ok - main concern was azure shift to streaming and missing methods for loading models @codefromthecrypt
katzdave
added a commit
that referenced
this pull request
Feb 3, 2026
…ntext * 'main' of github.com:block/goose: refactor(providers): extract ProviderDef trait and OpenAiCompatibleProvider (#6832) feat: ask ai discord bot (#6842) chore(maintenance): make GitHub repo configurable for auto-updater and publisher (#6828) fix: make apps work in built copies of goose (#6901) Remove dependency on goose-mcp from goose crate (#6637) Clean up build canonical warnings (#6880) Sync desktop_prompt with UI (#6898)
kuccello
pushed a commit
to kuccello/goose
that referenced
this pull request
Feb 3, 2026
- Merged upstream changes including PR block#6832 (OpenAiCompatibleProvider) - Refactored Ollama XML tool call parsing to use new architecture: - Added stream_ollama() function in openai_compatible.rs - Updated ollama.rs to use ProviderDef trait and new imports - Cleaned up single-line comments in formats/ollama.rs - Fixed reqwest multipart feature flag for api_client.rs - Fixed clippy warnings in utils.rs Signed-off-by: Keith Uccello <kuccello@gmail.com>
stebbins
pushed a commit
to stebbins/goose
that referenced
this pull request
Feb 4, 2026
…ovider (block#6832) Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: Harrison <hcstebbins@gmail.com>
2 tasks
kuccello
pushed a commit
to kuccello/goose
that referenced
this pull request
Feb 7, 2026
…ovider (block#6832) Signed-off-by: Adrian Cole <adrian@tetrate.io>
kuccello
added a commit
to kuccello/goose
that referenced
this pull request
Feb 7, 2026
- Merged upstream changes including PR block#6832 (OpenAiCompatibleProvider) - Refactored Ollama XML tool call parsing to use new architecture: - Added stream_ollama() function in openai_compatible.rs - Updated ollama.rs to use ProviderDef trait and new imports - Cleaned up single-line comments in formats/ollama.rs - Fixed reqwest multipart feature flag for api_client.rs - Fixed clippy warnings in utils.rs Signed-off-by: Keith Uccello <kuccello@gmail.com> Signed-off-by: kuccello <kuccello@users.noreply.github.com>
Tyler-Hardin
pushed a commit
to Tyler-Hardin/goose
that referenced
this pull request
Feb 11, 2026
…ovider (block#6832) Signed-off-by: Adrian Cole <adrian@tetrate.io>
Tyler-Hardin
pushed a commit
to Tyler-Hardin/goose
that referenced
this pull request
Feb 11, 2026
…ovider (block#6832) Signed-off-by: Adrian Cole <adrian@tetrate.io>
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.
Summary
Separate provider construction from runtime behavior to reduce boilerplate and prepare for ACP-backed providers.
ProviderDef: new trait withmetadata()andfrom_env(), split fromProvider. Simplifies registration from a closure-based call to a single type parameter:The name follows Rust conventions (
FromStr,Default) rather than OOP "factory" terminology. The implementing structs are zero-sized types used purely as type-level descriptors, with an associated type that ensures compile-time verification that the constructed provider implementsProvider.OpenAiCompatibleProvider: reusable struct that implementsProviderfor any OpenAI-compatible API. Providers like xAI and Azure go from ~200 lines (fullProviderimpl with duplicated HTTP/streaming logic) to ~70 lines (just metadata + client setup). Applied initially to "xai" and "azure" to prove the concept; others can follow.This is vital for ACP-backed providers, as there could be over a dozen and differ only on aspects such as permission and mode mappings.
Type of Change
AI Assistance
Testing
Ran the normal tests.
Related Issues
Last major refactor needed to reduce the huge diff in ACP provider PR #6605