Skip to content

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

agent: the deliverable check reads the current turn, skips URLs, and allows a file that lives elsewhere

killbill1dbf5af0febe
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 2b6f446a26..038e61a23d 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable.rs
@@ -99,8 +99,13 @@ pub(crate) fn candidate_paths(text: &str) -> Vec<String> {
continue;
}
// A path starts at a `/` that does not continue a token (so `a/b` in
- // prose is not read as rooted at `/b`).
- if index > 0 && is_path_char(bytes[index - 1]) {
+ // prose is not read as rooted at `/b`), and not at the `//` of a URL
+ // (`https://host/report.pdf` is not a local file).
+ if index > 0 && (is_path_char(bytes[index - 1]) || bytes[index - 1] == ':') {
+ index += 1;
+ continue;
+ }
+ if bytes.get(index + 1) == Some(&'/') {
index += 1;
continue;
}
@@ -153,12 +158,14 @@ pub(crate) fn notice(missing: &[String]) -> String {
("files", "do not exist")
};
wrap_harness_instruction(&format!(
- "The request names {subject} that {verb}: {list}. Nothing has been written there, so \
- none of this turn's work is available to whoever asked for it. Write it now with \
- whatever you have established, even where fields are incomplete or provisional, and \
- then answer. A file holding the parts you are sure of is worth more than a \
- description of what it would have contained; mark anything provisional inside it, or \
- say in your reply what is still missing."
+ "The request names {subject} that {verb} here: {list}. If that is the file this turn \
+ was asked to produce, nothing has been written there and none of this turn's work \
+ is available to whoever asked for it: write it now with whatever you have \
+ established, even where fields are incomplete or provisional, and then answer. A \
+ file holding the parts you are sure of is worth more than a description of what it \
+ would have contained; mark anything provisional inside it, or say in your reply what \
+ is still missing. If the path refers to a file that lives elsewhere (another \
+ machine, a container, a service), say so and answer as before."
))
}
@@ -304,12 +311,18 @@ impl<C: Send + Sync> Middleware<(), C> for UnmetDeliverableMiddleware {
if run.candidates.is_some() {
return Ok(());
}
- // The request is the turn's first user message; later user turns are
- // this harness's own injections and the model's follow-ups.
+ // The request is the current turn's user message: the last user
+ // message on the first call, since the thread's history rides ahead
+ // of it and the harness's own user-role injections are wrapped as
+ // instructions and arrive on later calls.
let text = request
.messages
.iter()
- .find(|message| matches!(message, Message::User(_)))
+ .rev()
+ .find(|message| {
+ matches!(message, Message::User(_))
+ && !message.text().contains("<harness_instruction>")
+ })
.map(Message::text)
.unwrap_or_default();
run.candidates = Some(candidate_paths(&text));
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable_tests.rs
index f3a9a7f918..5b1ce7b686 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/unmet_deliverable_tests.rs
@@ -65,6 +65,8 @@ fn only_absolute_paths_carrying_a_file_extension_are_candidates() {
"results go in /report.json", // single segment at the root
"read /app/../etc/passwd", // traversal is never statted
"the ratio is 3/4.5 overall", // arithmetic, not a path
+ "fetch https://example.com/report.pdf", // a URL, not a local file
+ "see http://host:8080/a/b.csv and //cdn/x.js", // scheme-less `//` too
] {
assert!(
candidate_paths(rejected).is_empty(),
@@ -103,12 +105,13 @@ fn a_repeated_path_is_reported_once_and_a_long_list_is_bounded() {
fn the_notice_names_the_paths_and_asks_for_a_partial_file() {
let one = notice(&["/app/output/r.json".to_string()]);
assert!(one.contains("<harness_instruction>"));
- assert!(one.contains("a file that does not exist"));
+ assert!(one.contains("a file that does not exist here"));
+ assert!(one.contains("lives elsewhere"));
assert!(one.contains("`/app/output/r.json`"));
assert!(one.contains("even where fields are incomplete or provisional"));
let two = notice(&["/a/x.json".to_string(), "/b/y.csv".to_string()]);
- assert!(two.contains("files that do not exist"));
+ assert!(two.contains("files that do not exist here"));
assert!(two.contains("`/a/x.json`, `/b/y.csv`"));
}
@@ -262,3 +265,62 @@ async fn install_covers_root_orchestrator_turns_only() {
"a sub-agent turn is not checked"
);
}
+
+/// The candidates come from the current turn's request, not from an earlier
+/// turn of the thread that rides ahead of it in the harness input, and not
+/// from a wrapped harness instruction.
+#[tokio::test]
+async fn candidates_come_from_the_current_turns_request() {
+ let old = std::env::temp_dir().join(format!("oh-unmet-old-{}.json", std::process::id()));
+ let new = std::env::temp_dir().join(format!("oh-unmet-new-{}.json", std::process::id()));
+ let _ = std::fs::remove_file(&old);
+ let _ = std::fs::remove_file(&new);
+ let mut harness: AgentHarness<()> = AgentHarness::new();
+ harness.register_model(
+ "mock",
+ Arc::new(ScriptedModel::new(vec![
+ tool_round("c0", "writer"),
+ tinyagents_harness::tinyinference_llm::model::ModelResponse::assistant(
+ "first answer".to_string(),
+ ),
+ tinyagents_harness::tinyinference_llm::model::ModelResponse::assistant(
+ "second answer".to_string(),
+ ),
+ ])),
+ );
+ harness.register_tool(Arc::new(FakeTool::returning("writer", "ok")));
+ harness.with_policy(RunPolicy {
+ limits: RunLimits::default()
+ .with_max_model_calls(20)
+ .with_max_tool_calls(20),
+ ..RunPolicy::default()
+ });
+ harness.push_middleware(Arc::new(UnmetDeliverableMiddleware::new(None)));
+ let run = harness
+ .invoke_default(
+ &(),
+ vec![
+ Message::user(format!("earlier turn: write {}", old.display())),
+ Message::assistant("done earlier"),
+ Message::user(format!("now write {}", new.display())),
+ ],
+ )
+ .await
+ .expect("run succeeds");
+ let notice = run
+ .messages
+ .iter()
+ .filter(|m| matches!(m, Message::User(_)) && m.text().contains("does not exist"))
+ .map(|m| m.text())
+ .collect::<Vec<_>>();
+ assert_eq!(notice.len(), 1, "held once for the current request");
+ assert!(
+ notice[0].contains(&new.display().to_string()),
+ "names the current turn's path"
+ );
+ assert!(
+ !notice[0].contains(&old.display().to_string()),
+ "not the earlier turn's path"
+ );
+ assert_eq!(run.text().as_deref(), Some("second answer"));
+}