Skip to content

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

fix(harness): use the fallback when the closing-message check gives no verdict

M3gA-Mind7d47b9489e76
diff --git a/crates/openhuman-core/src/agent/harness/session/turn/core/grounded_close.rs b/crates/openhuman-core/src/agent/harness/session/turn/core/grounded_close.rs
index 1aecb05a00..e83496f0fd 100644
--- a/crates/openhuman-core/src/agent/harness/session/turn/core/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/harness/session/turn/core/grounded_close.rs
@@ -23,7 +23,8 @@ impl Agent {
/// 2. **Check.** A separate call that sees only the request, the records and
/// the candidate rejects a reply that narrates intent, contradicts a
/// record, or drops the failure that explains an unfinished request.
- /// 3. **Fallback.** An empty, tool-calling or rejected close is replaced by
+ /// 3. **Fallback.** An empty, tool-calling, rejected or unverified close
+ /// (the check failed or gave no verdict) is replaced by
/// [`turn_checkpoint::build_deterministic_final_summary`], which quotes
/// each result and the stop note.
///
@@ -89,11 +90,14 @@ impl Agent {
};
if verdict == Some(CloseVerdict::Unclear) {
log::warn!(
- "[agent_loop] closing-message check returned no ACCEPT/REJECT verdict; keeping the grounded reply"
+ "[agent_loop] closing-message check returned no ACCEPT/REJECT verdict; using the deterministic fallback"
);
}
- let accepted = matches!(verdict, Some(CloseVerdict::Accept | CloseVerdict::Unclear));
+ // Only an explicit ACCEPT ships the model's text. A failed or malformed
+ // check leaves the reply unverified, and shipping unverified closing text
+ // is the defect this path exists to stop (CodeRabbit on #6289).
+ let accepted = verdict == Some(CloseVerdict::Accept);
let reply = if accepted {
self.stream_text_continuation(&candidate, iteration).await;
candidate
diff --git a/crates/openhuman-core/src/agent/harness/session/turn_checkpoint.rs b/crates/openhuman-core/src/agent/harness/session/turn_checkpoint.rs
index 2d3e9d6f1d..c844f69fe1 100644
--- a/crates/openhuman-core/src/agent/harness/session/turn_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/harness/session/turn_checkpoint.rs
@@ -340,9 +340,8 @@ pub(super) fn close_verification_prompt(user_request: &str, records: &str, reply
pub(super) enum CloseVerdict {
Accept,
Reject,
- /// Neither word found (or the call failed). The caller keeps the reply:
- /// the check is a guard added on top of the grounded instruction, and an
- /// unavailable checker is no evidence against the reply.
+ /// Neither word found (or the call failed). The reply is unverified, so the
+ /// caller does not ship it and uses the deterministic fallback instead.
Unclear,
}
diff --git a/crates/openhuman-core/src/agent/harness/session/turn_final_reply_grounding_tests.rs b/crates/openhuman-core/src/agent/harness/session/turn_final_reply_grounding_tests.rs
index a9f6f3cbd8..10f5ca5527 100644
--- a/crates/openhuman-core/src/agent/harness/session/turn_final_reply_grounding_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/turn_final_reply_grounding_tests.rs
@@ -170,6 +170,36 @@ async fn an_intent_only_close_is_rejected_and_replaced_by_the_tool_records() {
);
}
+/// A check that fails or answers without a verdict leaves the close unverified,
+/// and unverified closing text must not ship (CodeRabbit on #6289).
+#[tokio::test]
+async fn an_unverified_close_is_replaced_by_the_tool_records() {
+ const CANDIDATE: &str = "The demo item is installed.";
+ let recorded = scripted(vec![
+ respond(INSTALL_CALL),
+ respond(""),
+ respond(CANDIDATE),
+ // No ACCEPT/REJECT verdict.
+ respond("I am not sure."),
+ ]);
+
+ let (agent, reply, streamed) = run_turn(recorded, vec![Box::new(FailingInstallTool)]).await;
+
+ assert!(
+ !reply.contains(CANDIDATE),
+ "a close the check could not verify must not be the reply, got: {reply}"
+ );
+ assert!(
+ reply.contains("View it at https://example.test/demo"),
+ "the fallback must carry the failing tool's own message, got: {reply}"
+ );
+ assert!(
+ !streamed.contains(CANDIDATE),
+ "an unverified close must never be streamed, got: {streamed}"
+ );
+ assert!(history_ends_on(&agent, &reply));
+}
+
#[tokio::test]
async fn an_accepted_close_is_streamed_and_kept() {
const CLOSE: &str = "I could not install the demo item: it has no direct download. \
diff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.md
index c8a6cd2800..314fc2fd7e 100644
--- a/gitbooks/developing/architecture/agent-harness.md
+++ b/gitbooks/developing/architecture/agent-harness.md
@@ -586,7 +586,7 @@ A breaker halt at the top level is likewise never a silent finish, and the break
1. A tools-disabled wrap-up call whose instruction restates the turn's tool records, each failure's own message included, with the breaker summary passed as a stop note to explain rather than repeat.
2. A separate check call that sees only the request, the records and the candidate reply. It rejects a reply that only narrates intent, contradicts a record, or leaves out the failure that explains an unfinished request.
-3. A deterministic fallback for an empty, tool-calling or rejected reply. It quotes each tool result and the stop note.
+3. A deterministic fallback for an empty, tool-calling, rejected or unverified reply (a check that failed or gave no verdict). It quotes each tool result and the stop note.
Accepted text is streamed only after the check, so a rejected reply never renders.