Skip to content

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

feat(agent): add run mode support to tinyagents

Steven Enamakel25784c99ea9d
diff --git a/crates/openhuman-core/src/agent/tinyagents/run_mode.rs b/crates/openhuman-core/src/agent/tinyagents/run_mode.rs
index 4577fdda0a..467c38c614 100644
--- a/crates/openhuman-core/src/agent/tinyagents/run_mode.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/run_mode.rs
@@ -57,8 +57,8 @@ pub fn get_mode(ctx: &DispatchCtx, thread_id: &str) -> RunMode {
/// `DomainEvent::ThreadRunModeChanged` so the web channel can bridge a
/// `run_mode_changed` socket event. A no-op publish-wise when the mode is
/// already what was requested — still safe to call unconditionally.
-pub fn set_mode(thread_id: &str, mode: RunMode) {
- let handle = handle_for_thread(thread_id);
+pub fn set_mode(ctx: &DispatchCtx, thread_id: &str, mode: RunMode) {
+ let handle = handle_for_thread(ctx, thread_id);
let changed = handle.get() != mode;
handle.set(mode);
if changed {
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rs
index a12d3c3070..b211c07ab5 100644
--- a/crates/openhuman-core/src/memory/tools.rs
+++ b/crates/openhuman-core/src/memory/tools.rs
@@ -29,6 +29,7 @@ use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult, ToolRunConte
use crate::config::Config;
use crate::core::bus::BUS;
use crate::core::events::DomainEvent;
+use crate::core::runtime::DispatchCtx;
use super::error::MemoryError;
use super::ops;
@@ -46,11 +47,14 @@ fn turn_citations(ctx: &DispatchCtx) -> Arc<TurnCitations> {
crate::core::runtime::slot_for::<TurnCitations>(ctx)
}
-fn record_turn_citations(thread_id: &str, citations: &[tinymemory_api::Citation]) {
+fn record_turn_citations(
+ ctx: &DispatchCtx,
+ thread_id: &str, citations: &[tinymemory_api::Citation],
+) {
if citations.is_empty() {
return;
}
- let citations_by_thread = turn_citations();
+ let citations_by_thread = turn_citations(ctx);
let mut all = citations_by_thread
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
@@ -68,11 +72,11 @@ fn record_turn_citations(thread_id: &str, citations: &[tinymemory_api::Citation]
/// Records `citations` for `thread_id`'s in-flight turn: what the turn's
/// memory pack cited (`lifecycle::hooks::pre_turn`), beside what `recall`
/// cites.
-pub fn record_pack_citations(thread_id: &str, citations: Vec<TurnCitation>) {
+pub fn record_pack_citations(ctx: &DispatchCtx, thread_id: &str, citations: Vec<TurnCitation>) {
if citations.is_empty() {
return;
}
- let citations_by_thread = turn_citations();
+ let citations_by_thread = turn_citations(ctx);
let mut all = citations_by_thread
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
@@ -90,8 +94,8 @@ pub fn record_pack_citations(thread_id: &str, citations: Vec<TurnCitation>) {
/// Drains the citations `recall` and the turn's pack produced for
/// `thread_id` since the last drain.
#[must_use]
-pub fn take_turn_citations(thread_id: &str) -> Vec<TurnCitation> {
- turn_citations()
+pub fn take_turn_citations(ctx: &DispatchCtx, thread_id: &str) -> Vec<TurnCitation> {
+ turn_citations(ctx)
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
.remove(thread_id)