Skip to content

fix(pi): review fixes — typed effort, live model fallback, menu-declared variants, shared session machinery#907

Merged
gewenyu99 merged 8 commits into
experiment/orchestrator-pi-runtaskfrom
posthog-code/orchestrator-pi-review-fixes
Jul 15, 2026
Merged

fix(pi): review fixes — typed effort, live model fallback, menu-declared variants, shared session machinery#907
gewenyu99 merged 8 commits into
experiment/orchestrator-pi-runtaskfrom
posthog-code/orchestrator-pi-review-fixes

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Review fixes for #853, targeting its branch. Pairs with PostHog/context-mill#239, which emits the group/framework/default menu fields the resolver here consumes — the two land on their experiment branches together.

Changes

  • Typed effort. effort_pi/effort_sdk are validated against ThinkingLevel in parseAgentPrompt — a typo in remote frontmatter is logged and dropped (table default applies) instead of riding into a session through the as ThinkingLevel cast (removed from gateway.ts). The value stays typed through TaskRunInputs.
  • Dead default removed. taskModelSpec no longer bakes in DEFAULT_TASK_MODEL, so the call sites' existing ?? pick.model fallback is live: a pi task whose prompt names no model_pi degrades to the switchboard's pi model, not sonnet-over-pi.
  • Menu-declared variant resolution. FRAMEWORK_VARIANT_ALIASES and the startsWith guessing are gone; resolveSkillVariantId is an exact lookup on the menu's group/framework/default fields (context-mill owns the vocabulary). Task skills preflight after the registry loads — a miss logs and fires orchestrator skill variant missing before any agent runs. The test fixture is pinned from the real built skill-menu.json.
  • Flow fallback. loadAgentRegistry passes the menu entry's flow into parseAgentPrompt so a prompt with missing frontmatter flow isn't silently dropped (context-mill's build is now strict about the key, too).

Testing

pnpm build && pnpm test — 99 files, 1344 tests green; lint clean.


Created with PostHog Code

…red variants, shared session machinery

Follow-ups from the review of #853:

- effort is a ThinkingLevel end to end, validated at the parse boundary:
  a typo'd effort_pi in remote frontmatter is logged and dropped (the
  model-table default applies) instead of riding into a session through a
  cast. promptModelFor/taskModelSpec take the Harness enum, not a string.
- taskModelSpec no longer bakes in DEFAULT_TASK_MODEL, which made the call
  sites' `?? pick.model` dead code: a pi task whose prompt names no
  model_pi now degrades to the switchboard's pi model, not sonnet-over-pi.
  Each harness falls back within its own column.
- terra reverts to low in MODEL_CAPABILITIES: the table tunes the linear
  run only, and orchestrator agents already carry their own effort via
  prompt frontmatter (which overrides the table), so the medium row was a
  side effect on linear runs that the orchestrator never needed.
- FRAMEWORK_VARIANT_ALIASES and the startsWith heuristic are gone:
  skill-menu.json entries now declare `group`/`framework`/`default`
  (context-mill PR on experiment/orchestrator), so variant resolution is
  an exact lookup, misses preflight before any agent runs (log + a new
  `orchestrator skill variant missing` capture), and the variant test
  pins the real menu contract instead of a fixture that mirrors the code.
- new pi/shared.ts holds the session machinery both entry points use —
  gateway/registry wiring, hermetic loader, coding-tool factories, the
  session event watcher, error classification, usage capture — so run()
  and runPiTask() are configurations of one implementation and the 429
  sniff / analytics shape can't drift. The linear run gains the parseable
  usage log line; the per-task line drops its modelId-as-task fallback.
- loadAgentRegistry passes the menu entry's flow into parseAgentPrompt as
  the frontmatter fallback, so a prompt the menu placed in a flow is never
  silently dropped by the registry filter.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
@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 basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /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 mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
The medium row is terra's default for any run that doesn't name an effort
itself; the "linear isolation" concern was hypothetical (linear doesn't run
terra) and the revert only degraded the real default. models.ts and
switchboard.test.ts terra lines are back to the base branch verbatim.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
The switchboard is the single decision point; a shared layer between it and
the runners is a place decisions could creep into. index.ts, task.ts, and
subagent.ts return to the base branch verbatim; the typed effort in
gateway.ts/types.ts stays.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
- taskModelSpec takes the full HarnessPick and absorbs the switchboard
  fallback, so the enqueue-override -> frontmatter -> pick precedence lives
  in one place instead of being restated at each call site.
- onTransition builds its analytics base lazily — enqueue/requeue never
  read it, and resolveHarness logs per call.
- resolveReferenceSkillId (one-line wrapper, single call site) inlined.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
Drops the /simplify reshaping (HarnessPick signature, lazy analytics base,
wrapper inlining) and the Harness-enum param typing — taskModelSpec keeps
its base shape minus the baked-in default, and call sites keep their
existing pick fallback.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
…s dropped

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
Preflight already logs + captures a missing skill variant on every build.
Now, in dev and CI builds, it also throws so the gap fails a test run
loudly instead of passing as a silent skill-less (zero-diff) integration.
The throw is gated behind !IS_PRODUCTION_BUILD, which tsdown inlines to a
literal, so it is tree-shaken out of the published bundle — verified: the
throw string is absent from `pnpm build` output and present in
`pnpm build:ci` output, while the log + analytics capture survive in both.

Generated-By: PostHog Code
Task-Id: fafc230d-6f14-4e4d-9462-0e7f18a1eec1
@gewenyu99
gewenyu99 marked this pull request as ready for review July 15, 2026 17:42
@gewenyu99
gewenyu99 requested a review from a team as a code owner July 15, 2026 17:42
@gewenyu99
gewenyu99 merged commit de41ed5 into experiment/orchestrator-pi-runtask Jul 15, 2026
8 checks passed
@gewenyu99
gewenyu99 deleted the posthog-code/orchestrator-pi-review-fixes branch July 15, 2026 17:43
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