The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(tinyagents): move graph topology and tracing to upstream crates
Steven Enamakel14a63527eb30
diff --git a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rs b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rsindex 6822ebc9b8..34c44ce7b5 100644--- a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rs+++ b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime.rs@@ -49,7 +49,7 @@ use tinyagents_orchestration::teams::{truncate_chars, MemberOutcome, SessionTeamLedger, TeamError,};-use crate::agent::tinyagents::observability::GraphTracingSink;+use tinyagents_graph::GraphTracingSink;const LOG_TARGET: &str = "agent_team_runtime";/// Fallback archetype when a member carries no explicit `agent_id`: thediff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rsindex d062a0efbe..e69cb1e3d1 100644--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs@@ -291,7 +291,7 @@ pub(crate) async fn run_engine_loop()),).with_event_sink(Arc::new(- crate::agent::tinyagents::observability::GraphTracingSink::new(format!(+ tinyagents_graph::GraphTracingSink::new(format!("workflow:{run_id}")),));diff --git a/crates/openhuman-core/src/agent/schemas.rs b/crates/openhuman-core/src/agent/schemas.rsindex c7b7eb29e0..8643c48011 100644--- a/crates/openhuman-core/src/agent/schemas.rs+++ b/crates/openhuman-core/src/agent/schemas.rs@@ -480,7 +480,7 @@ fn handle_triage_evaluate(params: Map<String, Value>) -> ControllerFuture {fn handle_graph_topologies(_params: Map<String, Value>) -> ControllerFuture {Box::pin(async {- let reports = crate::agent::tinyagents::all_graph_topologies();+ let reports = tinyagents_orchestration::topology::all_graph_topologies();let agents = crate::agent::registry::agents::load_builtins().map_err(|e| format!("loading built-in agent graph resolutions: {e}"))?.into_iter()@@ -620,7 +620,7 @@ fn handle_registry_snapshot(_params: Map<String, Value>) -> ControllerFuture {}// ── Graphs: structure-only topology reports ─────────────────────────- let reports = crate::agent::tinyagents::all_graph_topologies();+ let reports = tinyagents_orchestration::topology::all_graph_topologies();let graph_count = reports.len();for report in &reports {let mut meta = ComponentMetadata::new(report.name, ComponentKind::Graph)diff --git a/crates/openhuman-core/src/agent/tinyagents/README.md b/crates/openhuman-core/src/agent/tinyagents/README.mdindex b2acb26b75..3670be845c 100644--- a/crates/openhuman-core/src/agent/tinyagents/README.md+++ b/crates/openhuman-core/src/agent/tinyagents/README.md@@ -10,7 +10,7 @@ The adapter seam between OpenHuman and the vendored [`tinyagents`](../../../../.- Route workloads to model tiers and record the resolved provider/model for audit ([`routes.rs`](./routes.rs), canonical TinyInference response metadata).- Let TinyAgents stop repetitive visible model streams in its agent loop; the OpenHuman session driver turns `GenerationStalled` into a bounded partial containing completed tool evidence.- Make turns durable and replayable: a JSONL event journal plus status store ([`journal.rs`](./journal.rs)), a startup sweep for orphaned runs ([`reaper.rs`](./reaper.rs)), and a read-only RPC surface over both (`replay/`).-- Provide graph-layer helpers for multi-stage sub-agent orchestration (`orchestration.rs`, `delegation.rs`) and expose graph structure for debugging ([`topology.rs`](./topology.rs)).+- Provide graph-layer helpers for multi-stage sub-agent orchestration (`orchestration.rs`, `delegation.rs`) (graph structure export lives in `tinyagents_orchestration::topology`).- Pick which tools a turn even considers: `discovery/` holds the process-wide tool-search ranker slot (see [Tool search](#tool-search) below).- Host adapters (`host/`) for the crate's ten host-capability traits. Not yet wired into the live turn path; see [Host adapters](#host-adapters) below.@@ -37,8 +37,7 @@ The adapter seam between OpenHuman and the vendored [`tinyagents`](../../../../.| `model.rs` | Helpers and wrappers over native crate `ChatModel` values: message/response translation, usage merging, stream-delta forwarding, `MaxTokensModel`, `ProfileOverrideModel`. || [`tools.rs`](./tools.rs) | `CanonicalSharedToolAdapter`: resolves an OpenHuman shared tool registry and forwards the canonical `tinytools::Tool` contract; `EarlyExitHook` pauses successful `ask_user_clarification`-style calls. || `routes.rs` | the workload router projected from the upstream `WORKLOAD_ROUTES` table, `RequiredCapabilitiesMiddleware`, `FallbackObserverMiddleware`, `UsageCarryMiddleware`, and the per-model fallback policy. |-| `topology.rs` | `all_graph_topologies`: behaviour-free `GraphTopology` exports of every custom OpenHuman graph for debug/inspection. |-| [`observability.rs`](./observability.rs) + `observability/` | `event_bridge.rs`: `OpenhumanEventBridge`, translating crate `AgentEvent`s into `AgentProgress` and feeding per-call usage into `crate::platform::cost`. `event_projection.rs`: its `EventListener` impl. `bridge_types.rs`: `SubagentScope` and the shared bridge carries (the cap pauser itself is `tinyagents_harness::events::CapPauser`). `graph_tracing.rs`: `GraphTracingSink`. |+| [`observability.rs`](./observability.rs) + `observability/` | `event_bridge.rs`: `OpenhumanEventBridge`, translating crate `AgentEvent`s into `AgentProgress` and feeding per-call usage into `crate::platform::cost`. `event_projection.rs`: its `EventListener` impl. `bridge_types.rs`: `SubagentScope` and the shared bridge carries (the cap pauser itself is `tinyagents_harness::events::CapPauser`). || [`host/steering.rs`](./host/steering.rs) | OpenHuman's steering allowlist and the shared `SteeringRegistry` for detached sub-agents. Task primitives are imported directly from `tinyagents_graph::orchestration`. || [`host/delegation.rs`](./host/delegation.rs) | Explicit tracing-bound execution helpers over `tinyagents_graph::delegation`'s plan, execute, review, finalize graph. || [`payload_summarizer.rs`](./payload_summarizer.rs) | `PayloadSummarizer` trait, `SummarizeOutcome`/`UnavailableReason`, and the default `SubagentPayloadSummarizer` that compresses oversized tool results through the `summarizer` sub-agent instead of hard-truncating them. |diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rsindex e1b682ab3d..e547186023 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_tool_registration.rs@@ -204,7 +204,7 @@ pub(super) fn register_turn_tools_and_agents(}}let tool_count = registered.len();- for report in crate::agent::tinyagents::topology::all_graph_topologies() {+ for report in tinyagents_orchestration::topology::all_graph_topologies() {let _ = capability_registry.register_descriptor(ComponentKind::Graph, report.name);}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/delegation.rs b/crates/openhuman-core/src/agent/tinyagents/host/delegation.rsindex 5be06eccc0..049e8383fa 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/delegation.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/delegation.rs@@ -21,7 +21,7 @@//! # The sink is the reason these are wrappers, not plain re-exports//!//! Every delegation run is journalled onto OpenHuman's `tracing` diagnostics-//! through [`GraphTracingSink`](super::observability::GraphTracingSink), which+//! through [`GraphTracingSink`](tinyagents_graph::GraphTracingSink), which//! lives in [`super::observability`] alongside the cost catalog, the tool-status//! classifier and the provider usage tables — host surface that must not follow//! the graph upstream. The crate instead takes an optional@@ -45,7 +45,7 @@use std::future::Future;use std::sync::Arc;-use super::super::observability::GraphTracingSink;+use tinyagents_graph::GraphTracingSink;use tinyagents_graph::delegation::{DelegationConfig, DelegationOutcome, DelegationStage, DelegationStageOutput, DelegationState,diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rsindex 8ad5952a82..023e61fd0d 100644--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs@@ -59,7 +59,6 @@ mod steering_forwarder;pub(crate) mod stop_hooks;pub mod todos;pub(crate) mod tools;-mod topology;mod turn_models;mod turn_outcome;mod turn_policy;@@ -81,7 +80,6 @@ pub(crate) use middleware::{};pub(crate) use observability::SubagentScope;pub(crate) use reasoning::{apply_requested_effort, parse_reasoning_effort};-pub(crate) use topology::all_graph_topologies;pub use turn_models::TurnModelSource;pub(crate) use turn_models::TurnModels;pub(crate) use turn_outcome::TinyagentsTurnOutcome;@@ -108,5 +106,8 @@ mod nested_calls_tests;#[path = "prompt_cache_golden_tests.rs"]mod prompt_cache_golden_tests;#[cfg(test)]+#[path = "topology_collision_tests.rs"]+mod topology_collision_tests;+#[cfg(test)]#[path = "tinyagents_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/observability.rs b/crates/openhuman-core/src/agent/tinyagents/observability.rsindex 9d4c8c3659..32b645a3f6 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability.rs@@ -11,7 +11,6 @@mod bridge_types;mod event_bridge;mod event_projection;-mod graph_tracing;#[cfg(test)]use std::sync::Arc;@@ -27,7 +26,6 @@ use crate::agent::progress::AgentProgress;pub(crate) use bridge_types::{ProviderUsageCarry, SubagentScope, ToolFailureMap, ToolNameMap};pub(crate) use event_bridge::OpenhumanEventBridge;pub(crate) use event_projection::surface_cache_layout_events;-pub(crate) use graph_tracing::GraphTracingSink;#[cfg(test)]#[path = "observability_tests.rs"]diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/graph_tracing.rs b/crates/openhuman-core/src/agent/tinyagents/observability/graph_tracing.rsdeleted file mode 100644index 36c36233a2..0000000000--- a/crates/openhuman-core/src/agent/tinyagents/observability/graph_tracing.rs+++ /dev/null@@ -1,66 +0,0 @@-//! [`GraphTracingSink`] — mirrors the `tinyagents` graph executor's lifecycle-//! stream onto openhuman's `tracing` diagnostics.--use std::sync::atomic::Ordering;-use std::sync::Arc;--use tinyagents_graph::stream::{GraphEvent, GraphEventEnvelope, GraphEventSink};--/// A [`GraphEventSink`] that mirrors the `tinyagents` graph executor's lifecycle-/// stream onto openhuman's `tracing` diagnostics — an observability journal for-/// graph runs (issue #4249 / #28). Node/step/run/route transitions land as-/// grep-friendly `[graph]` lines tagged with `label`; the running event count is-/// exposed for tests. Shared by every openhuman graph (council fan-out,-/// sub-agent delegation, …).-pub(crate) struct GraphTracingSink {- label: String,- count: Arc<std::sync::atomic::AtomicUsize>,-}--impl GraphTracingSink {- /// Build a sink tagging its lines with `label` (e.g. `"delegation:graph"`).- /// Accepts both string literals and runtime-built labels.- pub(crate) fn new(label: impl Into<String>) -> Self {- Self {- label: label.into(),- count: Arc::new(std::sync::atomic::AtomicUsize::new(0)),- }- }-- /// Shared counter of events observed, for assertions.- fn counter(&self) -> Arc<std::sync::atomic::AtomicUsize> {- self.count.clone()- }-}--impl GraphEventSink for GraphTracingSink {- fn emit(&self, envelope: GraphEventEnvelope) {- let event = envelope.event;- self.count.fetch_add(1, Ordering::Relaxed);- let label = self.label.as_str();- match &event {- GraphEvent::RunStarted { run_id } => {- tracing::debug!(label, ?run_id, "[graph] run started")- }- GraphEvent::RunCompleted { steps, .. } => {- tracing::debug!(label, steps, "[graph] run completed")- }- GraphEvent::RunFailed { error, .. } => {- tracing::warn!(label, %error, "[graph] run failed")- }- GraphEvent::NodeStarted { node, step } => {- tracing::debug!(label, ?node, step, "[graph] node started")- }- GraphEvent::NodeCompleted { node, step } => {- tracing::debug!(label, ?node, step, "[graph] node completed")- }- GraphEvent::NodeFailed { node, error, .. } => {- tracing::warn!(label, ?node, %error, "[graph] node failed")- }- GraphEvent::RouteSelected { node, target } => {- tracing::trace!(label, ?node, ?target, "[graph] route selected")- }- _ => tracing::trace!(label, "[graph] event"),- }- }-}diff --git a/crates/openhuman-core/src/agent/tinyagents/topology.rs b/crates/openhuman-core/src/agent/tinyagents/topology.rsdeleted file mode 100644index fd856b9f7c..0000000000--- a/crates/openhuman-core/src/agent/tinyagents/topology.rs+++ /dev/null@@ -1,68 +0,0 @@-//! Graph topology export for debug / inspection (issue #4249, Phase 4).-//!-//! Every custom OpenHuman graph exposes a `*_topology()` builder that constructs-//! its structure with no-op stub closures and returns a behaviour-free-//! [`GraphTopology`] (node names, edges, routing, and a structural validation-//! report — never closure bodies). [`all_graph_topologies`] collects them so a-//! UI / debug endpoint can render the orchestration graphs as JSON or Mermaid-//! and surface any structural defects.--use tinyagents_graph::export::{self, GraphTopology};--/// A rendered topology for one graph.-pub(crate) struct GraphTopologyReport {- /// Stable graph label (e.g. `"agent_teams:member"`).- pub(crate) name: &'static str,- /// Mermaid `flowchart TD` rendering.- pub(crate) mermaid: String,- /// Pretty-printed JSON of the full topology.- pub(crate) json: String,- /// `true` when the structural validation found no errors.- pub(crate) ok: bool,- /// Structural defects (missing nodes, unreachable routes, …).- pub(crate) errors: Vec<String>,- /// Non-fatal observations.- pub(crate) warnings: Vec<String>,-}--/// Render a [`GraphTopology`] into a [`GraphTopologyReport`].-fn describe(name: &'static str, topology: &GraphTopology) -> GraphTopologyReport {- GraphTopologyReport {- name,- mermaid: export::to_mermaid(topology),- json: export::to_json(topology),- ok: topology.validation.ok,- errors: topology.validation.errors.clone(),- warnings: topology.validation.warnings.clone(),- }-}--/// Collect structure-only topologies of every custom OpenHuman graph.-///-/// Graphs that fail to build (should not happen for the fixed-structure graphs)-/// are silently skipped. Each entry carries a Mermaid + JSON rendering and the-/// structural validation report.-pub(crate) fn all_graph_topologies() -> Vec<GraphTopologyReport> {- let mut out = Vec::new();-- if let Ok(t) = tinyagents_orchestration::teams::member_graph_topology() {- out.push(describe("agent_teams:member", &t));- }-- if let Ok(t) = tinyagents_graph::delegation::delegation_graph_topology() {- out.push(describe("delegation", &t));- }-- if let Ok(t) = tinyagents_orchestration::workflow::scheduler_topology_preview() {- out.push(describe("workflow_runs:scheduler_preview", &t));- }-- // Not exported: item-count-driven `map_reduce` fan-outs whose node set is- // determined per run rather than by a fixed named topology.-- out-}--#[cfg(test)]-#[path = "topology_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/topology_tests.rs b/crates/openhuman-core/src/agent/tinyagents/topology_collision_tests.rssimilarity index 66%rename from crates/openhuman-core/src/agent/tinyagents/topology_tests.rsrename to crates/openhuman-core/src/agent/tinyagents/topology_collision_tests.rsindex 9fc67c8082..1569d0db03 100644--- a/crates/openhuman-core/src/agent/tinyagents/topology_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/topology_collision_tests.rs@@ -1,30 +1,3 @@-use super::*;--#[test]-fn all_topologies_includes_member_delegation_and_workflow_scheduler() {- let reports = all_graph_topologies();- for name in [- "agent_teams:member",- "delegation",- "workflow_runs:scheduler_preview",- ] {- let report = reports- .iter()- .find(|r| r.name == name)- .unwrap_or_else(|| panic!("the {name} graph should be exported"));- assert!(- report.ok,- "{name} graph should validate structurally: {:?}",- report.errors- );- assert!(- report.mermaid.contains("flowchart"),- "{name} mermaid should render: {}",- report.mermaid- );- }-}-#[test]fn all_topologies_names_do_not_collide_with_production_tools() {let tmp = tempfile::tempdir().expect("create tempdir");@@ -63,7 +36,7 @@ fn all_topologies_names_do_not_collide_with_production_tools() {"expected spawn_parallel_agents in production all_tools registration");- let reports = all_graph_topologies();+ let reports = tinyagents_orchestration::topology::all_graph_topologies();for report in &reports {assert!(!tool_names.contains(report.name),