Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/openhuman-core/src/agent/agent_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use async_trait::async_trait;
use std::sync::{Arc, Mutex};
use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};
use tinytools::{Tool, ToolResult};
use tinytools_agent::dialect::{NativeDialect, ToolDialect, ToolOutcome, XmlDialect};
use tinytools_agent::dialect::{NativeDialect, ToolDialect, XmlDialect};

// ═══════════════════════════════════════════════════════════════════════════
// Test Helpers — Mock Provider, Mock Tool, Mock Memory
Expand Down
2 changes: 2 additions & 0 deletions crates/openhuman-core/src/agent/harness/graph_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async fn channel_turn_runs_through_the_graph() {
content: Vec::new(),
tool_calls: vec![ToolCall::new("p", "ping", serde_json::json!({}))],
usage: None,
origin: None,
},
usage: None,
finish_reason: Some("tool_calls".to_string()),
Expand Down Expand Up @@ -93,6 +94,7 @@ async fn channel_turn_pauses_on_ask_user_clarification() {
serde_json::json!({ "question": "Which three sources?" }),
)],
usage: None,
origin: None,
},
usage: None,
finish_reason: Some("tool_calls".to_string()),
Expand Down
5 changes: 5 additions & 0 deletions crates/openhuman-core/src/agent/message_convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ pub(crate) fn chat_message_to_message(msg: &ChatMessage) -> Message {
match msg.role.as_str() {
"system" => Message::System(SystemMessage {
content: vec![ContentBlock::Text(text)],
sections: Default::default(),
tools_added: Vec::new(),
tools_removed: Vec::new(),
}),
"assistant" => {
// Restore any `reasoning_content` stashed on the persisted message so a
Expand All @@ -189,6 +192,7 @@ pub(crate) fn chat_message_to_message(msg: &ChatMessage) -> Message {
content,
tool_calls,
usage: None,
origin: None,
})
} else {
let mut content = vec![ContentBlock::Text(text)];
Expand All @@ -198,6 +202,7 @@ pub(crate) fn chat_message_to_message(msg: &ChatMessage) -> Message {
content,
tool_calls: Vec::new(),
usage: None,
origin: None,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/openhuman-core/src/agent/message_convert_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fn legacy_provider_extension_reasoning_still_round_trips() {
],
tool_calls: vec![],
usage: None,
origin: None,
});

let back = message_to_chat_message(&msg);
Expand Down Expand Up @@ -303,6 +304,7 @@ fn conversation_preserves_tool_call_structure() {
invalid: None,
}],
usage: None,
origin: None,
}),
Message::Tool(ToolMessage {
tool_call_id: "c1".into(),
Expand All @@ -315,6 +317,7 @@ fn conversation_preserves_tool_call_structure() {
content: vec![ContentBlock::Text("all done".into())],
tool_calls: vec![],
usage: None,
origin: None,
}),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::collections::HashSet;
use std::sync::Arc;

use async_trait::async_trait;
use serde_json::json;

use super::*;
use crate::agent::harness::definition::AgentDefinitionRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
AgentPrepareContextTool::new()
.execute_with_live_parent_context(
arguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
CloseSubagentTool::new()
.execute_with_parent_context(arguments, parent.data.parent.clone(), Some(&context))
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
ContinueSubagentTool::new()
.execute_with_live_parent_context(
arguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
let graph_parent = parent
.child(
tinyagents_harness::context::RunConfig::new(format!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for D
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let tool_context = ToolExecutionContext::from_run_context(parent);
let tool_context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
let child = parent.data.child();
match &self.kind {
DelegationDispatchKind::Collapsed { targets } => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ async fn delegate_graph_dispatch_uses_its_durable_graph_argument_path() {
let result = dispatch
.execute(
&(),
tinyagents_harness::CallId::new("test-call"),
serde_json::json!({"task": "review this change"}),
tinytools::ToolCallOptions::default(),
&parent,
Expand Down Expand Up @@ -141,6 +142,7 @@ async fn config_delegate_dispatch_honours_the_parent_cancellation_token() {
.into_tinyagents(RunConfig::new("config-delegate-parent").with_thread("thread-parent"));
let execution = dispatch.execute(
&(),
tinyagents_harness::CallId::new("test-call"),
serde_json::json!({"agent": "configured", "prompt": "work"}),
tinytools::ToolCallOptions::default(),
&parent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
ListSubagentsTool::new()
.execute_with_parent_context(arguments, parent.data.parent.clone(), Some(&context))
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
let detached_data = parent.data.detached_child();
let detached_cancellation = detached_data.cancellation.clone();
let detached_parent = parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ async fn typed_dispatch_uses_the_parent_token_for_fanout_cancellation() {
dispatch
.execute(
&(),
tinyagents_harness::CallId::new("test-call"),
json!({
"tasks": [
{ "agent_id": "researcher", "prompt": "one" },
Expand Down Expand Up @@ -564,6 +565,7 @@ fn tool_response(name: &str, arguments: serde_json::Value) -> ModelResponse {
content: Vec::new(),
tool_calls: vec![ToolCall::new(format!("call-{name}"), name, arguments)],
usage: None,
origin: None,
},
usage: None,
finish_reason: Some("tool_calls".to_string()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
SpawnSubagentTool::new()
.execute_with_live_parent_context(
arguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
SpawnWorkerThreadTool::new()
.execute_with_live_parent_context(
arguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
SteerSubagentTool::new()
.execute_with_parent_context(arguments, parent.data.parent.clone(), Some(&context))
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for U
}
}

let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priority critical security confident

Add the call ID parameter before using it

_call_id is not declared in UseSkillDispatch::execute; its signature still only accepts state, arguments, options, and parent. This produces a compile error. Add the tinyagents_harness::CallId parameter to the implementation signature in the position required by ToolDispatch before using it here.

[RULE] undefined-variable ·

self.tool
.execute_with_context(arguments, options, Some(&context))
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
async fn execute(
&self,
_state: &(),
_call_id: tinyagents_harness::CallId,
arguments: serde_json::Value,
_options: ToolCallOptions,
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
let context = ToolExecutionContext::from_run_context(parent);
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
WaitSubagentTool::new()
.execute_with_parent_context(arguments, parent.data.parent.clone(), Some(&context))
.await
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::*;
use std::collections::BTreeMap;
use tinyagents_orchestration::workflow::{
validate_agents, validate_structure, DefinitionError, WorkflowDefinition, WorkflowPhase,
};
Expand Down
Loading
Loading