Skip to content

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

refactor(web_chat): route ledger writes through the shared ledger handle

Steven Enamakel21c06b05db3c
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
index 3d152b0702..238712fcd6 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
@@ -396,7 +396,7 @@ fn the_no_tools_sentinel_can_never_name_a_real_tool() {
#[test]
fn is_empty_tool_scope_distinguishes_the_three_states() {
- use crate::agent_registry::host_definition::{NO_TOOLS_SENTINEL, is_empty_tool_scope};
+ use crate::agent_registry::host_definition::{is_empty_tool_scope, NO_TOOLS_SENTINEL};
use std::collections::HashSet;
// Unset — the historical "everything" sentinel.
@@ -435,7 +435,7 @@ async fn a_summarized_agent_sees_the_recovery_tool_with_compaction_off() {
"orchestrator",
)
.expect("orchestrator is a shipped agent definition");
- let visible = agent.visible_tool_names;
+ let visible = &agent.visible_tool_names;
assert!(
visible.is_empty() || visible.contains(tinyjuice_bus::tools::RETRIEVE),
"the orchestrator's summaries point at a tool it must be able to call"
@@ -468,19 +468,15 @@ fn the_repl_tools_join_a_belt_only_while_handle_mode_is_active() {
let mut inactive = belt();
super::ensure_repl_tools_visible(&mut inactive, false);
- assert!(
- tinyjuice_bus::tools::REPL_TOOLS
- .iter()
- .all(|n| !inactive.contains(*n))
- );
+ assert!(tinyjuice_bus::tools::REPL_TOOLS
+ .iter()
+ .all(|n| !inactive.contains(*n)));
let mut active = belt();
super::ensure_repl_tools_visible(&mut active, true);
- assert!(
- tinyjuice_bus::tools::REPL_TOOLS
- .iter()
- .all(|n| active.contains(*n))
- );
+ assert!(tinyjuice_bus::tools::REPL_TOOLS
+ .iter()
+ .all(|n| active.contains(*n)));
// "No filter" and "deliberately no tools" both stay as they were.
let mut unfiltered = std::collections::HashSet::new();
@@ -516,7 +512,7 @@ async fn a_curated_orchestrator_sees_and_holds_every_juice_tool_in_handle_mode()
"orchestrator",
)
.expect("orchestrator is a shipped agent definition");
- let visible = agent.visible_tool_names;
+ let visible = &agent.visible_tool_names;
assert!(
!visible.is_empty(),
"the orchestrator's belt is curated; an empty set would make this test vacuous"
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs
index 759cbc2fc2..ca71e1a988 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs
@@ -4,8 +4,8 @@
//! registry.
use super::*;
-use crate::agent_registry::host_definition::AgentDefinitionRegistry;
use crate::agent::session_host::types::OpenHumanSessionHost;
+use crate::agent_registry::host_definition::AgentDefinitionRegistry;
use tinyagents_definition::{PromptSource, SandboxMode, ToolScope};
fn explicit_definition(id: &str) -> crate::agent_registry::host_definition::AgentDefinition {
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
index 2503c55d2d..36d9adc52e 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
@@ -6,8 +6,8 @@
//! real tool: it is on the belt, and it is advertised.
use super::*;
-use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
+use std::sync::Arc;
/// A tool that does nothing but be present under a name nothing else uses.
#[derive(Debug)]
@@ -461,11 +461,9 @@ fn permanent_metadata_without_a_source_is_rejected_before_build() {
)
.err()
.expect("inconsistent permanent metadata must be rejected");
- assert!(
- error
- .to_string()
- .contains("permanent tool must have exactly one source: missing_source")
- );
+ assert!(error
+ .to_string()
+ .contains("permanent tool must have exactly one source: missing_source"));
}
/// The factory is told the context the session is built under, not the
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs
index 541abad3c5..edd3cd3d0c 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs
@@ -7,8 +7,8 @@
//! builder caller had no equivalent, and fell back to the process registry.
//! These tests pin the route that closes that gap.
-use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};
use crate::agent::tinyagents::host::OpenHumanDefinitionRegistry;
+use crate::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};
use std::sync::Arc;
use tinyagents_definition::DefinitionRegistry;
use tinyagents_definition::ToolScope;
@@ -214,11 +214,9 @@ async fn a_padded_name_is_stored_as_the_definitions_own_id() {
.expect("a name that differs only by padding is not a contradiction");
assert_eq!(agent.agent_definition_name(), SEAT);
- assert!(
- catalogue(&agent)
- .resolve(agent.agent_definition_name())
- .await
- .expect("resolution never errors")
- .is_some()
- );
+ assert!(catalogue(&agent)
+ .resolve(agent.agent_definition_name())
+ .await
+ .expect("resolution never errors")
+ .is_some());
}
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index e220399b45..3f2ce6bcb6 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -172,13 +172,15 @@ mod wire_caps;
use wire_caps::MAX_WIRE_SUBAGENT_OUTPUT;
use wire_caps::{cap_wire_args, cap_wire_output};
-use crate::agent::session_store::ledger_sync;
+use crate::agent::session_store::with_ledger;
pub(super) fn ledger_upsert_agent_run(
config: &crate::config::Config,
upsert: tinyagents_session::run_ledger::AgentRunUpsert,
) {
- if let Err(err) = ledger_sync::upsert_agent_run(&config.workspace_dir, upsert) {
+ if let Err(err) = with_ledger(&config.workspace_dir, |ledger| async move {
+ ledger.upsert_agent_run(upsert).await
+ }) {
log::warn!("[run_ledger][web_channel] failed to upsert run: {err}");
}
}
@@ -187,7 +189,9 @@ pub(super) fn ledger_append_event(
config: &crate::config::Config,
event: tinyagents_session::run_ledger::RunEventAppend,
) {
- if let Err(err) = ledger_sync::append_run_event(&config.workspace_dir, event) {
+ if let Err(err) = with_ledger(&config.workspace_dir, |ledger| async move {
+ ledger.append_run_event(event).await
+ }) {
log::warn!("[run_ledger][web_channel] failed to append event: {err}");
}
}
@@ -196,7 +200,9 @@ pub(super) fn ledger_upsert_telemetry(
config: &crate::config::Config,
telemetry: tinyagents_session::run_ledger::RunTelemetryUpsert,
) {
- if let Err(err) = ledger_sync::upsert_run_telemetry(&config.workspace_dir, telemetry) {
+ if let Err(err) = with_ledger(&config.workspace_dir, |ledger| async move {
+ ledger.upsert_run_telemetry(telemetry).await
+ }) {
log::warn!("[run_ledger][web_channel] failed to upsert telemetry: {err}");
}
}
@@ -205,7 +211,10 @@ pub(super) fn ledger_get_telemetry(
config: &crate::config::Config,
run_id: &str,
) -> Option<tinyagents_session::run_ledger::RunTelemetry> {
- match ledger_sync::get_agent_run(&config.workspace_dir, run_id) {
+ let run_id_owned = run_id.to_string();
+ match with_ledger(&config.workspace_dir, |ledger| async move {
+ ledger.get_agent_run(&run_id_owned).await
+ }) {
Ok(Some(run)) => {
let telemetry = run.telemetry;
log::debug!(
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 4e5ec22f2c..f007274227 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 4e5ec22f2c4e3dbb88a2dd35efd8720932d2cfa4
+Subproject commit f007274227f227f597a69a1aa84568e06251f7f0