Skip to content

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

refactor(tinyagents): use shared ephemeral instruction queue for nudges

Steven Enamakel28c09eaa76b5
diff --git a/crates/openhuman-core/src/agent/message_convert_tests.rs b/crates/openhuman-core/src/agent/message_convert_tests.rs
index eb491f4a6e..9de7bd8529 100644
--- a/crates/openhuman-core/src/agent/message_convert_tests.rs
+++ b/crates/openhuman-core/src/agent/message_convert_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use tinyinference_llm::message::{AssistantMessage, SystemMessage, ToolMessage};
-use tinyagents_session::transcript::{TranscriptPart, TranscriptToolCall};
+use tinyinference_llm::message::{AssistantMessage, ToolMessage};
+use tinyagents_session::transcript::{TranscriptToolCall};
#[test]
fn durable_upload_parts_survive_message_row_replay_without_inline_payloads() {
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
index bacfeb7a85..c4c2345e3a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -23,7 +23,7 @@ use super::loop_guards::{
is_repeat_call_exempt, RECOVERABLE_NO_PROGRESS_FAILURE_THRESHOLD,
RECOVERABLE_REPEAT_FAILURE_THRESHOLD,
};
-use super::nudge_injector::PendingNudgeInjector;
+use tinyagents_harness::middleware::{EphemeralInstructionQueue, EphemeralInstructionMiddleware};
pub(crate) use crate::inference::failure_copy::user_actionable_escalation;
use crate::inference::failure_copy::{
recoverable_identical_halt_summary, recoverable_no_progress_halt_summary,
@@ -92,7 +92,7 @@ pub(crate) struct RepeatedToolFailureMiddleware {
/// message joins the working transcript and is committed into durable
/// history, where it replays as a stale instruction on every later turn
/// (#6725).
- pending_nudges: Arc<Mutex<Vec<String>>>,
+ pending_nudges: EphemeralInstructionQueue,
/// `tool\u{1f}args` of the last finished command that exited non-zero,
/// kept so a *repeat* of it still counts as a failure while a different
/// command's non-zero exit counts as information (see `after_tool`).
@@ -126,7 +126,7 @@ impl RepeatedToolFailureMiddleware {
target_scopes: std::sync::Mutex::new(std::collections::HashMap::new()),
recoverable_sig_counts: std::sync::Mutex::new(std::collections::HashMap::new()),
recoverable_consecutive: AtomicU32::new(0),
- pending_nudges: Arc::new(Mutex::new(Vec::new())),
+ pending_nudges: EphemeralInstructionQueue::new(),
call_effects: std::sync::Mutex::new(std::collections::HashMap::new()),
tool_facts: None,
}
@@ -143,25 +143,14 @@ impl RepeatedToolFailureMiddleware {
/// The request-scoped half of this breaker. Register it **last**: its
/// `before_model` must run after the transcript snapshot (which a failed
/// turn persists) and after every reduction step.
- pub(crate) fn nudge_injector(&self) -> PendingNudgeInjector {
- PendingNudgeInjector {
- pending: self.pending_nudges.clone(),
- }
- }
-
- fn queue_nudge(&self, instruction: impl Into<String>) {
- if let Ok(mut pending) = self.pending_nudges.lock() {
- pending.push(instruction.into());
- }
+ pub(crate) fn nudge_injector(&self) -> EphemeralInstructionMiddleware {
+ self.pending_nudges.middleware()
}
- /// Drain the queued nudges (what the injector does before a request).
+ /// Inspect pending product corrections in tests.
#[cfg(test)]
pub(crate) fn take_pending_nudges(&self) -> Vec<String> {
- self.pending_nudges
- .lock()
- .map(|mut pending| std::mem::take(&mut *pending))
- .unwrap_or_default()
+ self.pending_nudges.drain_all()
}
/// Clear the consecutive recoverable-failure streak. Called on any success or
@@ -371,7 +360,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn after_tool(
&self,
- _ctx: &mut RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
+ ctx: &mut RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
_state: &(),
invocation: &ToolInvocationIdentity,
result: &mut TaToolResult,
@@ -514,7 +503,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
class,
"[tinyagents::mw] classified failure within budget — nudging recovery"
);
- self.queue_nudge(instruction);
+ self.pending_nudges.push(ctx, instruction);
}
// The classified budget owns this known blocker. In particular,
// a different query must not reset its count or trigger a
@@ -683,7 +672,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
// Request-scoped, not steering: no run policy can reject it (a
// `Redirect` nudge aborted interactive turns, #4473), and it is
// never committed into durable history (#6725).
- self.queue_nudge(instruction);
+ self.pending_nudges.push(ctx, instruction);
}
NoProgress::Halt(summary) => {
// #4092: if the blocker is user-actionable (a missing connection),
diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rs
index d4ea47ca42..78edfd30f8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs
@@ -77,7 +77,6 @@ mod verify_before_finish;
pub(crate) use crate::agent::message_convert::chat_message_to_message;
#[cfg(feature = "flows")]
pub(crate) use crate::agent::message_convert::ta_call_to_oh_call;
-use tinyagents_runtime::transcript::reasoning_from_content;
pub(crate) use compaction_carry::{last_user_message, CompactionCarry};
#[allow(unused_imports)] // Wired into the recall/retrieval facade in workstream 09.2.
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 375f308f18..286d2fab25 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 375f308f18349fb586cd619ebfd7dc2c0508dc4c
+Subproject commit 286d2fab25e88c338c07ed305d6264b530a1fda4