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
feat(session_store): add run telemetry upsert to ledger sync
Steven Enamakel5b63c86fcd15
diff --git a/crates/openhuman-core/src/agent/session_store/ledger_sync.rs b/crates/openhuman-core/src/agent/session_store/ledger_sync.rsindex f696a6f22b..2f1be56fa7 100644--- a/crates/openhuman-core/src/agent/session_store/ledger_sync.rs+++ b/crates/openhuman-core/src/agent/session_store/ledger_sync.rs@@ -10,16 +10,19 @@use std::path::Path;use tinyagents_session::run_ledger::{- AgentRun, AgentRunUpsert, AgentTeam, AgentTeamMember, AgentTeamTask, AgentTeamTaskUpsert,- AgentTeamUpsert, AgentTeamMemberUpsert, ClaimOutcome, LedgerResult, RunEvent,- RunEventAppend, RunEventListRequest, RunEventListResponse, WorkflowRun, WorkflowRunUpsert,+ AgentRun, AgentRunUpsert, AgentTeam, AgentTeamMember, AgentTeamMemberUpsert, AgentTeamTask,+ AgentTeamTaskUpsert, AgentTeamUpsert, ClaimOutcome, LedgerResult, RunEvent, RunEventAppend,+ RunEventListRequest, RunEventListResponse, RunTelemetry, RunTelemetryUpsert, WorkflowRun,+ WorkflowRunUpsert,};use super::with_ledger;/// Inserts or merges an agent run.pub fn upsert_agent_run(workspace_dir: &Path, upsert: AgentRunUpsert) -> LedgerResult<AgentRun> {- with_ledger(workspace_dir, |l| async move { l.upsert_agent_run(upsert).await })+ with_ledger(workspace_dir, |l| async move {+ l.upsert_agent_run(upsert).await+ })}/// One agent run by id.@@ -33,18 +36,26 @@ pub fn upsert_workflow_run(workspace_dir: &Path,upsert: WorkflowRunUpsert,) -> LedgerResult<WorkflowRun> {- with_ledger(workspace_dir, |l| async move { l.upsert_workflow_run(upsert).await })+ with_ledger(workspace_dir, |l| async move {+ l.upsert_workflow_run(upsert).await+ })}/// One workflow run by id.pub fn get_workflow_run(workspace_dir: &Path, id: &str) -> LedgerResult<Option<WorkflowRun>> {let id = id.to_string();- with_ledger(workspace_dir, |l| async move { l.get_workflow_run(&id).await })+ with_ledger(+ workspace_dir,+ |l| async move { l.get_workflow_run(&id).await },+ )}/// Appends an event to a run's log.pub fn append_run_event(workspace_dir: &Path, event: RunEventAppend) -> LedgerResult<RunEvent> {- with_ledger(workspace_dir, |l| async move { l.append_run_event(event).await })+ with_ledger(+ workspace_dir,+ |l| async move { l.append_run_event(event).await },+ )}/// A run's events in sequence order.@@ -58,9 +69,21 @@ pub fn list_recent_run_events(})}+/// Merges a telemetry rollup into a run's.+pub fn upsert_run_telemetry(+ workspace_dir: &Path,+ upsert: RunTelemetryUpsert,+) -> LedgerResult<RunTelemetry> {+ with_ledger(workspace_dir, |l| async move {+ l.upsert_run_telemetry(upsert).await+ })+}+/// Inserts or updates a team.pub fn upsert_agent_team(workspace_dir: &Path, upsert: AgentTeamUpsert) -> LedgerResult<AgentTeam> {- with_ledger(workspace_dir, |l| async move { l.upsert_agent_team(upsert).await })+ with_ledger(workspace_dir, |l| async move {+ l.upsert_agent_team(upsert).await+ })}/// Inserts or updates a team member.@@ -86,7 +109,9 @@ pub fn upsert_agent_team_task(/// One team task by id.pub fn get_agent_team_task(workspace_dir: &Path, id: &str) -> LedgerResult<Option<AgentTeamTask>> {let id = id.to_string();- with_ledger(workspace_dir, |l| async move { l.get_agent_team_task(&id).await })+ with_ledger(workspace_dir, |l| async move {+ l.get_agent_team_task(&id).await+ })}/// One team member by id.@@ -95,7 +120,9 @@ pub fn get_agent_team_member(id: &str,) -> LedgerResult<Option<AgentTeamMember>> {let id = id.to_string();- with_ledger(workspace_dir, |l| async move { l.get_agent_team_member(&id).await })+ with_ledger(workspace_dir, |l| async move {+ l.get_agent_team_member(&id).await+ })}/// Atomically claims a task for a member.diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rsindex c600ee48b7..6847d9c956 100644--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs@@ -169,9 +169,9 @@ pub(super) fn ledger_upsert_agent_run(config: &crate::config::Config,upsert: tinyagents_session::run_ledger::AgentRunUpsert,) {- if let Err(err) = crate::agent::session_store::with_ledger(&config.workspace_dir, |ledger| async move {- ledger.upsert_agent_run(upsert).await- }) {+ if let Err(err) =+ crate::agent::session_store::ledger_sync::upsert_agent_run(&config.workspace_dir, upsert)+ {log::warn!("[run_ledger][web_channel] failed to upsert run: {err}");}}@@ -180,9 +180,9 @@ pub(super) fn ledger_append_event(config: &crate::config::Config,event: tinyagents_session::run_ledger::RunEventAppend,) {- if let Err(err) = crate::agent::session_store::with_ledger(&config.workspace_dir, |ledger| async move {- ledger.append_run_event(event).await- }) {+ if let Err(err) =+ crate::agent::session_store::ledger_sync::append_run_event(&config.workspace_dir, event)+ {log::warn!("[run_ledger][web_channel] failed to append event: {err}");}}@@ -191,9 +191,10 @@ pub(super) fn ledger_upsert_telemetry(config: &crate::config::Config,telemetry: tinyagents_session::run_ledger::RunTelemetryUpsert,) {- if let Err(err) = crate::agent::session_store::with_ledger(&config.workspace_dir, |ledger| async move {- ledger.upsert_run_telemetry(telemetry).await- }) {+ if let Err(err) = crate::agent::session_store::ledger_sync::upsert_run_telemetry(+ &config.workspace_dir,+ telemetry,+ ) {log::warn!("[run_ledger][web_channel] failed to upsert telemetry: {err}");}}@@ -202,10 +203,7 @@ pub(super) fn ledger_get_telemetry(config: &crate::config::Config,run_id: &str,) -> Option<tinyagents_session::run_ledger::RunTelemetry> {- let id = run_id.to_string();- match crate::agent::session_store::with_ledger(&config.workspace_dir, |ledger| async move {- ledger.get_agent_run(&id).await- }) {+ match crate::agent::session_store::ledger_sync::get_agent_run(&config.workspace_dir, run_id) {Ok(Some(run)) => {let telemetry = run.telemetry;log::debug!(