Skip to content

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

feat(voice): add explicit None request_id for voice harness approval context

Steven Enamakel72a0931b977d
diff --git a/app/src/features/conversations/aui/useThreadGoal.test.tsx b/app/src/features/conversations/aui/useThreadGoal.test.tsx
new file mode 100644
index 0000000000..8910ac9d2e
--- /dev/null
+++ b/app/src/features/conversations/aui/useThreadGoal.test.tsx
@@ -0,0 +1,68 @@
+import { combineReducers, configureStore } from '@reduxjs/toolkit';
+import { renderHook, waitFor } from '@testing-library/react';
+import type { ReactNode } from 'react';
+import { Provider } from 'react-redux';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { threadApi } from '../../../services/api/threadApi';
+import threadGoalReducer from '../../../store/threadGoalSlice';
+import { formatTokens, useLoadThreadGoal, useThreadGoal } from './useThreadGoal';
+
+vi.mock('../../../services/api/threadApi', () => ({
+ threadApi: { getGoal: vi.fn() },
+}));
+
+function setup() {
+ const store = configureStore({ reducer: combineReducers({ threadGoal: threadGoalReducer }) });
+ const wrapper = ({ children }: { children: ReactNode }) => (
+ <Provider store={store}>{children}</Provider>
+ );
+ return { store, wrapper };
+}
+
+describe('formatTokens', () => {
+ it('keeps small counts exact', () => {
+ expect(formatTokens(42)).toBe('42');
+ });
+ it('formats thousands', () => {
+ expect(formatTokens(1200)).toBe('1.2k');
+ });
+ it('formats millions', () => {
+ expect(formatTokens(2_500_000)).toBe('2.5M');
+ });
+});
+
+describe('useThreadGoal', () => {
+ it('returns null for a thread with no goal loaded', () => {
+ const { wrapper } = setup();
+ const { result } = renderHook(() => useThreadGoal('t1'), { wrapper });
+ expect(result.current).toBeNull();
+ });
+});
+
+describe('useLoadThreadGoal', () => {
+ beforeEach(() => vi.mocked(threadApi.getGoal).mockReset());
+
+ it('primes the slice from the RPC on thread open', async () => {
+ const goal = {
+ goal_id: 'g1',
+ objective: 'Ship it',
+ status: 'active' as const,
+ tokens_used: 10,
+ };
+ vi.mocked(threadApi.getGoal).mockResolvedValue(goal);
+ const { store, wrapper } = setup();
+ renderHook(() => useLoadThreadGoal('t1'), { wrapper });
+
+ await waitFor(() => expect(store.getState().threadGoal.byThread.t1).toEqual(goal));
+ });
+
+ it('leaves the slice untouched when the RPC fails', async () => {
+ vi.mocked(threadApi.getGoal).mockRejectedValue(new Error('no such method'));
+ const { store, wrapper } = setup();
+ renderHook(() => useLoadThreadGoal('t1'), { wrapper });
+
+ await waitFor(() => expect(threadApi.getGoal).toHaveBeenCalled());
+ expect(store.getState().threadGoal.byThread.t1).toBeUndefined();
+ });
+});
diff --git a/crates/openhuman-core/src/voice/realtime_harness/agent.rs b/crates/openhuman-core/src/voice/realtime_harness/agent.rs
index 320d4925f7..74ea2430a3 100644
--- a/crates/openhuman-core/src/voice/realtime_harness/agent.rs
+++ b/crates/openhuman-core/src/voice/realtime_harness/agent.rs
@@ -141,6 +141,8 @@ async fn run_single_with_timeout(
let approval_ctx = crate::security::approval::ApprovalChatContext {
thread_id: VOICE_CHAT_THREAD_ID.to_string(),
client_id: VOICE_CHAT_CLIENT_ID.to_string(),
+ // The realtime voice harness has no web-channel turn request_id.
+ request_id: None,
};
agent.set_thread_id(Some(VOICE_CHAT_THREAD_ID));
let scoped_run = agent.run_single(prompt);