Skip to content

refactor: move the agent, programs, tui, hosts, tools and cli onto the session store - #1378

Merged
gewenyu99 merged 1 commit into
posthog/functional-r9-03-add-the-session-store-and-run-contract-tfrom
posthog/functional-r9-05-take-each-run-s-route-from-its-program-a
Oct 5, 2026
Merged

gewenyu99 merged 1 commit into
posthog/functional-r9-03-add-the-session-store-and-run-contract-tfrom
posthog/functional-r9-05-take-each-run-s-route-from-its-program-a

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Phase 2 of Release C (#1320), PR 2 of 4, after #1376. This PR folds the 13 reviewed PRs #1378 to #1390 into one, because their pieces only compile together. Each piece was approved on its own PR, which keeps its review threads.

Problem

On main, programs run through the legacy runner with a TUI wrapped around the session, and every layer imports the others. This PR moves the agent, programs, TUI, hosts, tools and CLI onto the session store from #1376, deletes the old modules, and brings the tests along.

Changes

Test plan

Created with PostHog Desktop

@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.

@gewenyu99
gewenyu99 added this pull request to stack #1394 September 29, 2026 09:41
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from 347a236 to b564b5c Compare September 30, 2026 08:06
@gewenyu99
gewenyu99 removed this pull request from stack #1394 September 30, 2026 08:07
@gewenyu99
gewenyu99 changed the base branch from posthog/functional-r9-04-add-shared-run-state-control-types-and-r to posthog/functional-r9-03-add-the-session-store-and-run-contract-t September 30, 2026 08:07
@gewenyu99
gewenyu99 added this pull request to stack #1400 September 30, 2026 08:07
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from b564b5c to de14bf2 Compare September 30, 2026 08:44
@gewenyu99
gewenyu99 marked this pull request as ready for review September 30, 2026 09:43
@gewenyu99
gewenyu99 requested a review from a team as a code owner September 30, 2026 09:43
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from de14bf2 to 5320df3 Compare September 30, 2026 14:11
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from 5320df3 to e278aff Compare October 1, 2026 06:43
@gewenyu99
gewenyu99 removed this pull request from stack #1400 October 1, 2026 06:47
@gewenyu99
gewenyu99 added this pull request to stack #1403 October 1, 2026 06:47

@johncwaters johncwaters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

Comment thread src/agent/agent-interface.ts Outdated
? require
: createRequire(process.argv[1] ?? `${process.cwd()}/`);
// ESM has no bare `require`: resolve from the entry script.
const resolver = createRequire(process.argv[1] ?? `${process.cwd()}/`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

Can you confirm this still finds the SDK on a global install? The removed comment said only tsx dev runs lacked a bare require, so built runs used to resolve from the bundle itself. Now resolution always starts from process.argv[1], and Node does not realpath that. With npm i -g or pnpm, argv[1] is the bin symlink or shim outside the wizard's own node_modules, so resolve('@anthropic-ai/claude-agent-sdk') could fail and every anthropic-harness run would crash.

createRequire(import.meta.url) resolves from the real bundle path and works under tsx too. harness/pi/mcp.ts already uses import.meta.url.

@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from e278aff to 58ef33e Compare October 2, 2026 16:47
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from 58ef33e to 97d1225 Compare October 2, 2026 20:50
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from 97d1225 to 3ba2baa Compare October 3, 2026 20:40

@edwinyjlim edwinyjlim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of #1378 at 3ba2baa4. Items outside this PR's diff lines:

[P2] The Pi harness's Bash gate drops the --debug allow/deny lines the PR says now flow as log events
src/agent/runner/harness/pi/security.ts:386

Before, wizardCanUseTool called the global debug() itself, so a --debug run on either harness showed "Allowing/Denying bash command". Now the lines depend on a caller-supplied onDebug. The Anthropic path passes one at agent-interface.ts:1199; the Pi path, the default harness, passes none, so Pi runs lose them from the screen. They remain in the log file.

Suggested fix: Add onDebug?: (line: string) => void to the Pi tool-gate context, pass it at line 386, and have createToolGate in pi/index.ts supply (line) => emit({ kind: 'log', level: 'info', message: line }) when the run's debug flag is set. If the shared-code lines are meant to leave --debug output for good, say so in the body.


Drafted with Claude Code from a review of the whole Release C stack, re-verified at the stack tip 2e31e438. Line numbers are at this PR's head.

Comment thread src/shared/constants.ts
* (`javascript_node`, `python`, `ruby`) and KMP, which has no replay support
* yet.
*/
export const REPLAY_VISION_SUPPORTED: ReadonlySet<Integration> = new Set([

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Program knowledge lands in the shared layer: REPLAY_VISION_SUPPORTED and SETUP_REPORT_FILE

Which integrations replay-vision supports is a replay-vision decision, and the report name belongs to the integration program. They moved so two TUI decks could import them, but the TUI may import @programs. AGENTS.md's first rule is that product knowledge stays out of infrastructure code.

Suggested fix: Keep the constants in their programs and re-export them from src/programs/index.ts, as TASK_OUTCOMES_KEY is; import @programs from error-tracking/deck/tips.ts:4 and SelfDrivingHandoffScreen.tsx:15.

// refactor.
export function configureGatewayFromCIEnvironment(
/** Use this run's pre-issued gateway token, or mint when it has none; the keyed mint cache stays. */
export function useRunGatewayCredential(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] useRunGatewayCredential clears the module-global CI credential for every run that has none

ciAuth is module state. Two runAgent calls alive in one process would have the later non-CI run null out the earlier CI run's credential. The wizard runs one agent at a time today, so this is a latent hazard of the new per-run contract.

Suggested fix: Return the credential into the bootstrap result and have gatewayAuth take it, or document that runAgent calls are serialised per process.

…e session store

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99
gewenyu99 force-pushed the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch from 3ba2baa to 92fa6f7 Compare October 5, 2026 09:47
@gewenyu99
gewenyu99 requested review from a team as code owners October 5, 2026 09:47
@gewenyu99
gewenyu99 requested review from TueHaulund, ablaszkiewicz, fasyy612, hpouillot and ksvat and removed request for a team October 5, 2026 09:47
@gewenyu99 gewenyu99 changed the title refactor: take each run's route from its program and drop the global debug sink refactor: move the agent, programs, tui, hosts, tools and cli onto the session store Oct 5, 2026
@gewenyu99
gewenyu99 added this pull request to stack #1413 October 5, 2026 09:48
@gewenyu99
gewenyu99 merged commit 62e06ba into main Oct 5, 2026
21 of 22 checks passed
@gewenyu99
gewenyu99 deleted the posthog/functional-r9-05-take-each-run-s-route-from-its-program-a branch October 5, 2026 09:50
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.

3 participants