Skip to content

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

fix(workflow_builder): prefer graph handles over inline graph JSON

M3gA-Mind6cbcbb555036
diff --git a/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt.rs b/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt.rs
index e8b7610eb6..f9aa7b97f2 100644
--- a/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt.rs
+++ b/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt.rs
@@ -11,5 +11,21 @@ pub fn build(ctx: &PromptContext<'_>) -> Result<String> {
let archetype = ctx.flow_archetype_text.ok_or_else(|| {
anyhow!("workflow_builder requires a scoped TinyFlows GetPrompt response")
})?;
- super::super::flow_prompts::build_with_archetype(ctx, archetype)
+ let mut prompt = super::super::flow_prompts::build_with_archetype(ctx, archetype)?;
+ prompt.push_str(GRAPH_HANDLE_GUIDANCE);
+ Ok(prompt)
}
+
+/// A whole graph re-emitted as tool-call JSON is where small models break the
+/// JSON, and a call with broken arguments never runs: live, a builder resent
+/// the same malformed inline graph to `validate_workflow` until the failure
+/// breaker halted it, while a run that iterated on a draft passed.
+const GRAPH_HANDLE_GUIDANCE: &str = "\n\n## Passing graphs to tools\n\n\
+- Whenever a `draft_id` or `flow_id` exists, pass it to `validate_workflow` and \
+`dry_run_workflow` instead of the graph, and change the graph with `edit_workflow` \
+ops on that id instead of re-emitting it.\n\
+- With no id yet, an inline `graph` is the only source: keep it to the nodes and \
+config fields the step needs.\n\
+- If a call is answered that its arguments are not valid JSON, do not resend the \
+same graph. Rebuild it smaller (fewer nodes per call, shorter config text) and \
+check that before adding the rest.\n";
diff --git a/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt_tests.rs b/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt_tests.rs
index 3bca18cf47..8bfd859800 100644
--- a/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt_tests.rs
+++ b/crates/openhuman-core/src/agent_registry/agents/workflow_builder/prompt_tests.rs
@@ -30,4 +30,5 @@ fn builder_prompt_composes_supplied_archetype_tools_and_workspace() {
assert!(prompt.starts_with("module-owned builder archetype"));
assert!(prompt.contains("save_workflow"));
assert!(prompt.contains("## Workspace"));
+ assert!(prompt.contains("## Passing graphs to tools"));
}