Skip to content

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

feat(caps): delegate prompt helpers to upstream agent_prompt module

Steven Enamakele2ffa6400a09
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/mod.rs b/crates/openhuman-core/src/flows/tinyflows/caps/mod.rs
index 205caa0366..36eced5de3 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/mod.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/mod.rs
@@ -25,6 +25,13 @@ pub(crate) use llm::*;
// `caps::` path so existing call sites resolve unchanged.
pub use ops::*;
pub(crate) use prompt::*;
+// The pure prompt/reply helpers live upstream, beside the agent request builder.
+pub(crate) use tinyflows::nodes::integration::agent_prompt::{
+ build_agent_result, build_harness_run_prompt, clamp_run_timeout_secs, extract_structured_json,
+ input_context_block, node_request_to_prompt, parse_llm_json, prepend_system_message,
+ resolve_node_model, resolve_run_timeout_secs, scale_timeout_for_iteration_cap,
+ structured_output_instruction, structured_output_requested, INPUT_CONTEXT_MAX_LEN,
+};
pub(crate) use resolver::*;
pub(crate) use tier::*;
pub(crate) use tinyflows::caps::mock_schema_aware::*;
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs
index 634c84d42e..9715d45543 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/prompt.rs
@@ -1,9 +1,11 @@
//! Turning a node's request into a completion, and a completion back into a
//! node result.
//!
-//! Message assembly, the `input_context` carrier and its size cap, the
-//! structured-output contract, and the tolerant JSON extraction a model reply
-//! needs when it wraps its object in prose or a fenced block.
+//! The pure request/reply handling (the `input_context` carrier, structured
+//! output steering, tolerant JSON extraction) lives in
+//! `tinyflows::nodes::integration::agent_prompt`; this file keeps the host
+//! mapping of its neutral messages onto [`ChatMessage`], usage projection and
+//! model pinning.
#![allow(unused_imports)]
@@ -16,9 +18,24 @@ use tinyflows::error::{EngineError, Result};
use super::*;
use crate::agent::messages::ChatMessage;
+use tinyflows::nodes::integration::agent_prompt;
use crate::config::Config;
use crate::inference::provider::{is_raw_passthrough_model, UsageInfo};
+/// [`agent_prompt::build_completion_messages`] mapped onto the host's
+/// [`ChatMessage`] type.
+pub(crate) fn build_completion_messages(request: &Value) -> Vec<ChatMessage> {
+ agent_prompt::build_completion_messages(request)
+ .into_iter()
+ .map(|m| match m.role {
+ "system" => ChatMessage::system(m.content),
+ "assistant" => ChatMessage::assistant(m.content),
+ "tool" => ChatMessage::tool(m.content),
+ _ => ChatMessage::user(m.content),
+ })
+ .collect()
+}
+
/// Maps a `UsageInfo` (not `Serialize`) into a JSON value field-by-field, so
/// [`OpenHumanLlm::complete`] can surface it in its response `Value` without
/// requiring an upstream `Serialize` impl change.
@@ -56,10 +73,6 @@ pub(crate) fn model_response_to_completion_value(
})
}
-#[cfg(test)]
-#[path = "prompt_tests.rs"]
-mod tests;
-
/// Select the model an `agent` node completion actually runs on.
///
/// `resolved_model` is what [`create_chat_provider`] returned for the node's