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(runtime): pin bounded task scopes and streamed code rendering
Steven Enamakel04432ec17aa9
diff --git a/app/test/playwright/specs/chat-harness-scroll-render.spec.ts b/app/test/playwright/specs/chat-harness-scroll-render.spec.tsindex 343b696917..887ab0b1d2 100644--- a/app/test/playwright/specs/chat-harness-scroll-render.spec.ts+++ b/app/test/playwright/specs/chat-harness-scroll-render.spec.ts@@ -264,4 +264,58 @@ test.describe('Chat Harness - Scroll Render', () => {).toBeGreaterThan(settledRemaining + 10);}});++ test('keeps an indented code block complete after streamed Markdown settles', async ({+ page,+ }) => {+ const script = [+ ...Array.from({ length: 80 }, (_, i) => ({+ text: `Filler line ${i + 1} — autogenerated to grow the scroll column.\n`,+ delayMs: 5,+ })),+ { text: `\n**${CANARY_BOLD}** is bold.\n\n`, delayMs: 30 },+ { text: ` ${CANARY_CODE}\n line 2\n\n`, delayMs: 30 },+ { text: `Visit [the docs](${LINK_URL}) for more.`, delayMs: 30 },+ { finish: 'stop', delayMs: 30 },+ ];+ await resetMock();+ await setMockBehavior('llmStreamScript', JSON.stringify(script));+ await setMockBehavior('llmStreamChunkDelayMs', '5');+ await openChat(page);+ await createNewThread(page);+ await sendMessage(page, 'Reply with the markdown sample please.');+ try {+ await expect(page.locator('pre code')).toContainText(`${CANARY_CODE}\nline 2`, {+ timeout: 40_000,+ });+ await expect(page.getByRole('link', { name: 'the docs', exact: true })).toHaveAttribute(+ 'href',+ LINK_URL+ );+ } finally {+ console.log(+ '[indented-code-state]',+ await page.evaluate(canary => {+ const state = (+ window as unknown as {+ __OPENHUMAN_STORE__?: {+ getState: () => {+ thread?: { messages?: { content: string }[] };+ chatRuntime?: { streamingAssistantByThread?: Record<string, unknown> };+ };+ };+ }+ ).__OPENHUMAN_STORE__?.getState();+ return {+ storedCanary:+ state?.thread?.messages?.some(message => message.content.includes(canary)) ?? false,+ streamingCanary: JSON.stringify(+ state?.chatRuntime?.streamingAssistantByThread ?? {}+ ).includes(canary),+ codeText: document.querySelector('pre code')?.textContent ?? null,+ };+ }, CANARY_CODE)+ );+ }+ });});diff --git a/crates/openhuman-core/src/core/runtime/spawn_tests.rs b/crates/openhuman-core/src/core/runtime/spawn_tests.rsindex 357492183f..19b949343d 100644--- a/crates/openhuman-core/src/core/runtime/spawn_tests.rs+++ b/crates/openhuman-core/src/core/runtime/spawn_tests.rs@@ -75,3 +75,21 @@ async fn spawn_blocking_scoped_keeps_the_memory_identity() {assert_eq!(seen.0.as_deref(), Some("u-ravi"));assert_eq!(seen.1.as_deref(), Some("planner"));}++#[test]+fn scoping_a_large_task_keeps_its_wrapper_bounded() {+ // Background pollers capture large async state. Carrying that state+ // inline through both task-local wrappers multiplies the moves on the+ // spawning thread, including the CLI's ordinary process-main stack.+ let payload = [7u8; 256 * 1024];+ let task = async move {+ tokio::task::yield_now().await;+ std::hint::black_box(payload)[0]+ };+ let wrapped = scoped(task);+ assert!(+ std::mem::size_of_val(&wrapped) < 64 * 1024,+ "context propagation must not duplicate a large task inline ({} bytes)",+ std::mem::size_of_val(&wrapped),+ );+}