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: address e2e review findings
Steven Enamakelac098eac3216
diff --git a/app/src/store/__tests__/threadSlice.test.ts b/app/src/store/__tests__/threadSlice.test.tsindex bc41c63cc4..4e92ac25d0 100644--- a/app/src/store/__tests__/threadSlice.test.ts+++ b/app/src/store/__tests__/threadSlice.test.ts@@ -168,6 +168,7 @@ describe('threadSlice synchronous reducers', () => {store.dispatch(setSelectedThread('t-1'));store.dispatch(setActiveThread('t-1'));+ const selectionVersion = store.getState().thread.selectionIntentVersion;store.dispatch(clearAllThreads());const state = store.getState().thread;expect(state.threads).toEqual([]);@@ -175,6 +176,7 @@ describe('threadSlice synchronous reducers', () => {expect(state.selectedThreadId).toBeNull();expect(state.activeThreadIds).toEqual({});expect(state.messages).toEqual([]);+ expect(state.selectionIntentVersion).toBeGreaterThan(selectionVersion);});it('clearStaleThread removes stale selection, cache, and active id', async () => {@@ -192,12 +194,14 @@ describe('threadSlice synchronous reducers', () => {store.dispatch(setSelectedThread('t-1'));store.dispatch(setActiveThread('t-1'));+ const selectionVersion = store.getState().thread.selectionIntentVersion;store.dispatch(clearStaleThread('t-1'));const state = store.getState().thread;expect(state.threads.map(thread => thread.id)).toEqual(['t-2']);expect(state.messagesByThreadId['t-1']).toBeUndefined();expect(state.selectedThreadId).toBeNull();+ expect(state.selectionIntentVersion).toBeGreaterThan(selectionVersion);expect(state.activeThreadIds).toEqual({});expect(state.messages).toEqual([]);});diff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.tsindex 4ecf91328c..f3ff1b5d65 100644--- a/app/src/store/threadSlice.ts+++ b/app/src/store/threadSlice.ts@@ -518,6 +518,7 @@ const threadSlice = createSlice({state.threads = state.threads.filter(thread => thread.id !== threadId);delete state.messagesByThreadId[threadId];if (state.selectedThreadId === threadId) {+ state.selectionIntentVersion = (state.selectionIntentVersion ?? 0) + 1;state.selectedThreadId = null;state.messages = [];state.messagesError = null;@@ -528,6 +529,7 @@ const threadSlice = createSlice({}},clearAllThreads: state => {+ state.selectionIntentVersion = (state.selectionIntentVersion ?? 0) + 1;state.threads = [];state.messagesByThreadId = {};state.selectedThreadId = null;diff --git a/app/test/playwright/helpers/core-rpc.ts b/app/test/playwright/helpers/core-rpc.tsindex 80c9210b1b..9a78439bed 100644--- a/app/test/playwright/helpers/core-rpc.ts+++ b/app/test/playwright/helpers/core-rpc.ts@@ -261,10 +261,7 @@ export async function waitForAppReady(page: Page): Promise<void> {return result.snapshot ?? null;} catch (error) {// Some slim or older cores do not expose this optional status method.- if (- error instanceof Error &&- error.message.includes('unknown method: openhuman.harness_init_status')- ) {+ if (error instanceof Error && /(?:unknown method|method not found)/i.test(error.message)) {return null;}throw error;@@ -279,9 +276,7 @@ export async function waitForAppReady(page: Page): Promise<void> {);if (alreadyDismissed) return;- const continueButton = page.getByTestId(- init.overall === 'failed' ? 'harness-init-continue-anyway' : 'harness-init-background'- );+ const continueButton = page.getByTestId(/harness-init-(?:background|continue-anyway)/);await expect.poll(async () => {diff --git a/app/test/playwright/specs/chat-scroll-stick.spec.ts b/app/test/playwright/specs/chat-scroll-stick.spec.tsindex 72efbb60c5..f0c3bca15d 100644--- a/app/test/playwright/specs/chat-scroll-stick.spec.ts+++ b/app/test/playwright/specs/chat-scroll-stick.spec.ts@@ -164,7 +164,7 @@ async function selectedThreadId(page: Page): Promise<string | null> {async function startNewThread(page: Page): Promise<void> {await dismissWalkthroughIfPresent(page);const previousThread = await selectedThreadId(page);- await page.getByRole('button', { name: 'New Conversation' }).click();+ await page.getByTestId('new-thread-button').click({ force: true });await expect.poll(() => selectedThreadId(page), { timeout: 20_000 }).not.toBe(previousThread);}diff --git a/app/test/playwright/specs/chat-thread-selection-race.spec.ts b/app/test/playwright/specs/chat-thread-selection-race.spec.tsindex 0673482595..8e73795072 100644--- a/app/test/playwright/specs/chat-thread-selection-race.spec.ts+++ b/app/test/playwright/specs/chat-thread-selection-race.spec.ts@@ -67,15 +67,17 @@ test('a stale thread-list response preserves a thread selected while it was in freleaseResponse?.();await expect.poll(() =>- page.evaluate(() => {+ page.evaluate((threadId: string) => {const store = (window as typeof window & {- __OPENHUMAN_STORE__?: { getState?: () => { thread?: { isLoadingThreads?: boolean } } };+ __OPENHUMAN_STORE__?: {+ getState?: () => { thread?: { threads?: Array<{ id: string }> } };+ };}).__OPENHUMAN_STORE__;- return store?.getState?.().thread?.isLoadingThreads === false;- })+ return store?.getState?.().thread?.threads?.some(thread => thread.id === threadId) ?? false;+ }, selectedDuringLoad))- .toBe(true);+ .toBe(false);expect(await selectedThreadId(page)).toBe(selectedDuringLoad);});diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rsindex 68f370f5cf..34fd7a507e 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs@@ -38,69 +38,8 @@ use crate::agent::tinyagents::verify_before_finish;use tinyagents_harness::store::InMemoryStore as ToolResultArtifactIndexStore;use super::ToolPolicyEnforcement;--/// Everything [`assemble_turn_harness`] wires up for one turn: the configured-/// harness plus the shared slots/handles the run loop reads after the drive-/// future returns.-pub(super) struct AssembledTurnHarness {- /// The fully assembled harness: model, tools, and middleware registered in- /// the intended order.- pub(super) harness: AgentHarness<(), OpenHumanRunContext>,- /// Shared 1-based model-call cursor (event bridge advances, model adapter- /// reads for out-of-band thinking attribution).- pub(super) cursor: IterationCursor,- /// Shared `call_id → tool_name` map used by the event bridge to label- /// tool-argument fragments projected off the crate stream.- pub(super) tool_names: ToolNameMap,- /// Shared `call_id → (success, failure, elapsed_ms, output_chars)` side-channel:- /// middleware records each outcome for the event bridge's `ToolCallCompleted`.- pub(super) failure_map: ToolFailureMap,- /// Shared FIFO carry of per-call provider `BilledUsage`; the event bridge- /// reads it when recording usage to preserve charged-USD precedence (#4467).- pub(super) provider_usage_carry: ProviderUsageCarry,- /// Recovers the original (downcastable) provider error on run failure.- pub(super) error_slot: crate::agent::tinyagents::model::ModelErrorSlot,- /// Root-cause summary recorded by the repeated-tool-failure breaker.- pub(super) halt_summary: HaltSummarySlot,- /// Per-call tool success/content capture for honest `ToolCallRecord`s.- pub(super) tool_outcome_sink: ToolOutcomeSink,- /// The shared steering handle (mid-flight steer, early-exit, cap, stop-hook- /// pauses).- pub(super) handle: Option<SteeringHandle>,- /// Records the first early-exit tool round, when early-exit tools exist.- pub(super) early_exit_hook: Option<EarlyExitHook>,- /// Set by [`FinalCallWrapUpMiddleware`] when it turned the last permitted- /// model call into the turn's conclusion (issue #6014). `None` when the- /// middleware is not installed (a run that does not pause at its cap).- ///- /// A flag rather than an inference off the run, because this turn now ends- /// the way a finished one does — the model returns text and requests no- /// tools — so `final_response.is_none()` no longer tells the two apart.- pub(super) wrap_up_fired:- Option<Arc<tinyagents_harness::middleware::FinalCallWrapUpMiddleware>>,- /// Number of callable tools registered.- pub(super) tool_count: usize,- /// TinyAgents named-capability projection for this turn. The live run still- /// uses the harness registries above; this snapshot makes the projected- /// model/tool/graph inventory inspectable without changing dispatch.- pub(super) registry_snapshot: RegistrySnapshot,- /// Health diagnostics from the projected registry.- pub(super) registry_diagnostics: Vec<RegistryDiagnostic>,- /// TinyAgents store index for OpenHuman action-dir tool-result artifacts.- pub(super) tool_result_artifact_index: Option<Arc<ToolResultArtifactIndexStore>>,- /// Concrete handle to the installed [`ContextCompressionMiddleware`], when- /// summarization is active. Drained after the run to surface each compaction's- /// [`CompressionProvenance`][tinyagents_harness::summarization::CompressionProvenance]- /// via the observability path.- pub(super) compression_mw: Option<Arc<ContextCompressionMiddleware>>,- /// Crate prompt-cache guard (issue #4249, 03.2). Records a `CacheLayoutEvent`- /// whenever the cacheable prompt prefix (system prompt + tool set) changes- /// across model calls. Drained after the run and surfaced via- /// [`observability::surface_cache_layout_events`](crate::agent::tinyagents::observability::surface_cache_layout_events) —- /// the crate-native replacement for the deleted `CacheAlignMiddleware`- /// warn-log (C3).- pub(super) prompt_cache_guard: Arc<PromptCacheGuardMiddleware>,-}+mod assembled;+pub(super) use assembled::AssembledTurnHarness;/// Assemble the turn harness for [`run_turn_via_tinyagents_shared`](super::run_turn_via_tinyagents_shared):/// register the provider model, every shared tool, and the full middlewarediff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly/assembled.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly/assembled.rsnew file mode 100644index 0000000000..429cd9b5f0--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly/assembled.rs@@ -0,0 +1,65 @@+use super::*;++/// Everything [`assemble_turn_harness`](super::assemble_turn_harness) wires up+/// for one turn: the configured harness plus the shared slots and handles the+/// run loop reads after the drive future returns.+pub(in crate::agent::tinyagents) struct AssembledTurnHarness {+ /// The fully assembled harness: model, tools, and middleware registered in+ /// the intended order.+ pub(in crate::agent::tinyagents) harness: AgentHarness<(), OpenHumanRunContext>,+ /// Shared 1-based model-call cursor (event bridge advances, model adapter+ /// reads for out-of-band thinking attribution).+ pub(in crate::agent::tinyagents) cursor: IterationCursor,+ /// Shared `call_id → tool_name` map used by the event bridge to label+ /// tool-argument fragments projected off the crate stream.+ pub(in crate::agent::tinyagents) tool_names: ToolNameMap,+ /// Shared `call_id → (success, failure, elapsed_ms, output_chars)` side-channel:+ /// middleware records each outcome for the event bridge's `ToolCallCompleted`.+ pub(in crate::agent::tinyagents) failure_map: ToolFailureMap,+ /// Shared FIFO carry of per-call provider `BilledUsage`; the event bridge+ /// reads it when recording usage to preserve charged-USD precedence (#4467).+ pub(in crate::agent::tinyagents) provider_usage_carry: ProviderUsageCarry,+ /// Recovers the original (downcastable) provider error on run failure.+ pub(in crate::agent::tinyagents) error_slot: crate::agent::tinyagents::model::ModelErrorSlot,+ /// Root-cause summary recorded by the repeated-tool-failure breaker.+ pub(in crate::agent::tinyagents) halt_summary: HaltSummarySlot,+ /// Per-call tool success/content capture for honest `ToolCallRecord`s.+ pub(in crate::agent::tinyagents) tool_outcome_sink: ToolOutcomeSink,+ /// The shared steering handle (mid-flight steer, early-exit, cap, stop-hook+ /// pauses).+ pub(in crate::agent::tinyagents) handle: Option<SteeringHandle>,+ /// Records the first early-exit tool round, when early-exit tools exist.+ pub(in crate::agent::tinyagents) early_exit_hook: Option<EarlyExitHook>,+ /// Set by [`FinalCallWrapUpMiddleware`] when it turned the last permitted+ /// model call into the turn's conclusion (issue #6014). `None` when the+ /// middleware is not installed (a run that does not pause at its cap).+ ///+ /// A flag rather than an inference off the run, because this turn now ends+ /// the way a finished one does — the model returns text and requests no+ /// tools — so `final_response.is_none()` no longer tells the two apart.+ pub(in crate::agent::tinyagents) wrap_up_fired:+ Option<Arc<tinyagents_harness::middleware::FinalCallWrapUpMiddleware>>,+ /// Number of callable tools registered.+ pub(in crate::agent::tinyagents) tool_count: usize,+ /// TinyAgents named-capability projection for this turn. The live run still+ /// uses the harness registries above; this snapshot makes the projected+ /// model/tool/graph inventory inspectable without changing dispatch.+ pub(in crate::agent::tinyagents) registry_snapshot: RegistrySnapshot,+ /// Health diagnostics from the projected registry.+ pub(in crate::agent::tinyagents) registry_diagnostics: Vec<RegistryDiagnostic>,+ /// TinyAgents store index for OpenHuman action-dir tool-result artifacts.+ pub(in crate::agent::tinyagents) tool_result_artifact_index:+ Option<Arc<ToolResultArtifactIndexStore>>,+ /// Concrete handle to the installed [`ContextCompressionMiddleware`], when+ /// summarization is active. Drained after the run to surface each compaction's+ /// [`CompressionProvenance`][tinyagents_harness::summarization::CompressionProvenance]+ /// via the observability path.+ pub(in crate::agent::tinyagents) compression_mw: Option<Arc<ContextCompressionMiddleware>>,+ /// Crate prompt-cache guard (issue #4249, 03.2). Records a `CacheLayoutEvent`+ /// whenever the cacheable prompt prefix (system prompt + tool set) changes+ /// across model calls. Drained after the run and surfaced via+ /// [`observability::surface_cache_layout_events`](crate::agent::tinyagents::observability::surface_cache_layout_events) —+ /// the crate-native replacement for the deleted `CacheAlignMiddleware`+ /// warn-log (C3).+ pub(in crate::agent::tinyagents) prompt_cache_guard: Arc<PromptCacheGuardMiddleware>,+}diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rsindex 353573ff02..8979fef884 100644--- a/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs@@ -92,6 +92,8 @@ use crate::security::prompt_injection::{};use crate::tools::agent_policy::{ToolPolicyAction, ToolPolicySession};use tinytools::{PermissionLevel, Tool};+mod outcome;+use outcome::decision_for_outcome;/// The tool name whose arguments carry a shell command string.///@@ -390,53 +392,6 @@ pub(crate) fn unanswered_approval_text(tool_name: &str) -> String {)}-/// Maps how the approval flow settled to what the runtime is told.-///-/// A refusal is a `Deny` whose text names no human and no timeout — every-/// refusal reads the same — and rules out other routes explicitly, because-/// `shell` never prompts while autonomy is disabled (`[autonomy] enabled =-/// false`, the default) and was used to redo a refused call.-///-/// The text carries no `[policy-denied]` marker on purpose. The marker-/// classifies as a policy failure with a zero recovery budget-/// (`middleware::repeated_failure`), which pauses the turn before the model can-/// answer. The model must get this turn to tell the user the action was not-/// done, as it did with the harness's unmarked fallback text.-fn decision_for_outcome(tool_name: &str, outcome: GateOutcome) -> GateDecision {- match outcome {- GateOutcome::Allow => GateDecision::Prompted { approved: true },- // An expired prompt is not a refusal: nobody answered, and the gate has- // now denied the request. Saying so lets the agent (and, for a- // sub-agent, its parent) tell the user the approval window expired and- // that they must ask again for a new request, rather than that it was- // declined — the generic text below left a 600s `media_generate_image`- // expiry reported as nothing at all.- GateOutcome::Deny { reason }- if crate::security::approval::is_unanswered_approval_reason(&reason) =>- {- tracing::warn!(- target: "tinyagents",- tool = %tool_name,- "[tinyagents::host::security] approval prompt expired unanswered"- );- GateDecision::deny(unanswered_approval_text(tool_name))- }- GateOutcome::Deny { reason } => {- tracing::warn!(- target: "tinyagents",- tool = %tool_name,- reason = %reason,- "[tinyagents::host::security] approval flow declined the tool call"- );- GateDecision::deny(- "This action was refused and must not be performed this turn — do not retry this \- call and do not achieve the same result another way (shell, CLI, another tool). \- Tell the user it was not done.",- )- }- }-}-#[async_trait]impl SecurityGate for OpenHumanSecurityGate {/// Answers in five stages, each of which can only narrow the answer:diff --git a/crates/openhuman-core/src/agent/tinyagents/host/security_gate/outcome.rs b/crates/openhuman-core/src/agent/tinyagents/host/security_gate/outcome.rsnew file mode 100644index 0000000000..1ce235dff7--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/host/security_gate/outcome.rs@@ -0,0 +1,40 @@+use tinyagents_harness::host::security_gate::GateDecision;++use crate::security::approval::GateOutcome;++use super::unanswered_approval_text;++/// Convert the approval flow's terminal outcome into the host gate decision.+///+/// Expired approval is distinct from an explicit refusal so the model can tell+/// the user that a new request is needed. Refusals deliberately omit the+/// policy-denial marker, which would stop the turn before the model can explain+/// what happened.+pub(super) fn decision_for_outcome(tool_name: &str, outcome: GateOutcome) -> GateDecision {+ match outcome {+ GateOutcome::Allow => GateDecision::Prompted { approved: true },+ GateOutcome::Deny { reason }+ if crate::security::approval::is_unanswered_approval_reason(&reason) =>+ {+ tracing::warn!(+ target: "tinyagents",+ tool = %tool_name,+ "[tinyagents::host::security] approval prompt expired unanswered"+ );+ GateDecision::deny(unanswered_approval_text(tool_name))+ }+ GateOutcome::Deny { reason } => {+ tracing::warn!(+ target: "tinyagents",+ tool = %tool_name,+ reason = %reason,+ "[tinyagents::host::security] approval flow declined the tool call"+ );+ GateDecision::deny(+ "This action was refused and must not be performed this turn — do not retry this \+ call and do not achieve the same result another way (shell, CLI, another tool). \+ Tell the user it was not done.",+ )+ }+ }+}diff --git a/scripts/ci/check-openhuman-rust-layout.mjs b/scripts/ci/check-openhuman-rust-layout.mjsindex 96c2ceffe6..f8fabfc234 100644--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@ -50,10 +50,6 @@ const LEGACY_LIMIT_ENTRIES = [["crates/openhuman-core/src/agent/subagent_host/ops/runner.rs", 1152],["crates/openhuman-core/src/tools/ops.rs", 1209],["crates/openhuman-core/src/web_chat/progress_bridge.rs", 1309],- // These composition and policy files grew in the upstream runtime changes;- // retain exact pins while their semantic splits are followed up.- ["crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs", 760],- ["crates/openhuman-core/src/agent/tinyagents/host/security_gate.rs", 772],// These established external test modules grew with upstream coverage. Pin// their current sizes while follow-up work separates their test concerns.// `core/` was pruned from the line limit by name until these pins; its