Skip to content

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

refactor(inference): split host runtime ops into per-operation modules

Steven Enamakel338121902b0d
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rs
index 3f3f425c0a..3b90031282 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs
@@ -14,8 +14,8 @@ mod runtime_ops;
mod turn_guards;
pub use agent_chat::{
- agent_chat, agent_chat_for, agent_chat_reply_for, agent_chat_simple, AgentChatReply,
- AgentChatTarget,
+ agent_chat, agent_chat_for, agent_chat_reply_for, agent_chat_simple, AgentChatEnv,
+ AgentChatReply, AgentChatTarget,
};
pub use complete_once::{complete_once, CompletionEndpoint};
pub use runtime_ops::{
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
index 7d0e8b1854..0bfb084da7 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
@@ -54,9 +54,13 @@ impl std::fmt::Debug for CompletionEndpoint {
/// `request.model` is required and sent verbatim. Errors are rendered strings,
/// the same contract as the other `ops` functions, so the facade maps them in
/// one place.
+///
+/// `budget` is the caller's explicit spend ledger; every physical call the
+/// request makes is charged against it. `None` runs unmetered.
pub async fn complete_once(
endpoint: &CompletionEndpoint,
request: ModelRequest,
+ budget: Option<&crate::agent::tinyagents::budget::ModelBudget>,
) -> Result<ModelResponse, String> {
if !request.tools.is_empty() {
return Err(
@@ -96,7 +100,7 @@ pub async fn complete_once(
);
let model: std::sync::Arc<dyn ChatModel<()>> = std::sync::Arc::new(model);
- let model = match crate::agent::tinyagents::budget::current() {
+ let model = match budget {
Some(budget) => budget.wrap(model),
None => model,
};
diff --git a/crates/openhuman-core/src/inference/host_runtime/schemas.rs b/crates/openhuman-core/src/inference/host_runtime/schemas.rs
index f4616504aa..7ba08dc89c 100644
--- a/crates/openhuman-core/src/inference/host_runtime/schemas.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/schemas.rs
@@ -242,6 +242,7 @@ fn handle_agent_chat(params: Map<String, Value>) -> ControllerFuture {
p.cwd,
crate::config::schema::EphemeralRoute::from_params(p.inference_url, p.api_key)
.map(|route| route.with_headers(p.inference_headers)),
+ crate::inference::host_runtime::ops::AgentChatEnv::default(),
)
.await?
.into_rpc_json()