Skip to content

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

feat(agent): add deferred user message tracking

Steven Enamakel556d722f2d81
diff --git a/crates/openhuman-core/src/agent/queued_turn.rs b/crates/openhuman-core/src/agent/queued_turn.rs
index c1b589a319..536aeeb65d 100644
--- a/crates/openhuman-core/src/agent/queued_turn.rs
+++ b/crates/openhuman-core/src/agent/queued_turn.rs
@@ -47,6 +47,9 @@ pub struct QueuedPayload {
/// Requeued placeholders inherit it from their running turn; public chat
/// metadata never supplies or overrides this value.
pub(crate) trusted_turn: Option<Arc<super::turn_host::TrustedAgentTurn>>,
+ /// Follow-up submissions defer their user row until the trusted runner
+ /// admits them, so transcript order follows the preceding assistant turn.
+ pub(crate) deferred_user_message: bool,
pub(crate) stored_attachments: Option<StoredAttachmentInput>,
pub(crate) pending_attachments: Option<PendingAttachmentInput>,
}
@@ -60,6 +63,7 @@ impl std::fmt::Debug for QueuedPayload {
.field("locale", &self.locale)
.field("queued_at_ms", &self.queued_at_ms)
.field("has_trusted_turn", &self.trusted_turn.is_some())
+ .field("deferred_user_message", &self.deferred_user_message)
.field("has_stored_attachments", &self.stored_attachments.is_some())
.field(
"has_pending_attachments",
@@ -84,6 +88,7 @@ impl RequeuePayload for QueuedPayload {
if self.trusted_turn.is_none() {
self.trusted_turn.clone_from(&running.trusted_turn);
}
+ self.deferred_user_message |= running.deferred_user_message;
if self.pending_attachments.is_none() {
self.pending_attachments
.clone_from(&running.pending_attachments);
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index 5277f59345..b19f8e5fcc 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -386,6 +386,7 @@ async fn start_chat_inner(
locale,
metadata,
queued_at_ms,
+ deferred_user_message: mode == QueueMode::Followup,
stored_attachments,
pending_attachments: pending_attachments.clone(),
},
diff --git a/crates/openhuman-core/src/web_chat/runner.rs b/crates/openhuman-core/src/web_chat/runner.rs
index e74b35af91..44df0d0b79 100644
--- a/crates/openhuman-core/src/web_chat/runner.rs
+++ b/crates/openhuman-core/src/web_chat/runner.rs
@@ -83,10 +83,6 @@ pub(super) struct TurnSlot {
/// Cross-surface lease survives TinyAgents' early `checkin` until the
/// terminal projection has finished delivering this turn.
pub(super) session_lease: Option<SessionLease>,
- /// The runner removed this request from a queue and its user row has not
- /// been persisted by the web submit path. The trusted host persists it
- /// immediately before execution, preserving transcript order.
- pub(super) deferred_user_message: bool,
pub(super) fork: bool,
pub(super) config: Option<Arc<crate::config::Config>>,
pub(super) thread_dir: Option<std::path::PathBuf>,