The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(agent): keep autosave for the direct-chat RPC, and test the whole allowlist
yh9289b445d511ebf
diff --git a/src/openhuman/agent/turn_origin.rs b/src/openhuman/agent/turn_origin.rsindex d82464aabf..69e2d15109 100644--- a/src/openhuman/agent/turn_origin.rs+++ b/src/openhuman/agent/turn_origin.rs@@ -63,6 +63,21 @@ pub enum AgentTurnOrigin {},/// Command-line / sub-agent / one-off internal invocation.Cli,+ /// A person typing into a direct chat surface that is not the web thread —+ /// today the `openhuman.agent_chat` RPC behind the desktop Settings agent+ /// chat panel, and an operator running the same RPC by hand.+ ///+ /// Split out of [`Cli`](Self::Cli) rather than folded into it because the+ /// two answer different questions with the same variant. `Cli` was chosen+ /// for this RPC to tell the **approval gate** "trusted caller, do not fail+ /// closed"; it says nothing about who wrote the text, and its own+ /// documentation covers sub-agent and internal invocations too. Reusing it+ /// for [`is_user_authored`](Self::is_user_authored) would have to answer+ /// "did a person write this" with a trust answer, and would drop a real+ /// person's message on the floor.+ ///+ /// Trust-wise this is exactly `Cli` — the gate treats them identically.+ DirectChat,/// Unlabelled — gate fails closed. Every entry point MUST scope a real/// origin before invoking the agent.Unknown,@@ -121,14 +136,15 @@ impl AgentTurnOrigin {format!("TrustedAutomation({source:?})")}AgentTurnOrigin::Cli => "Cli".to_string(),+ AgentTurnOrigin::DirectChat => "DirectChat".to_string(),AgentTurnOrigin::Unknown => "Unknown".to_string(),}}/// Whether the turn's text was written by a **person**.///- /// `WebChat` and `ExternalChannel` carry what a human sent. Every other- /// origin carries text the host wrote for an agent to act on: a+ /// `WebChat`, `ExternalChannel`, and `DirectChat` carry what a human sent.+ /// Every other origin carries text the host wrote for an agent to act on: a/// `TrustedAutomation` prompt (cron, subconscious, goal continuation,/// workflow), a `Cli` invocation — which this module documents as/// "command-line / **sub-agent** / one-off internal" — or an unscoped@@ -138,12 +154,20 @@ impl AgentTurnOrigin {/// gate uses one: a new origin is a turn nobody has classified yet, and/// mistaking a host-written prompt for a user message writes it into the/// user's memory, where it is indistinguishable from something they said.- /// A caller that genuinely relays a person's text scopes one of the two+ /// A caller that genuinely relays a person's text scopes one of the three/// origins above.+ ///+ /// This is a **different question** from the one the approval gate asks,+ /// and the two must not be collapsed onto one variant. The gate asks how+ /// far to trust the caller; this asks who wrote the words. `DirectChat`+ /// exists because `agent_chat` needs the first answer to be "trusted" and+ /// the second to be "a person" — see that variant's note.pub fn is_user_authored(&self) -> bool {matches!(self,- AgentTurnOrigin::WebChat { .. } | AgentTurnOrigin::ExternalChannel { .. }+ AgentTurnOrigin::WebChat { .. }+ | AgentTurnOrigin::ExternalChannel { .. }+ | AgentTurnOrigin::DirectChat)}}diff --git a/src/openhuman/inference/local/ops_part_01.rs b/src/openhuman/inference/local/ops_part_01.rsindex 1f1620924f..9c04ce5c78 100644--- a/src/openhuman/inference/local/ops_part_01.rs+++ b/src/openhuman/inference/local/ops_part_01.rs@@ -119,13 +119,23 @@ fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {////// An ambient origin — scoped by an in-process embedder around its/// `invoke("openhuman.inference_agent_chat", …)` — is the caller's own,-/// deliberate trust statement about the turn and is kept. Absent one, the-/// historical [`AgentTurnOrigin::Cli`] label applies: this RPC is reached by-/// trusted clients (desktop UI, operator CLI), and leaving it unlabelled would-/// fail the approval gate closed on every external-effect tool.+/// deliberate trust statement about the turn and is kept. Absent one,+/// [`AgentTurnOrigin::DirectChat`] applies: this RPC is reached by trusted+/// clients (the desktop Settings agent-chat panel, an operator running the RPC+/// by hand), and leaving it unlabelled would fail the approval gate closed on+/// every external-effect tool.+///+/// `DirectChat` rather than the historical `Cli`, and the difference is not+/// cosmetic. The approval gate treats the two identically, so trust is+/// unchanged — but `message` here is something a *person* typed, and `Cli`+/// answers "who wrote this" with a trust answer. Its own documentation covers+/// sub-agent and internal invocations, so+/// [`is_user_authored`](crate::openhuman::agent::turn_origin::AgentTurnOrigin::is_user_authored)+/// reads `false` for it and the conversation autosave would silently drop a+/// real user message.fn effective_agent_chat_origin() -> crate::openhuman::agent::turn_origin::AgentTurnOrigin {crate::openhuman::agent::turn_origin::current()- .unwrap_or(crate::openhuman::agent::turn_origin::AgentTurnOrigin::Cli)+ .unwrap_or(crate::openhuman::agent::turn_origin::AgentTurnOrigin::DirectChat)}/// Executes a single chat turn with an AI agent.diff --git a/src/openhuman/security/approval/gate_intercept.rs b/src/openhuman/security/approval/gate_intercept.rsindex 64ffeeaf7f..c2064cf25b 100644--- a/src/openhuman/security/approval/gate_intercept.rs+++ b/src/openhuman/security/approval/gate_intercept.rs@@ -343,9 +343,15 @@ impl ApprovalGate {// TTL-denies, the conservative fail-closed default for a// user-forced HITL gate.}- AgentTurnOrigin::Cli => {+ // Same trust decision for both: a local operator invoking the core+ // directly. They differ only in whether the turn's text was written+ // by a person (`turn_origin::is_user_authored`), which this gate+ // does not ask. Kept as one arm so the two can never drift apart on+ // the trust axis, which is the axis this gate owns.+ AgentTurnOrigin::Cli | AgentTurnOrigin::DirectChat => {tracing::debug!(tool = tool_name,+ origin = %origin.class(),"[approval::gate] CLI / sub-agent caller — allowing without prompt");return (GateOutcome::Allow, None);diff --git a/src/openhuman/security/approval/gate_tests_part_03_tests.rs b/src/openhuman/security/approval/gate_tests_part_03_tests.rsindex bf015dcc05..51b3a521fb 100644--- a/src/openhuman/security/approval/gate_tests_part_03_tests.rs+++ b/src/openhuman/security/approval/gate_tests_part_03_tests.rs@@ -55,6 +55,31 @@ async fn intercept_with_cli_origin_allows_without_prompt() {assert!(matches!(outcome, GateOutcome::Allow));}+#[tokio::test]+async fn intercept_with_direct_chat_origin_allows_without_prompt() {+ // `DirectChat` shares the CLI arm: both are a local operator invoking+ // the core directly, and this gate decides on trust, not on whether the+ // turn's text was person-written. The arm is only sound while both+ // origins are covered — pinning `Cli` alone would let a future split+ // send `DirectChat` down the park-and-prompt path (or the TTL-deny one)+ // with nothing failing.+ let (gate, _dir) = test_gate();+ let outcome = turn_origin::with_origin(+ AgentTurnOrigin::DirectChat,+ gate.intercept("shell", "run ls", serde_json::json!({})),+ )+ .await;+ assert!(+ matches!(outcome, GateOutcome::Allow),+ "DirectChat must allow unprompted, got {outcome:?}"+ );+ // Allowed without prompting means nothing was parked for a decision.+ assert!(+ gate.list_pending().unwrap().is_empty(),+ "an allow-without-prompt must not persist a pending approval"+ );+}+/// Regression for #5508 / #5499: an external-effect scheduling tool/// (`cron_add`) that runs on a freshly-spawned, turn-less task — the exact/// shape of a hosted effect executor, which