refactor: decouple providers from core-only types#7162
Merged
AntoineToussaint merged 8 commits intomainfrom Apr 10, 2026
Merged
refactor: decouple providers from core-only types#7162AntoineToussaint merged 8 commits intomainfrom
AntoineToussaint merged 8 commits intomainfrom
Conversation
1fe1942 to
bce1ad3
Compare
…o-types Rate limiting config types (RateLimitResource, RateLimitingConfigScopes, TagRateLimitingConfigScope, etc.) are domain types that belong in tensorzero-types, not tensorzero-error. They were in the error crate only because ErrorDetails variants reference them. All 3 call sites updated to import from tensorzero_types directly. No re-export shim needed. This unblocks implementing From<StoredRateLimitingConfig> in the stored-config crate (which depends on tensorzero-types but not tensorzero-error). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract shared types and HTTP client into separate crates, and decouple provider implementations from core-internal types (ModelProvider, OtlpConfig). This is a prerequisite for extracting providers into their own crate. Key changes: - Create tensorzero-http crate with the shared HTTP client - Move credential types and ModelProviderRequestInfo to tensorzero-inference-types - Introduce ProviderInferenceRequest (like ModelProviderRequest without otlp_config) - Update InferenceProvider trait to use &ModelProviderRequestInfo instead of &ModelProvider - Update all ~20 provider implementations to use the new types - Core converts at the dispatch boundary before calling into providers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2adba13 to
782a122
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nversions Add tensorzero-stored-config as a dependency of tensorzero-inference-types so that From<StoredExtraBodyConfig> for ExtraBodyConfig (and vice versa) can be implemented directly on the types. This eliminates the ugly free functions (extra_body_config_from_stored, extra_body_config_to_stored, etc.) that were needed as an orphan rule workaround. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
c768b5b to
b265de1
Compare
…nversions Add tensorzero-stored-config as a dependency of tensorzero-inference-types so that From impls can be implemented directly on the types. This eliminates all the ugly free functions that were needed as orphan rule workarounds: - extra_body_config_from_stored / extra_body_config_to_stored - extra_headers_config_from_stored / extra_headers_config_to_stored - credential_location_from_stored / credential_location_to_stored - credential_location_with_fallback_from_stored / credential_location_with_fallback_to_stored - credential_location_or_hardcoded_from_stored / credential_location_or_hardcoded_to_stored - endpoint_location_from_stored / endpoint_location_to_stored - stored_api_key_defaults_from_credential_location - stored_gcp_credential_defaults_from_credential_location All call sites reverted to idiomatic .map(Type::from) / .map(Into::into). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b265de1 to
20af373
Compare
The danger_accept_invalid_certs call was guarded by cfg!(feature = "e2e_tests") which is a runtime check — the code still compiles into production builds and CodeQL flags it. Switch to #[cfg(feature = "e2e_tests")] so the code is completely excluded from non-test builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d3f21b7 to
0e4f818
Compare
Contributor
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e4f81831c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
shuyangli
previously approved these changes
Apr 9, 2026
Contributor
shuyangli
left a comment
There was a problem hiding this comment.
I took a cursory look and I think the main thing is a bunch of types moving into tensorzero-inference-types and the http client moving into tensorzero-http. looks fine.
…tra-body-headers # Conflicts: # crates/tensorzero-core/src/http.rs
010e3b1
This was a working copy from exploration, not ready for commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
virajmehta
approved these changes
Apr 10, 2026
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
tensorzero-httpcrate: Extract the shared HTTP client (TensorzeroHttpClient, event source, response wrappers) fromtensorzero-coreinto its own crate, enabling reuse across crates without depending on coretensorzero-inference-types: ExtractCredentialLocation,ModelProviderRequestInfo, and related types intocredentials.rsin the shared inference-types crateProviderInferenceRequest: New provider-facing request type that mirrorsModelProviderRequestbut omitsotlp_config(which no provider ever used)InferenceProvidertrait fromModelProvider: Change trait signatures to accept&ModelProviderRequestInfoinstead of&ModelProvider, andProviderInferenceRequestinstead ofModelProviderRequestotlp_config: _destructuring patternsFromimpls: Addtensorzero-stored-configas a dependency oftensorzero-inference-typesto enable properFromimpls for all stored config conversions (ExtraBody, ExtraHeaders, CredentialLocation, EndpointLocation, etc.), eliminating 14 ugly free functionsdanger_accept_invalid_certsCodeQL alert: Switch from runtimecfg!()to compile-time#[cfg(feature = "e2e_tests")]so the code is completely excluded from production buildsThis is a prerequisite for extracting providers into their own
tensorzero-providerscrate. Providers now only depend on types from shared crates (tensorzero-inference-types,tensorzero-types,tensorzero-error,tensorzero-http), with no remaining imports fromcrate::model::ModelProviderorcrate::cache::ModelProviderRequest.CodeQL note
CodeQL flags a
danger_accept_invalid_certsalert, but this is a stale/false positive. The code is now behind#[cfg(feature = "e2e_tests")]— it is completely excluded from production builds at compile time. The alert needs to be manually dismissed in the security tab.Test plan
cargo check --all-targets --all-featurescargo clippy --all-targets --all-features -- -D warningscargo fmt🤖 Generated with Claude Code