The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/web_chat/run_task.rs
Steven Enamakelb64313048c2d
diff --git a/crates/openhuman-core/src/web_chat/run_task.rs b/crates/openhuman-core/src/web_chat/run_task.rsindex 27b001b216..133d765263 100644--- a/crates/openhuman-core/src/web_chat/run_task.rs+++ b/crates/openhuman-core/src/web_chat/run_task.rs@@ -10,13 +10,11 @@ use tinyagents_harness::run_queue::RunQueue;use crate::config::rpc as config_rpc;use crate::threads::turn_state::TurnStateStore;-use super::ops::{key_for, BudgetCorrelation, THREAD_SESSIONS};+use super::ops::BudgetCorrelation;use super::progress_bridge::spawn_progress_bridge;use super::session::{- build_session_agent, build_session_fingerprint, normalize_model_override, pick_target_agent_id,- provider_role_for_model_override,+ checkin_session_agent, checkout_session_agent, normalize_model_override, CheckedOutSession,};-use super::types::SessionEntry;use super::types::{ChatRequestMetadata, WebChatTaskResult};use super::web_errors::{classify_inference_error, inference_budget_exceeded_user_message,@@ -97,134 +95,23 @@ pub(crate) async fn run_chat_task(}let config = config_rpc::load_config_with_timeout().await?;- let map_key = key_for(thread_id);let model_override = normalize_model_override(model_override);- let target_agent_id = pick_target_agent_id(&config);- let provider_role = provider_role_for_model_override(model_override.as_deref());- let current_fp = build_session_fingerprint(+ // The cached session (or a cold-boot resumed one) is the thread's single+ // live history; every turn on the thread checks it out through this path.+ let CheckedOutSession {+ mut agent,+ fingerprint: current_fp,+ } = checkout_session_agent(&config,- model_override.clone(),+ client_id,+ thread_id,+ model_override,temperature,- target_agent_id.clone(),- provider_role,- );-- // A forked (parallel) turn never reuses or evicts the shared cached agent —- // it always builds fresh from the history snapshot below.- let prior = if fork {- None- } else {- let mut sessions = THREAD_SESSIONS.lock().await;- sessions.remove(&map_key)- };-- let (mut agent, was_built_fresh) = match prior {- Some(entry) if entry.fingerprint == current_fp => {- log::info!(- "[web-channel] reusing cached session agent id={} for client={} thread={}",- target_agent_id,- client_id,- thread_id- );- (entry.agent, false)- }- Some(prior_entry) => {- log::info!(- "[web-channel] cache miss — rebuilding session agent \- (was id={}, now id={}; prior_provider_binding={}, now={}) \- for client={} thread={}",- prior_entry.fingerprint.target_agent_id,- target_agent_id,- prior_entry.fingerprint.provider_binding,- current_fp.provider_binding,- client_id,- thread_id- );- (- build_session_agent(- &config,- client_id,- thread_id,- &target_agent_id,- model_override.clone(),- temperature,- locale.as_deref(),- )?,- true,- )- }- None => (- build_session_agent(- &config,- client_id,- thread_id,- &target_agent_id,- model_override.clone(),- temperature,- locale.as_deref(),- )?,- true,- ),- };-- // Cold-boot resume. Prefer the full-fidelity `session_raw/{stem}.jsonl`- // transcript (tool calls, tool-role results, reasoning) routed by thread- // id — the model must not "forget" its tool interactions across an app- // restart. Only fall back to the lossy conversation-log prose pairs when- // no root transcript exists for the thread or it fails to load; the two- // sources overlap (user prompts + final assistant text), so we take one- // or the other, never both, to avoid duplicated context.- if was_built_fresh {- if agent.seed_resume_from_thread_transcript(thread_id) {- log::info!(- "[web-channel] cold-boot resumed thread={} from full-fidelity session transcript",- thread_id- );- } else {- log::debug!(- "[web-channel] no usable session transcript for thread={} — seeding resume \- from conversation-log prose",- thread_id- );- // Blocking pool: the store takes a process-global mutex and reads- // the thread's whole JSONL under it, so doing this inline parked an- // async worker on the chat hot path (#5156).- match crate::memory::conversations::blocking::get_messages(- config.workspace_dir.clone(),- thread_id.to_string(),- )- .await- {- Ok(prior_messages) if !prior_messages.is_empty() => {- let pairs: Vec<(String, String)> = prior_messages- .into_iter()- .map(|m| (m.sender, m.content))- .collect();- if let Err(err) = agent.seed_resume_from_messages(pairs, message) {- log::warn!(- "[web-channel] failed to seed agent resume from conversation log \- thread={} err={}",- thread_id,- err- );- }- }- Ok(_) => {- log::debug!(- "[web-channel] no prior messages to seed for thread={} — first turn",- thread_id- );- }- Err(err) => {- log::warn!(- "[web-channel] failed to read conversation log for resume thread={} err={}",- thread_id,- err- );- }- }- }- }+ locale.as_deref(),+ fork,+ message,+ )+ .await?;// Bounded to 256 (was 64): a heavy-event subagent (e.g. `workflow_builder`,// 50+ progress events per run) can overflow a smaller buffer, and the@@ -397,14 +284,7 @@ pub(crate) async fn run_chat_task(request_id);} else {- let mut sessions = THREAD_SESSIONS.lock().await;- sessions.insert(- map_key,- SessionEntry {- agent,- fingerprint: current_fp,- },- );+ checkin_session_agent(thread_id, agent, current_fp).await;}}