Skip to content

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

agent: a deliverable by half-time, and a request read two ways is satisfied both ways

killbill1980c48f0023
diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md
index c10752dd39..2d0085dfcb 100644
--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md
+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt.md
@@ -29,5 +29,6 @@ First match wins:
- A hypothesis about the data's unit, axis, column order or encoding is tested, not argued: transform the data and compare with a value the request fixes (a known peak position, a documented constant, a sample output, a count). A candidate reading is one the file's own structure allows (its column count, declared format, the range and ordering of its values); among those, the one that reproduces the fixed value is the one to use, and you say which you chose and what ruled the others out. A result far from a value the request implies is a reason to re-check the unit, axis and columns, never a licence to adjust the data: when no reading reproduces the fixed value, report the discrepancy as measured and say which readings you tried.
- Think in the workspace, not in your head. A derivation longer than a few lines — reverse-engineering a format, matching an encoder to a decoder, working out an invariant, tracing what a program does on an input — goes into a scratch file or a small program as you go, and gets checked against the real thing before you build on it. Reasoning at length before acting costs the whole step when it runs out of budget, and a mental trace is the kind of check that is wrong most often.
- In your first steps, write down the acceptance contract: the exact paths, file names, commands, ports, output format, allowed and forbidden elements, thresholds and reference tools the request names. Tests, verifier scripts or a named reference tool are the source of truth over any metric of your own. Everything you do is judged against that contract, not against your approach.
+- Where the request describes one thing two ways — an argument called a folder in one sentence and the file to save in another, a format shown one way and named another — do not choose: implement so that every reading is satisfied, and test each. A path whose value carries a file extension is that file, whatever the prose around it calls it; a value without one is a directory.
- Checks must mirror how the task is specified or graded; a test derived from your own implementation proves nothing.
- Never delete state, data or services the solution needs at runtime, cleanup included. Verify the final state as a fresh consumer would see it.
diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs
index 09f28e7cd8..7045f75654 100644
--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs
+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs
@@ -54,6 +54,11 @@ fn render_installed_skills_lists_skills_and_names_the_hand_offs_it_is_given() {
&& ARCHETYPE.contains("source of truth over any metric of your own"),
"the contract-first rule is part of the archetype"
);
+ assert!(
+ ARCHETYPE.contains("implement so that every reading is satisfied")
+ && ARCHETYPE.contains("carries a file extension is that file"),
+ "the satisfy-every-reading rule is part of the archetype"
+ );
assert!(out.contains("- **ascii-art**: ASCII art via pyfiglet"));
assert!(out.contains("- **no-dir**: (no description)"));
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable.rs
index 014f523b6d..7a3823bfe9 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable.rs
@@ -36,9 +36,12 @@ use std::sync::Mutex;
use async_trait::async_trait;
use tinyagents_harness::context::RunContext;
use tinyagents_harness::error::{Result, TinyAgentsError};
+use tinyagents_harness::middleware::library::TurnClock;
use tinyagents_harness::middleware::Middleware;
+use tinyagents_harness::middleware::ToolInvocationIdentity;
use tinyagents_harness::tinyinference_llm::message::Message;
use tinyagents_harness::tinyinference_llm::model::{ModelRequest, ModelResponse};
+use tinytools::{ToolContent, ToolResult as TaToolResult};
use crate::agent::session_host::turn_checkpoint::wrap_harness_instruction;
@@ -164,6 +167,72 @@ pub(crate) fn notice(missing: &[String]) -> String {
struct RunState {
candidates: Option<Vec<String>>,
fired: bool,
+ /// The half-time note (a requested path still absent at 50% of the
+ /// clock) has been appended to a tool result.
+ half_noted: bool,
+ /// The late note (80% of the clock: stop exploring, measure every stated
+ /// limit) has been appended.
+ late_noted: bool,
+}
+
+/// Share of the turn's wall clock after which a requested path that still
+/// does not exist is pointed out on the next tool result.
+const HALF_TIME_BAND: u32 = 5;
+/// Share of the turn's wall clock after which exploring stops being worth
+/// it and the note says so.
+const LATE_BAND: u32 = 8;
+
+/// The note for a requested path still absent at half-time. The deliverable
+/// written now and improved in place beats one written in the last minute:
+/// one run spent eight of its nine minutes probing an input format, wrote
+/// the program at minute fourteen of fifteen, and had no time left to make
+/// it meet the size limit the request stated.
+fn half_time_note(missing: &[String], clock: &TurnClock) -> String {
+ let list = missing
+ .iter()
+ .map(|path| format!("`{path}`"))
+ .collect::<Vec<_>>()
+ .join(", ");
+ wrap_harness_instruction(&format!(
+ "Half the turn's budget is gone ({} left) and nothing exists yet at {list}. Write it \
+ now from what you have established, even if provisional, then improve it in place; \
+ measure every limit the request states against it as you go. Exploring further \
+ before it exists risks ending with nothing to judge.",
+ clock_text(clock.remaining())
+ ))
+}
+
+/// The note at 80% of the clock, whether or not the deliverable exists.
+fn late_note(clock: &TurnClock) -> String {
+ wrap_harness_instruction(&format!(
+ "{} of the turn's budget left. Stop exploring: make what exists meet every limit, \
+ format and interface the request names, measure each one through the exact interface \
+ it will be judged by, and finish. A result that meets the stated limits beats a better \
+ one that is not written.",
+ clock_text(clock.remaining())
+ ))
+}
+
+/// `1m 30s`-style rendering of what is left on the clock.
+fn clock_text(d: std::time::Duration) -> String {
+ let secs = d.as_secs();
+ if secs >= 60 {
+ format!("{}m {:02}s", secs / 60, secs % 60)
+ } else {
+ format!("{secs}s")
+ }
+}
+
+/// Appends `note` after the result's own content, in the plain blocks and in
+/// the markdown rendering, the way the harness's own clock note is appended.
+fn append_note(result: &mut TaToolResult, note: &str) {
+ result.content.push(ToolContent::Text {
+ text: format!("\n{note}"),
+ });
+ if let Some(markdown) = result.markdown_formatted.as_mut() {
+ markdown.push('\n');
+ markdown.push_str(note);
+ }
}
/// Holds a turn's first final answer once, when the request named an output
@@ -242,6 +311,67 @@ impl<C: Send + Sync> Middleware<(), C> for UnmetDeliverableMiddleware {
Ok(())
}
+ /// The clock-driven rungs: at half-time a requested path that still does
+ /// not exist is pointed out on the tool result the model is about to
+ /// read, and at 80% the note says to stop exploring and meet the stated
+ /// limits. Each is appended once per run, and each asks the loop for
+ /// reasoning on the next call: these are the moments thinking pays.
+ async fn after_tool(
+ &self,
+ ctx: &mut RunContext<C>,
+ _state: &(),
+ _invocation: &ToolInvocationIdentity,
+ result: &mut TaToolResult,
+ ) -> Result<()> {
+ let Some(clock) = TurnClock::of(ctx, None) else {
+ return Ok(());
+ };
+ let Some(band) = clock.band() else {
+ return Ok(());
+ };
+ let (candidates, half_noted, late_noted) = {
+ let Ok(runs) = self.runs.lock() else {
+ return Ok(());
+ };
+ match runs.get(&ctx.instance_id()) {
+ Some(run) => (
+ run.candidates.clone().unwrap_or_default(),
+ run.half_noted,
+ run.late_noted,
+ ),
+ None => return Ok(()),
+ }
+ };
+ if band >= LATE_BAND && !late_noted {
+ if let Ok(mut runs) = self.runs.lock() {
+ runs.entry(ctx.instance_id()).or_default().late_noted = true;
+ }
+ tracing::info!(
+ band,
+ "[unmet_deliverable] late note: stop exploring, meet the stated limits"
+ );
+ append_note(result, &late_note(&clock));
+ ctx.request_reasoning();
+ return Ok(());
+ }
+ if band >= HALF_TIME_BAND && !half_noted {
+ let missing = Self::missing(&candidates);
+ if let Ok(mut runs) = self.runs.lock() {
+ runs.entry(ctx.instance_id()).or_default().half_noted = true;
+ }
+ if !missing.is_empty() {
+ tracing::info!(
+ band,
+ missing = ?missing,
+ "[unmet_deliverable] half-time note: requested path still absent"
+ );
+ append_note(result, &half_time_note(&missing, &clock));
+ ctx.request_reasoning();
+ }
+ }
+ Ok(())
+ }
+
async fn after_model(
&self,
ctx: &mut RunContext<C>,
diff --git a/crates/openhuman-core/src/agent/tinyagents/verify_before_finish.rs b/crates/openhuman-core/src/agent/tinyagents/verify_before_finish.rs
index 01965902ce..24e14aadbb 100644
--- a/crates/openhuman-core/src/agent/tinyagents/verify_before_finish.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/verify_before_finish.rs
@@ -43,7 +43,9 @@ inputs and conditions stated in the request. Verify the complete outcome, includ
expected errors and side effects, and cite evidence from the final environment. Checks \
count only if derived from the request, not from your own approach.\n\
3. Where a sentence allows two readings, examine both against the surrounding requirements. \
-Apply the literal rule where it resolves the ambiguity; otherwise check both readings and \
+Apply the literal rule where it resolves the ambiguity; where both readings can be satisfied \
+at once, make the result satisfy both and test each (a path argument whose value has a file \
+extension is a file, one without is a directory); otherwise check both readings and \
state any remaining uncertainty instead of treating a check of your guess as proof.\n\
4. Find equivalent paths or workflows that perform the same action and verify that their \
required outcomes, notifications and state changes are consistent.\n\
diff --git a/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs b/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs
index 9a75c932ca..2ceba6f7c6 100644
--- a/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/verify_before_finish_tests.rs
@@ -167,6 +167,8 @@ fn check_is_a_harness_instruction_that_names_the_spec_rules() {
"stop exploring and",
"Once every check the contract names passes",
"named test still failing or never run",
+ "make the result satisfy both and test each",
+ "has a file extension is a file",
] {
assert!(check.contains(needle), "check must mention `{needle}`");
}