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
test(e2e): assert tool calls via rendered cards instead of runtime store
Steven Enamakel05cbf7832695
diff --git a/app/test/e2e/specs/chat-multi-tool-round.spec.ts b/app/test/e2e/specs/chat-multi-tool-round.spec.tsindex 6571e99467..64befb9d2b 100644--- a/app/test/e2e/specs/chat-multi-tool-round.spec.ts+++ b/app/test/e2e/specs/chat-multi-tool-round.spec.ts@@ -57,27 +57,12 @@ const FORCED_RESPONSES = [{ content: `Found the content using both tools: ${CANARY_FINAL}` },];-interface ToolTimelineSnapshot {- ids: string[];- names: string[];-}--async function getToolTimeline(threadId: string): Promise<ToolTimelineSnapshot> {- return (await browser.execute((tid: string) => {- const winAny = window as unknown as { __OPENHUMAN_STORE__?: { getState: () => unknown } };- const state = winAny.__OPENHUMAN_STORE__?.getState() as- | {- chatRuntime?: {- toolTimelineByThread?: Record<string, Array<{ id?: string; name?: string }>>;- };- }- | undefined;- const timeline = state?.chatRuntime?.toolTimelineByThread?.[tid] ?? [];- return {- ids: timeline.map((e: { id?: string }) => e?.id ?? ''),- names: timeline.map((e: { name?: string }) => e?.name ?? ''),- };- }, threadId)) as ToolTimelineSnapshot;+async function renderedToolCards(): Promise<string[]> {+ return (await browser.execute(() =>+ Array.from(document.querySelectorAll<HTMLElement>('[data-testid="assistant-ui-tool-call"]')).map(+ card => card.innerText+ )+ )) as string[];}describe('Chat multi-tool round', () => {@@ -133,57 +118,21 @@ describe('Chat multi-tool round', () => {})).toBe(true);- // Watch for file_read to appear in the timeline.- let sawFileRead = false;- let sawFinal = false;- const deadline = Date.now() + 45_000;- while (Date.now() < deadline) {- const snap = await getToolTimeline(threadId);- if (snap.names.some(n => n.includes('file_read'))) {- sawFileRead = true;- console.log(`${LOG_PREFIX} T2.1: file_read in timeline — names: ${snap.names.join(', ')}`);- break;- }- if (await textExists(CANARY_FINAL)) {- sawFinal = true;- console.log(`${LOG_PREFIX} T2.1: final answer arrived (tools may have already cycled)`);- break;- }- await browser.pause(200);- }-- const finalArrived = await textExists(CANARY_FINAL);- expect(sawFileRead || sawFinal || finalArrived).toBe(true);+ await browser.waitUntil(+ async () => (await renderedToolCards()).some(card => card.includes('Read file')),+ { timeout: 45_000, interval: 100, timeoutMsg: 'Rendered file_read tool card never appeared' }+ );+ expect(await textExists('Read file')).toBe(true);console.log(`${LOG_PREFIX} T2.1: passed`);});it('T2.2 — agent calls tool 2 (grep); timeline shows 2 entries', async () => {console.log(`${LOG_PREFIX} T2.2: watching for grep in timeline`);- let sawGrep = false;- let maxEntries = 0;- const deadline = Date.now() + 45_000;- while (Date.now() < deadline) {- const snap = await getToolTimeline(threadId);- if (snap.names.some(n => n.includes('grep'))) {- sawGrep = true;- maxEntries = Math.max(maxEntries, snap.names.length);- console.log(- `${LOG_PREFIX} T2.2: grep in timeline — names: ${snap.names.join(', ')}, count: ${snap.names.length}`- );- break;- }- if (snap.names.length > maxEntries) maxEntries = snap.names.length;- if (await textExists(CANARY_FINAL)) {- console.log(`${LOG_PREFIX} T2.2: final answer arrived before grep poll`);- break;- }- await browser.pause(200);- }-- const finalArrived = await textExists(CANARY_FINAL);- // Either we saw grep in the live timeline, or the entire turn already finished.- expect(sawGrep || finalArrived).toBe(true);- console.log(`${LOG_PREFIX} T2.2: passed (sawGrep=${sawGrep}, maxEntries=${maxEntries})`);+ await browser.waitUntil(+ async () => (await renderedToolCards()).some(card => card.includes('Searching code')),+ { timeout: 45_000, interval: 100, timeoutMsg: 'Rendered grep tool card never appeared' }+ );+ expect(await textExists('Searching code')).toBe(true);});it('T2.3 — final answer renders after both tools complete', async () => {@@ -198,37 +147,11 @@ describe('Chat multi-tool round', () => {it('T2.5 — tool timeline has 2 entries (file_read before grep)', async () => {console.log(`${LOG_PREFIX} T2.5: verifying timeline order`);- // After IN_FLIGHT clears the timeline snapshot may have already been- // pruned by the runtime (entries are removed once complete in some- // configurations). We accept having seen both names at any point.- const snap = await getToolTimeline(threadId);- console.log(- `${LOG_PREFIX} T2.5: final timeline — names: ${snap.names.join(', ')}, ids: ${snap.ids.join(', ')}`- );-- // The tool names may already have been pruned when the final answer renders.- // This test verifies ordinal correctness if both entries are still present.- if (snap.names.length >= 2) {- const fileReadIndex = snap.names.findIndex(n => n.includes('file_read'));- const grepIndex = snap.names.findIndex(n => n.includes('grep'));- if (fileReadIndex !== -1 && grepIndex !== -1) {- expect(fileReadIndex).toBeLessThan(grepIndex);- console.log(- `${LOG_PREFIX} T2.5: order confirmed — file_read[${fileReadIndex}] < grep[${grepIndex}]`- );- } else {- console.log(- `${LOG_PREFIX} T2.5: one or both tools already pruned from timeline — relying on T2.3`- );- }- } else {- console.log(- `${LOG_PREFIX} T2.5: timeline has ${snap.names.length} entries after completion — tools pruned`- );- }-- // Primary assertion: the full turn produced the canary (tools ran in order).- expect(await textExists(CANARY_FINAL)).toBe(true);+ const cards = await renderedToolCards();+ const fileReadIndex = cards.findIndex(card => card.includes('Read file'));+ const grepIndex = cards.findIndex(card => card.includes('Searching code'));+ expect(fileReadIndex).toBeGreaterThanOrEqual(0);+ expect(grepIndex).toBeGreaterThan(fileReadIndex);console.log(`${LOG_PREFIX} T2.5: passed`);});});diff --git a/app/test/e2e/specs/chat-tool-call-flow.spec.ts b/app/test/e2e/specs/chat-tool-call-flow.spec.tsindex 9c147144d3..a021a5981f 100644--- a/app/test/e2e/specs/chat-tool-call-flow.spec.ts+++ b/app/test/e2e/specs/chat-tool-call-flow.spec.ts@@ -43,29 +43,12 @@ const FORCED_RESPONSES = [{ content: `Here is the fetched content: ${CANARY_FINAL}` },];-interface RuntimeSnapshot {- timelineIds: string[];- timelineNames: string[];-}--async function snapshotRuntime(threadId: string): Promise<RuntimeSnapshot> {- const winSnapshot = await browser.execute((tid: string) => {- const winAny = window as unknown as { __OPENHUMAN_STORE__?: { getState: () => unknown } };- const state = winAny.__OPENHUMAN_STORE__?.getState() as- | {- chatRuntime?: {- toolTimelineByThread?: Record<string, Array<{ id?: string; name?: string }>>;- };- }- | undefined;- const timeline = state?.chatRuntime?.toolTimelineByThread?.[tid] ?? [];- return {- timelineIds: timeline.map((e: { id?: string }) => e?.id ?? ''),- timelineNames: timeline.map((e: { name?: string }) => e?.name ?? ''),- };- }, threadId);-- return winSnapshot as { timelineIds: string[]; timelineNames: string[] };+async function renderedToolCards(): Promise<string[]> {+ return (await browser.execute(() =>+ Array.from(document.querySelectorAll<HTMLElement>('[data-testid="assistant-ui-tool-call"]')).map(+ card => card.innerText+ )+ )) as string[];}describe('Chat tool-call lifecycle', () => {@@ -116,63 +99,22 @@ describe('Chat tool-call lifecycle', () => {})).toBe(true);- // Poll for a tool timeline entry while the LLM processes the tool_calls turn.- let sawToolTimeline = false;- let sawFinalAnswer = false;- const deadline = Date.now() + 45_000;- while (Date.now() < deadline) {- const snap = await snapshotRuntime(threadId);- if (snap.timelineIds.length > 0 || snap.timelineNames.length > 0) {- sawToolTimeline = true;- console.log(- `${LOG_PREFIX} T1.1: tool timeline appeared — ids: ${snap.timelineIds.join(', ')}, names: ${snap.timelineNames.join(', ')}`- );- break;- }- // Also check if the final answer arrived (tool timeline may have already cleared- // if the whole turn was faster than our polling interval).- if (await textExists(CANARY_FINAL)) {- sawFinalAnswer = true;- console.log(`${LOG_PREFIX} T1.1: final answer arrived before first timeline poll`);- break;+ await browser.waitUntil(+ async () => (await renderedToolCards()).some(card => card.includes('Fetching example.com')),+ {+ timeout: 45_000,+ interval: 100,+ timeoutMsg: 'Rendered web_fetch tool card never appeared',}- await browser.pause(200);- }-- // The timeline entry is the primary signal, but if the full turn completed- // before our first poll we still accept the final-answer path.- const finalArrived = sawFinalAnswer || (await textExists(CANARY_FINAL));- expect(sawToolTimeline || finalArrived).toBe(true);- console.log(- `${LOG_PREFIX} T1.1: passed (sawTimeline=${sawToolTimeline}, finalArrived=${finalArrived})`);+ expect(await textExists('Fetching example.com')).toBe(true);});it('T1.2 — tool timeline entry shows tool name web_fetch', async () => {console.log(`${LOG_PREFIX} T1.2: checking tool name in timeline`);- const threadId = await getSelectedThreadId();- expect(typeof threadId).toBe('string');-- // The name may have already been recorded; if not, wait until it lands.- let toolName = '';- const deadline = Date.now() + 20_000;- while (Date.now() < deadline) {- const snap = await snapshotRuntime(threadId as string);- const webFetchName = snap.timelineNames.find(n => n.includes('web_fetch'));- if (webFetchName) {- toolName = webFetchName;- break;- }- // If timeline cleared but CANARY is present the tool ran successfully.- if (await textExists(CANARY_FINAL)) {- console.log(`${LOG_PREFIX} T1.2: canary visible, timeline may have cleared — acceptable`);- toolName = 'web_fetch'; // known from forced response config- break;- }- await browser.pause(250);- }- expect(toolName).toContain('web_fetch');- console.log(`${LOG_PREFIX} T1.2: passed — tool name: ${toolName}`);+ const cards = await renderedToolCards();+ expect(cards.some(card => card.includes('Fetching example.com'))).toBe(true);+ expect(await textExists('Fetching example.com')).toBe(true);});it('T1.3 — final answer with canary text renders in the DOM', async () => {