Skip to content

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

refactor(prompts): move prompt and telemetry modules to canonical paths

Steven Enamakelc7acceafe5ce
diff --git a/crates/openhuman-core/src/agent/prompts/builder.rs b/crates/openhuman-core/src/agent/prompts/builder.rs
index 5d9dfed728..0b7513258c 100644
--- a/crates/openhuman-core/src/agent/prompts/builder.rs
+++ b/crates/openhuman-core/src/agent/prompts/builder.rs
@@ -51,8 +51,8 @@ impl TieredPrompt {
}
}
-use super::sections::*;
-use super::sync_workspace_file;
+use crate::prompts::sections::*;
+use crate::prompts::sync_workspace_file;
use super::types::*;
use anyhow::Result;
use std::path::Path;
diff --git a/crates/openhuman-core/src/agent/prompts/mod.rs b/crates/openhuman-core/src/agent/prompts/mod.rs
index 5b6d6cbcc5..ca6189821c 100644
--- a/crates/openhuman-core/src/agent/prompts/mod.rs
+++ b/crates/openhuman-core/src/agent/prompts/mod.rs
@@ -11,28 +11,8 @@ pub use agents_md::{AGENTS_MD_FILENAME, AgentsMdContent, load_agents_md, load_ag
pub mod builder;
pub use builder::{GLOBAL_STYLE_SUFFIX, SystemPromptBuilder, TieredPrompt};
-pub mod sections;
-pub use sections::*;
-
-#[path = "render_helpers/section_renderers.rs"]
-mod section_renderers;
-#[path = "render_helpers/subagent.rs"]
-mod subagent;
-#[path = "render_helpers/workspace_files.rs"]
-mod workspace_files;
-
-pub use section_renderers::{
- current_datetime_line, render_ambient_environment, render_datetime, render_identity,
- render_runtime, render_safety, render_tools, render_user_identity, render_workspace,
- turn_preamble,
-};
pub(crate) use subagent::harness_json_tool_prompt;
pub use subagent::{render_subagent_system_prompt, render_subagent_system_prompt_with_format};
-pub(crate) use workspace_files::write_agents_md_blocks;
-pub use workspace_files::{
- default_workspace_file_content, inject_inline_content, inject_workspace_file,
- inject_workspace_file_capped, sync_workspace_file,
-};
#[cfg(test)]
#[path = "mod_tests.rs"]
diff --git a/crates/openhuman-core/src/agent/registration.rs b/crates/openhuman-core/src/agent/registration.rs
index dc7dd34222..952d85a2e7 100644
--- a/crates/openhuman-core/src/agent/registration.rs
+++ b/crates/openhuman-core/src/agent/registration.rs
@@ -6,7 +6,7 @@ use super::orchestration::tools::{
WaitSubagentTool,
};
#[cfg(feature = "skills")]
-use super::tools::{AwaitWorkflowTool, RunWorkflowTool};
+use crate::skills::run_workflow::{AwaitWorkflowTool, RunWorkflowTool};
use super::tools::{PlanExitTool, TodoTool};
use crate::config::Config;
use std::path::Path;
diff --git a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
index f82cade496..d1694da280 100644
--- a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs
@@ -26,7 +26,8 @@ use crate::agent::tinyagents::host::OpenHumanRunContext;
use crate::agent::tinyagents::host::run_context::HostOperationContext;
use crate::agent::tinyagents::turn_policy::is_subagent_spawn_or_delegate_tool;
use crate::agent::tinyagents::use_skill_dispatch::UseSkillDispatch;
-use crate::agent::tools::{DelegateToolDispatch, TodoToolDispatch};
+use crate::agent::tools::TodoToolDispatch;
+use crate::tools::delegate::DelegateToolDispatch;
use crate::core::runtime::CoreContext;
use crate::tools::implementations::threads::SpawnWorkerThreadDispatch;
diff --git a/crates/openhuman-core/src/backend/mod.rs b/crates/openhuman-core/src/backend/mod.rs
index 1aed951924..68feecfebf 100644
--- a/crates/openhuman-core/src/backend/mod.rs
+++ b/crates/openhuman-core/src/backend/mod.rs
@@ -24,6 +24,7 @@
pub mod classify;
pub mod client;
pub mod transport;
+pub(crate) mod telemetry;
pub use client::{flatten_authed_error, BackendApiError, BackendClient};
pub use transport::{
diff --git a/crates/openhuman-core/src/backend/telemetry/mod.rs b/crates/openhuman-core/src/backend/telemetry/mod.rs
new file mode 100644
index 0000000000..6f8ab9f080
--- /dev/null
+++ b/crates/openhuman-core/src/backend/telemetry/mod.rs
@@ -0,0 +1,2 @@
+//! Backend telemetry adapters.
+pub(crate) mod langfuse;
diff --git a/crates/openhuman-core/src/core/observability/progress_tracing.rs b/crates/openhuman-core/src/core/observability/progress_tracing.rs
index ec4a515420..9932408e34 100644
--- a/crates/openhuman-core/src/core/observability/progress_tracing.rs
+++ b/crates/openhuman-core/src/core/observability/progress_tracing.rs
@@ -52,13 +52,15 @@
//! is exhaustively unit-testable.
/// Journal-backed projection from durable tinyagents observations.
+#[path = "../../agent/progress_tracing/journal_projection.rs"]
pub(crate) mod journal_projection;
/// Langfuse ingestion exporter (remote push through the configured backend).
-#[path = "progress_tracing/langfuse/environment.rs"]
-pub(crate) mod langfuse;
+pub(crate) use crate::backend::telemetry::langfuse;
+#[path = "../../agent/progress_tracing/otlp.rs"]
mod otlp;
/// The [`SpanCollector`] state machine that folds progress events into spans.
+#[path = "../../agent/progress_tracing/collector/mod.rs"]
mod collector;
/// Handing finished spans to the local exporter and the Langfuse push.
mod export;
@@ -88,8 +90,9 @@ pub(crate) use export::export_subagent_journal_trace;
pub(crate) use export::{export_run_trace, export_run_trace_from_journal};
#[cfg(test)]
+#[path = "../../agent/progress_tracing/journal_projection_tests.rs"]
mod journal_projection_tests;
#[cfg(test)]
-#[path = "progress_tracing/progress_tracing_tests.rs"]
+#[path = "../../agent/progress_tracing/progress_tracing_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/prompts/section_renderers.rs b/crates/openhuman-core/src/prompts/section_renderers.rs
index 061dccaef6..2b8c026d5a 100644
--- a/crates/openhuman-core/src/prompts/section_renderers.rs
+++ b/crates/openhuman-core/src/prompts/section_renderers.rs
@@ -2,8 +2,8 @@
//! [`crate::prompts::sections`], plus the per-turn datetime stamp and the
//! ambient-environment composer that `agents/<id>/prompt.rs` builders call.
-use super::sections::*;
-use super::types::*;
+use crate::prompts::sections::*;
+use crate::agent::prompts::types::*;
use anyhow::Result;
use std::sync::OnceLock;
use tinytools_agent::dialect::ToolCallFormat;
diff --git a/crates/openhuman-core/src/prompts/sections.rs b/crates/openhuman-core/src/prompts/sections.rs
index 9ee9b4ad0f..f3eadb9337 100644
--- a/crates/openhuman-core/src/prompts/sections.rs
+++ b/crates/openhuman-core/src/prompts/sections.rs
@@ -5,8 +5,8 @@
//! workspace-file helpers re-exported by [`super`] for workspace-file injection and
//! sub-agent plumbing.
-use super::types::*;
-use super::{inject_workspace_file, sync_workspace_file};
+use crate::agent::prompts::types::*;
+use crate::prompts::{inject_workspace_file, sync_workspace_file};
use anyhow::Result;
use std::fmt::Write;
use tinytools::ToolSpec;
@@ -227,7 +227,7 @@ impl PromptSection for AgentsInstructionsSection {
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut out = String::new();
- super::write_agents_md_blocks(
+ crate::prompts::write_agents_md_blocks(
&mut out,
ctx.agents_md_global.as_deref(),
ctx.agents_md_local.as_deref(),
@@ -344,7 +344,7 @@ impl PromptSection for SafetySection {
/// agent's own `prompt.md`, not here.
///
/// Byte-stable (no time / RNG / host) so it lives in the KV-cache-friendly
-/// prefix. Must contain no em-dashes per [`super::builder::GLOBAL_STYLE_SUFFIX`].
+/// prefix. Must contain no em-dashes per [`crate::agent::prompts::builder::GLOBAL_STYLE_SUFFIX`].
/// Heading the grounding contract renders under, in both the global
/// [`GROUNDING_BODY`] and any agent prompt that carries its own copy. The
/// builder matches on this to avoid emitting the contract twice.
diff --git a/crates/openhuman-core/src/prompts/workspace_files.rs b/crates/openhuman-core/src/prompts/workspace_files.rs
index d35d3e6587..204c70907f 100644
--- a/crates/openhuman-core/src/prompts/workspace_files.rs
+++ b/crates/openhuman-core/src/prompts/workspace_files.rs
@@ -2,7 +2,7 @@
//! workspace, injecting on-disk or inline content into a prompt under a
//! `###` heading with a character cap, and the shared AGENTS.md block writer.
-use super::types::*;
+use crate::agent::prompts::types::*;
use std::fmt::Write;
use std::hash::{Hash, Hasher};
use std::path::Path;
@@ -146,7 +146,7 @@ pub fn inject_inline_content(prompt: &mut String, label: &str, content: &str, ma
///
/// Used by both [`crate::prompts::sections::AgentsInstructionsSection`] (the default /
/// sub-agent builder chains) and the narrow sub-agent renderer
-/// ([`super::subagent::render_subagent_system_prompt_with_format`]) so the two paths never
+/// ([`crate::agent::prompts::subagent::render_subagent_system_prompt_with_format`]) so the two paths never
/// drift. The heading is emitted only when at least one layer carries content;
/// the global layer renders first, then the local/project layer. Each layer is
/// injected via [`inject_inline_content`] under its own `###` sub-heading and
@@ -194,7 +194,7 @@ pub(crate) fn write_agents_md_blocks(out: &mut String, global: Option<&str>, loc
/// file bytes at call time, and `max_chars`. Callers must invoke this
/// once per session — re-reading mid-session breaks the inference
/// backend's automatic prefix cache. See the byte-stability note on
-/// [`super::subagent::render_subagent_system_prompt`].
+/// [`crate::agent::prompts::subagent::render_subagent_system_prompt`].
pub fn inject_workspace_file_capped(
prompt: &mut String,
workspace_dir: &Path,
diff --git a/crates/openhuman-core/src/web_chat/mod.rs b/crates/openhuman-core/src/web_chat/mod.rs
index 5f575a6c7c..791b22a895 100644
--- a/crates/openhuman-core/src/web_chat/mod.rs
+++ b/crates/openhuman-core/src/web_chat/mod.rs
@@ -42,6 +42,7 @@ mod run_task;
mod schemas;
mod session;
mod suggestions;
+pub(crate) mod turn_guards;
mod turn_activity;
mod turn_close;
mod turn_timing;
diff --git a/crates/openhuman-core/src/web_chat/turn_guards/mod.rs b/crates/openhuman-core/src/web_chat/turn_guards/mod.rs
new file mode 100644
index 0000000000..810b9a91a1
--- /dev/null
+++ b/crates/openhuman-core/src/web_chat/turn_guards/mod.rs
@@ -0,0 +1,2 @@
+//! Web-chat turn deadline and cancellation guards.
+pub(crate) mod backstop;