Skip to content

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

Merge remote-tracking branch 'upstream/main' into green-all-tests-followup-next

Steven Enamakel3493d1092c45
diff --cc crates/openhuman-core/src/agent/tools/todo.rs
index 7dab8c4e03,4d7f2d94a5..5f62b799fc
--- a/crates/openhuman-core/src/agent/tools/todo.rs
+++ b/crates/openhuman-core/src/agent/tools/todo.rs
@@@ -1,12 -1,12 +1,10 @@@
//! `todo` — the session's todo list, the way Claude Code and Codex have it.
//!
- //! One call writes the whole list: `{"todos": [{"content", "status"}]}`.
- //! There is no per-card CRUD, no approval gate, no evidence, no plan; the
- //! list is a progress checklist the model rewrites as it works. It is scoped
- //! to the agent session the turn runs in (in memory, for the life of the
- //! process) via [`crate::agent::todos::ops`]; without a session (a bare
- //! `execute` in a test) it falls back to a scratch list. Calling with no
- //! `todos` returns the current list.
+ //! The tool itself is TinyAgents' `todos::TodoTool` (schema, argument
+ //! validation, the whole-list write, markdown). This file is only the host
-//! adapter: it decides **which** list a call is about — the agent session the
-//! turn runs in, in memory for the life of the process — and registers the
-//! harness dispatch. Nothing here may turn a bad argument into an `Err`: a
-//! dispatch `Err` is fatal to the run, and a turn died that way when a model
-//! sent the retired `{"cards": …}` shape to a previous host-side copy.
++//! adapter: it selects the session-scoped list for a turn and registers the
++//! harness dispatch. Bad arguments must become a tool error, never a fatal
++//! harness error.
use crate::agent::harness::fork_context::ParentExecutionContext;
use crate::agent::todos::ops::{self, TodoScope};
@@@ -24,28 -24,35 +22,31 @@@ pub struct TodoTool
pub(crate) struct TodoToolDispatch {
tool: Arc<dyn Tool>,
}
++
impl TodoToolDispatch {
pub(crate) fn new(tool: Arc<dyn Tool>) -> Self {
Self { tool }
}
}
++
#[async_trait]
impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for TodoToolDispatch {
fn tool(&self) -> Arc<dyn Tool> {
self.tool.clone()
}
++
async fn execute(
&self,
_state: &(),
-- _call_id: tinyagents_harness::CallId,
++ 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, _call_id.clone());
- match TodoTool::new()
++ let context = ToolExecutionContext::from_run_context(parent, call_id);
+ TodoTool::new()
.execute_with_parent_context(arguments, parent.data.parent.clone(), Some(&context))
.await
- {
- Ok(result) => Ok(result),
- Err(error) => {
- tracing::warn!(%error, "[tool][todo] rejected call");
- Ok(ToolResult::error(format!("todo failed: {error}")))
- }
- }
}
}
@@@ -61,35 -70,17 +64,13 @@@ impl Default for TodoTool
}
}
- /// One item as the model writes it. `status` accepts the Claude-style
- /// `pending` / `in_progress` / `completed` plus the older `todo` / `done`
- /// spellings the store already parses.
- #[derive(Deserialize)]
- struct TodoItem {
- content: String,
- #[serde(default)]
- status: Option<String>,
- }
-/// The scope's store key, handed to the crate tool the only way it accepts
-/// one: as the `thread_id` of a tool context. The crate keys a list by the
-/// caller's thread; OpenHuman keys it by the agent session the turn runs in
-/// (see [`current_scope`]), so the host substitutes its own key here rather
-/// than letting the crate read a thread id that would address the wrong list.
++/// Supplies the selected session key to TinyAgents' tool implementation.
+ struct ScopedKey<'a>(&'a str);
- fn cards_from_todos(raw: &serde_json::Value) -> anyhow::Result<Vec<TaskBoardCard>> {
- let items: Vec<TodoItem> = serde_json::from_value(raw.clone())
- .map_err(|e| anyhow::anyhow!("invalid `todos`: {e}"))?;
- let mut cards = Vec::with_capacity(items.len());
- for item in items {
- let content = item.content.trim();
- if content.is_empty() {
- anyhow::bail!("every todo needs non-empty `content`");
- }
- let mut card = TaskBoardCard::new(content);
- card.status = match item.status.as_deref() {
- None => TaskCardStatus::Todo,
- Some(raw) => ops::parse_status(raw).map_err(|_| {
- anyhow::anyhow!("status must be pending, in_progress, or completed")
- })?,
- };
- cards.push(card);
+ impl ToolRunContext for ScopedKey<'_> {
+ fn thread_id(&self) -> Option<&str> {
+ Some(self.0)
}
- Ok(cards)
}
#[async_trait]
@@@ -143,8 -112,8 +102,7 @@@ impl Tool for TodoTool
_options: ToolCallOptions,
tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
-- self.execute_with_parent_context(args, None, tool_context)
-- .await
++ self.execute_with_parent_context(args, None, tool_context).await
}
}
@@@ -212,12 -133,12 +122,6 @@@ impl TodoTool
}
}
--/// The list belongs to the agent session the tool runs in: the orchestrator's
--/// session for a chat thread, a sub-agent's own session for its run. The
--/// orchestrator used to be routed to one app-wide `orchestrator-tasks` board
--/// instead; nothing rendered it, so the list the model kept was invisible to
--/// the thread the user was looking at. The parent context names the session;
--/// a tool that is only handed a thread id (older callers, tests) keys on that.
fn current_scope(
parent: Option<&ParentExecutionContext>,
tool_context: Option<&dyn ToolRunContext>,