Skip to content

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

feat(tinyagents): add tool output and turn context middleware

Steven Enamakeld50c725a7a4b
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
index a6181150a9..1974cf7f12 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs
@@ -16,12 +16,13 @@ use tinyinference_llm::tool::ToolCall as TaToolCall;
use tinytools::{ToolPolicy as TaToolPolicy, ToolResult as TaToolResult};
use crate::agent::harness::tool_result_artifacts::{
- artifact_read_target, page_artifact_read, TINYAGENTS_TOOL_RESULT_ARTIFACT_STORE,
+ artifact_read_target, page_artifact_read, HostArtifactStore,
+ TINYAGENTS_TOOL_RESULT_ARTIFACT_STORE,
};
use crate::agent::tinyagents::payload_summarizer::DynPayloadSummarizer;
use crate::inference::tokenjuice::generate::GenerateTicket;
use tinyagents_harness::artifacts::tool_results::{
- ArtifactRead, ToolResultArtifactOutcome, ToolResultArtifactStore,
+ ArtifactRead, ToolResultArtifactOutcome,
};
use tinyagents_harness::middleware::library::{
plan_output_stages, run_output_ladder, CompactedOutput, OutputCapPolicy, OutputLadderInput,
@@ -183,7 +184,7 @@ pub(crate) struct ToolOutputMiddleware {
/// The model behind TinyJuice's summary stage. `None` means this agent's
/// results are never summarized.
pub(crate) payload_summarizer: Option<Arc<DynPayloadSummarizer>>,
- pub(crate) artifact_store: Option<ToolResultArtifactStore>,
+ pub(crate) artifact_store: Option<HostArtifactStore>,
pub(crate) tokenjuice_compaction_enabled: bool,
pub(crate) tokenjuice_compression: AgentTokenjuiceCompression,
/// Config resolved when the turn was constructed; avoids a disk reload from
@@ -446,7 +447,11 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Too
}
}
if let Some(read) =
- artifact_read_target(self.artifact_store.as_ref(), &call.name, &call.arguments)
+ artifact_read_target(
+ self.artifact_store.as_deref(),
+ &call.name,
+ &call.arguments,
+ )
{
tracing::debug!(
tool = %call.name,
@@ -455,6 +460,10 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Too
offset = read.offset,
"[tinyagents::mw] call reads a persisted tool-result artifact"
);
+ // `file_read` opens the filesystem; the body lives on the blob store.
+ if let Some(store) = self.artifact_store.as_ref() {
+ store.resolve_read(&mut call.arguments, &read).await;
+ }
if let Ok(mut reads) = self.artifact_reads.lock() {
reads.insert(call.id.clone(), read);
}
@@ -600,7 +609,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Too
content,
focus,
wants_compaction: wants_tinyjuice && !raw_fetch && !verbatim_file_read,
- store: self.artifact_store.as_ref(),
+ store: self.artifact_store.as_deref(),
summary_label: "openhuman",
},
)
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
index 09fdba2c4b..afe12796b4 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
@@ -17,7 +17,7 @@ use tinyinference_llm::model::{ModelRequest, ModelResponse, ResolvedModelRoute};
use tinytools::{ToolPolicy as TaToolPolicy, ToolResult as TaToolResult};
use crate::agent::tinyagents::payload_summarizer::DynPayloadSummarizer;
-use tinyagents_harness::artifacts::tool_results::ToolResultArtifactStore;
+use crate::agent::harness::tool_result_artifacts::HostArtifactStore;
use tinyagents_harness::turn_outcome::ToolCallOutcome;
use tinyjuice_bus::types::AgentTokenjuiceCompression;
@@ -39,7 +39,7 @@ pub(crate) struct TurnContextMiddleware {
/// The model behind TinyJuice's tool-output summary. `None` disables it.
pub(crate) payload_summarizer: Option<Arc<DynPayloadSummarizer>>,
/// Optional action-workspace artifact sink for oversized tool results.
- pub(crate) artifact_store: Option<ToolResultArtifactStore>,
+ pub(crate) artifact_store: Option<HostArtifactStore>,
/// Whether TokenJuice content-aware compaction runs before output caps.
pub(crate) tokenjuice_compaction_enabled: bool,
/// Agent-level TokenJuice profile for tool-result compaction.