Skip to content

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

feat(todo): publish ThreadTodosChanged event on successful write

Steven Enamakel1dce7cafd8c1
diff --git a/crates/openhuman-core/src/agent/tools/todo.rs b/crates/openhuman-core/src/agent/tools/todo.rs
index 6bfa6ed6b6..d4d5e25c38 100644
--- a/crates/openhuman-core/src/agent/tools/todo.rs
+++ b/crates/openhuman-core/src/agent/tools/todo.rs
@@ -64,9 +64,38 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext> for T
.map(|c| c.workspace_dir)
.map_err(|e| anyhow::anyhow!("[tool][todo] load config: {e}"))?,
};
- TodoTool::new(workspace_dir)
+ let is_write = arguments.get("todos").is_some();
+ let scope = current_scope(parent.data.parent.as_ref(), Some(&context));
+ let result = TodoTool::new(workspace_dir)
.execute_with_parent_context(arguments, parent.data.parent.clone(), Some(&context))
- .await
+ .await?;
+ // Only a whole-list write changes anything the frontend's todo drawer
+ // needs to hear about; a bare read (`{}`) re-reports the same list and
+ // would just be a redundant socket event.
+ if is_write && !result.is_error {
+ if let Some(id) = scope.session_id() {
+ match serde_json::from_str::<serde_json::Value>(&result.output())
+ .ok()
+ .and_then(|payload| payload.get("todos").cloned())
+ {
+ Some(todos) => {
+ crate::core::bus::BUS.publish(
+ crate::core::events::DomainEvent::ThreadTodosChanged {
+ thread_id: id.to_string(),
+ todos,
+ },
+ );
+ }
+ None => {
+ tracing::debug!(
+ thread_id = id,
+ "[tool][todo] write succeeded but result had no `todos` field — skipping ThreadTodosChanged"
+ );
+ }
+ }
+ }
+ }
+ Ok(result)
}
}