Skip to content

test(agent): cover run cancellation through the harnesses - #1345

Draft
gewenyu99 wants to merge 1 commit into
mainfrom
posthog/fix-a3-cancel-tests
Draft

gewenyu99 wants to merge 1 commit into
mainfrom
posthog/fix-a3-cancel-tests

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Scope: Tests only. No behavior change.

Problem

A host cancel has to stop the pi session, the gateway re-mint and the orchestrator drain. Some of those paths had no test, so a regression would show up as a run that keeps working after the user cancels it. Review thread r4077474538 on #1307 asked for this coverage.

Changes

This PR only changes tests.

  • pi/__tests__/backend-cancellation.test.ts: the pi run and runTask sessions abort when the host cancels during a live turn, and both return the abort result. There is one it.each row per entry point.
  • pi/__tests__/cancellation.test.ts: the bindPiCancellation test is a table that covers a cancel after binding and a cancel before binding.
  • pi/__tests__/gateway.test.ts: when the host cancels during the re-mint, withGatewayRemint registers no new provider and does not continue.
  • orchestrator/__tests__/executor.test.ts: the sibling-join test is a table that covers a fatal error and a host cancel. In both rows, drainQueue waits for the live sibling and starts no dependents.

Test plan

  • pnpm typecheck, pnpm lint (0 errors), pnpm vitest run (202 files, 3360 tests) and pnpm test:arch pass.
  • Each test fails when the line it covers is reverted:
Reverted line Failing test
pi/index.ts binds inputs.signal to the session backend-cancellation, run row
pi/task.ts binds inputs.signal to the session backend-cancellation, runTask row
cancellation.ts if (signal?.aborted) onAbort() cancellation, before binding row
gateway.ts abort check after refreshAuth() gateway, cancel during the re-mint
executor.ts await Promise.allSettled(running.values()) executor, both rows

Created with PostHog Desktop

Host cancellation now has tests at each layer that handles it: the pi
run and task sessions abort on a live cancel, bindPiCancellation honours
a signal aborted before binding, withGatewayRemint stops after a cancel
during the re-mint, and drainQueue joins live siblings after a cancel.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant