refactor: extract tensorzero-providers crate from tensorzero-core by AntoineToussaint · Pull Request #7304 · tensorzero/tensorzero · GitHub
Skip to content

refactor: extract tensorzero-providers crate from tensorzero-core#7304

Closed
AntoineToussaint wants to merge 4 commits intopr2-inference-traits-to-sharedfrom
create-tensorzero-providers-crate
Closed

refactor: extract tensorzero-providers crate from tensorzero-core#7304
AntoineToussaint wants to merge 4 commits intopr2-inference-traits-to-sharedfrom
create-tensorzero-providers-crate

Conversation

@AntoineToussaint
Copy link
Copy Markdown
Member

Summary

Stacks on #7303. Extracts crates/tensorzero-core/src/providers/ (~52K LOC, 25 files) into a standalone tensorzero-providers crate.

tensorzero-providers does NOT depend on tensorzero-core. Dependency direction is core → providers.

  • All provider files moved with git mv (history preserved)
  • All use crate:: imports rewritten to canonical shared-crate paths
  • From impls between Stored* and provider types relocated to providers (orphan rule)
  • From<&FunctionTool> for FunctionToolDef added in core for optimizer call sites
  • GCPVertexGeminiSupervisedRow refactored to own Vec<FunctionToolDef>
  • Optimizer row types updated via tool_serializer helpers
  • gcp_vertex_gemini/optimization.rs stays in core (depends on LazyRenderedSample)
  • dummy.rs and test_helpers.rs stay in core
  • tensorzero-core/src/providers/mod.rs is now a re-export shim

~49 files, mostly mechanical file moves + import rewrites.

Test plan

  • CI green

🤖 Generated with Claude Code

AntoineToussaint and others added 4 commits April 14, 2026 15:53
Move 25 provider files (~52K LOC) from `tensorzero-core/src/providers/`
into a new `tensorzero-providers` crate. The providers crate does NOT
depend on `tensorzero-core` — the dependency is `core → providers`.

Key changes:
- All `use crate::` imports in moved files rewritten to canonical shared
  crate paths (`tensorzero_inference_types::*`, `tensorzero_types::*`,
  `tensorzero_error::*`, `tensorzero_http::*`)
- `From` impls between `Stored*` types and provider types (OpenAIAPIType,
  ContentBlockType, grader types) moved from core to providers (orphan rule)
- `From<&FunctionTool> for FunctionToolDef` added in core for optimizer
  call sites that pass tools to provider constructors
- `GCPVertexGeminiSupervisedRow` refactored to own `Vec<FunctionToolDef>`
  internally, serialized as `GCPVertexGeminiSFTTool` via `serialize_with`
- Extension trait `LazyRenderedSampleGCPVertexGeminiExt` in core's
  optimization module for building supervised rows
- Optimizer row types (openai, fireworks, together) similarly updated to
  own `FunctionToolDef`s via `tool_serializer` helpers
- `serialize_or_log` and `warn_inference_parameter_not_supported` moved
  to `tensorzero_inference_types::utils`
- `tensorzero-core/src/providers/mod.rs` replaced with re-export shim
- `gcp_vertex_gemini/optimization.rs` stays in core (depends on core types)

Production code compiles cleanly (`cargo check --all-features`,
`cargo clippy --all-features -- -D warnings`).

Inline `#[cfg(test)] mod tests` blocks in provider files have ~95
remaining compile errors from core-only test infrastructure references
(`ToolCallConfig`, `jsonschema_util`, `tensorzero_unsafe_helpers`,
test_helpers tool constants). These need follow-up work to port the
test infrastructure to shared crates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix inline test code across all provider files to work with the new
crate structure:

- Replace WEATHER_TOOL/QUERY_TOOL with WEATHER_TOOL_DEF/QUERY_TOOL_DEF
- Replace .name()/.parameters() method calls with .name/.parameters field access
- Replace ToolCallConfig with ProviderToolCallConfig (tools field instead of
  static_tools_available/dynamic_tools_available)
- Replace crate::utils::testing::capture_logs with crate::test_helpers::capture_logs
- Fix ObjectStoragePointer import path (tensorzero_types:: not inference_types::)
- Fix ferris.png include_bytes! path for new crate location
- Fix JSONSchema -> serde_json::Value for test usage
- Add tensorzero-unsafe-helpers as dev-dep for env var test helpers
- Add missing imports in core's openai_rft test module
- Make GCPVertexGeminiSupervisedRow fields pub for test assertions
- Fix optimizer row .tools -> .tool_defs field access in tests
- Wire e2e_tests feature through tensorzero-stored-config to fix
  StorageKind::S3Compatible prefix field issue

cargo check --all-targets --all-features and
cargo clippy --all-targets --all-features -- -D warnings both pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add tensorzero-providers gcp_vertex_gemini path to pre-commit
  detect-private-key exclusion (test fixture with fake RSA key)
- Gate PartialEq derives on provider request structs behind
  `feature = "e2e_tests"` instead of `test` (cfg(test) doesn't
  propagate to dependency crates in cargo hack --each-feature)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
cargo hack --each-feature runs clippy with --no-default-features,
which means e2e_tests is disabled and PartialEq derives gated behind
it (on ErrorDetails, RequestMessage, etc.) are missing. Provider test
code uses assert_eq! on these types.

Fix by adding e2e_tests-enabled dev-dependencies for tensorzero-error
and tensorzero-inference-types, so test targets always have PartialEq
available regardless of feature flags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant