Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(inference): update turn model construction logic

Steven Enamakel6ff8c16b3738
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index 5d30c79cc8..b48b261e88 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -70,10 +70,10 @@ impl SessionHostBuilder {
self
}
- /// Sets the AI provider as a **crate-native** turn-model source (Phase 3 P3-B):
- /// `build`/`build_summarizer` construct crate `ChatModel`s from `(role, config)`
- /// via `create_turn_chat_model` (managed → `TinyHumansModel`, local/cloud →
- /// crate `OpenAiModel`) instead of wrapping `provider` in `native model adapters.
+ /// Sets the AI provider as a **crate-native** turn-model source:
+ /// `build`/`build_summarizer` use TinyAgents' `TurnModelSet` to construct
+ /// the primary, workload routes, and summarizer through the host model factory,
+ /// rather than wrapping `provider` in generic model adapters.
/// Used by the production session factory; the plain
/// [`provider`](Self::provider) setter (Provider path) stays for tests that
/// inject a mock they observe.
diff --git a/crates/openhuman-core/src/inference/README.md b/crates/openhuman-core/src/inference/README.md
index 0f0dd39d3b..163ad40f00 100644
--- a/crates/openhuman-core/src/inference/README.md
+++ b/crates/openhuman-core/src/inference/README.md
@@ -72,10 +72,9 @@ in `registry.rs`. The generic `provider_model.rs` adapter maps workload-role hin
concrete ids without carrying a hosted catalog. The TinyAgents workload router that consumes this
for agent turns is in [`agent/tinyagents/routes.rs`](../agent/tinyagents/routes.rs).
-There are two families of entry points. `create_chat_model*` in `factory/chat_model.rs` is for
-one-shot callers (summaries, sentiment, prompts). `create_turn_chat_model*` in
-`factory/turn_model.rs` is for agent turns and carries native-tool and route options. Both go
-through the same gates and constructors.
+One-shot callers use `create_chat_model*` in `factory/chat_model.rs`. Agent turns use the
+TinyAgents `TurnModelSet` through `TurnModelSource`, which builds the primary, workload routes,
+and summarizer under the same host gates.
### The managed backend model
@@ -216,8 +215,8 @@ picks the provider the same way a provider string does.
- `create_chat_model`, `create_chat_model_with_model_id`, `create_chat_model_from_string` (in
[`provider/factory/chat_model.rs`](./provider/factory/chat_model.rs)) build a model for one-shot work from a role or an explicit
provider string.
-- `create_turn_chat_model*` ([`provider/factory/turn_model.rs`](./provider/factory/turn_model.rs), crate-private) build the model for
- an agent turn.
+- `TurnModelSource` ([`turn_models.rs`](./turn_models.rs)) uses TinyAgents' `TurnModelSet` to
+ build models for an agent turn.
- `provider_for_role` ([`provider/factory/routing.rs`](./provider/factory/routing.rs)) returns the configured provider string for a
role. `provider_model.rs` handles generic `hint:*` workload markers and consults provider hooks for provider-owned aliases.
- `probe_inference_readiness` (`provider/factory/chat_model.rs`) checks that a role can actually
diff --git a/crates/openhuman-core/src/inference/provider/README.md b/crates/openhuman-core/src/inference/provider/README.md
index 9495d5bfc1..59fd7675d6 100644
--- a/crates/openhuman-core/src/inference/provider/README.md
+++ b/crates/openhuman-core/src/inference/provider/README.md
@@ -10,7 +10,7 @@ previously `providers/` (pre-consolidation single-crate layout); see
## Public surface
-- **Factory** ([`factory.rs`](./factory.rs) + `factory/`: `routing.rs`, `turn_model.rs`, `subprocess_providers.rs`, `access_gates.rs`, `chat_model.rs`, `cloud_slug.rs`, `credentials.rs`, `local_runtime.rs`, `managed_backend.rs`), `create_chat_model`,
+- **Factory** ([`factory.rs`](./factory.rs) + `factory/`: `routing.rs`, `subprocess_providers.rs`, `access_gates.rs`, `chat_model.rs`, `cloud_slug.rs`, `credentials.rs`, `local_runtime.rs`, `managed_backend.rs`), `create_chat_model`,
`create_chat_model_from_string[_with_model_id]`,
`create_chat_model_with_model_id`, `provider_for_role`,
`probe_inference_readiness`, `BYOK_INCOMPLETE_SENTINEL`. Parses the
diff --git a/crates/openhuman-core/src/inference/turn_models.rs b/crates/openhuman-core/src/inference/turn_models.rs
index eb7015621d..994ceca505 100644
--- a/crates/openhuman-core/src/inference/turn_models.rs
+++ b/crates/openhuman-core/src/inference/turn_models.rs
@@ -301,9 +301,8 @@ impl TurnModelSource {
Self::from_model(Arc::new(ProfileOverrideModel::new(model, profile)))
}
- /// Build a crate-native source: [`build`](Self::build) constructs the tiered
- /// [`TurnModels`] from `(role, config)` via [`build_turn_models_crate`] rather
- /// than wrapping a provider in `native model adapters. Used by the session-builder producer
+ /// Build a crate-native source: [`build`](Self::build) uses TinyAgents' `TurnModelSet`
+ /// to construct the turn's native models under the host policy adapter. Used by the session-builder producer
/// (`crate_native_provider`); the triage path uses
/// [`new_crate_native_from_string`](Self::new_crate_native_from_string).
pub(crate) fn new_crate_native(
@@ -323,8 +322,8 @@ impl TurnModelSource {
}
}
- /// Build a crate-native source whose **primary** model is built from an explicit
- /// `provider_string` (via [`factory::create_turn_chat_model_from_string`]) rather
+ /// Build a crate-native source whose **primary** model uses an explicit
+ /// `provider_string` rather
/// than the role's default resolution — the triage path's #1257 force-managed
/// override (`build_remote_provider` picks the effective string). Routes still
/// use the standard workload tiers.