Skip to content

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

refactor(agent_runs): move subagent finalize subscriber into agent_runs

Steven Enamakelf2aa29cf487e
diff --git a/crates/openhuman-core/src/agent/orchestration/mod.rs b/crates/openhuman-core/src/agent/orchestration/mod.rs
index 80b8d49551..e8ee855c8c 100644
--- a/crates/openhuman-core/src/agent/orchestration/mod.rs
+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs
@@ -29,7 +29,6 @@ pub(crate) mod fleet_tools;
mod ops;
#[path = "parent_context/builder.rs"]
pub(crate) mod parent_context;
-pub(crate) mod run_ledger_finalize;
pub(crate) mod running_subagents;
pub(crate) mod spawn_parallel;
pub(crate) mod subagent_events;
diff --git a/crates/openhuman-core/src/agent_runs/mod.rs b/crates/openhuman-core/src/agent_runs/mod.rs
index 27b24dfce1..e526a73b79 100644
--- a/crates/openhuman-core/src/agent_runs/mod.rs
+++ b/crates/openhuman-core/src/agent_runs/mod.rs
@@ -5,6 +5,7 @@ pub(crate) mod command_center;
pub(crate) mod context_breakdown;
pub(crate) mod replay;
mod schemas;
+mod subagent_finalize;
pub(crate) mod subagent_control;
pub(crate) mod workflow_runs;
pub(crate) mod worktree_schemas;
@@ -28,6 +29,11 @@ pub(crate) use worktree_schemas::{
all_registered_controllers as all_worktree_registered_controllers,
};
+/// Registers the agent-run lifecycle projection for detached sub-agent events.
+pub(crate) fn register_subagent_finalize_subscriber(config: &crate::config::Config) {
+ subagent_finalize::register_subagent_finalize_subscriber(config);
+}
+
/// Registers the orchestration RPC surfaces in their catalogue order.
pub(crate) fn all_orchestration_registered_controllers(
) -> Vec<crate::core::all::RegisteredController> {
diff --git a/crates/openhuman-core/src/agent_runs/subagent_finalize.rs b/crates/openhuman-core/src/agent_runs/subagent_finalize.rs
index 42e86152e2..fb3d58d593 100644
--- a/crates/openhuman-core/src/agent_runs/subagent_finalize.rs
+++ b/crates/openhuman-core/src/agent_runs/subagent_finalize.rs
@@ -48,7 +48,7 @@ struct RunLedgerFinalizeSubscriber {
#[async_trait]
impl EventHandler<DomainEvent> for RunLedgerFinalizeSubscriber {
fn name(&self) -> &str {
- "agent_orchestration::run_ledger_finalize"
+ "agent_runs::subagent_finalize"
}
async fn handle(&self, event: &DomainEvent) {
@@ -104,7 +104,7 @@ impl EventHandler<DomainEvent> for RunLedgerFinalizeSubscriber {
/// Register the run-ledger finalizer on the global event bus. Leaks the
/// subscription handle so it lives for the whole process (its `Drop` would
/// cancel the subscriber). Called once from `register_domain_subscribers`.
-pub(crate) fn register_run_ledger_finalize_subscriber(config: &Config) {
+pub(crate) fn register_subagent_finalize_subscriber(config: &Config) {
if let Some(handle) = BUS.subscribe(Arc::new(RunLedgerFinalizeSubscriber {
config: config.clone(),
})) {
@@ -118,5 +118,5 @@ pub(crate) fn register_run_ledger_finalize_subscriber(config: &Config) {
}
#[cfg(test)]
-#[path = "run_ledger_finalize_tests.rs"]
+#[path = "subagent_finalize_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/core/runtime/subscribers.rs b/crates/openhuman-core/src/core/runtime/subscribers.rs
index 5265572a3b..f5da2d1c36 100644
--- a/crates/openhuman-core/src/core/runtime/subscribers.rs
+++ b/crates/openhuman-core/src/core/runtime/subscribers.rs
@@ -436,7 +436,7 @@ pub(super) fn register_domain_subscribers(
// global-bus subscriber settles `agent_runs` from
// `DomainEvent::Subagent{Completed,Failed}`, preventing rows from
// leaking as perpetual `running` timeline entries on thread reopen.
- crate::agent::orchestration::run_ledger_finalize::register_run_ledger_finalize_subscriber(&config);
+ crate::agent_runs::register_subagent_finalize_subscriber(&config);
}
} else {
log::debug!(