Skip to content

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

feat(tool-policy): add generated_context helper to ToolPolicyMiddleware

Steven Enamakel595e288dac63
diff --git a/src/openhuman/agent/tinyagents/middleware_part_03.rs b/src/openhuman/agent/tinyagents/middleware_part_03.rs
index e7e76df8cb..9b55e03c2a 100644
--- a/src/openhuman/agent/tinyagents/middleware_part_03.rs
+++ b/src/openhuman/agent/tinyagents/middleware_part_03.rs
@@ -110,6 +110,22 @@ impl ToolMiddleware<()> for ToolPolicyMiddleware {
}
}
+impl ToolPolicyMiddleware {
+ fn generated_context(
+ &self,
+ name: &str,
+ args: &serde_json::Value,
+ ) -> Option<crate::openhuman::agent::tool_policy::GeneratedToolRuntimeContext> {
+ self.tool_sets
+ .iter()
+ .flat_map(|set| set.iter())
+ .find(|t| t.name() == name)
+ .and_then(|t| {
+ crate::openhuman::tools::traits::generated_runtime_context(t.as_ref(), args)
+ })
+ }
+}
+
/// `after_tool`: capture each tool call's execution outcome (success + content)
/// into a shared sink before the harness folds the result into a `Message::tool`
/// that drops the `error` flag (issue #4249). Without this, a post-turn