Skip to content

perf(integration): switch to gpt-6.2-sol low, pre-install AIO skill, and isolate linear Task tools - #1617

Open
gewenyu99 wants to merge 6 commits into
mainfrom
perf/aio-runtime-opt
Open

gewenyu99 wants to merge 6 commits into
mainfrom
perf/aio-runtime-opt

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

posthog-integration and ai-observability are slow and expensive on gpt-5.6-terra. Runtime skill discovery and solo TaskUpdate calls waste turns, and linear-only Task* tools leak into orchestrator runs.

Changes

posthog-integration should run ~25% faster (~65% lower LLM cost) and standalone ai-observability ~50% faster once the 600s stream stall is fixed.

  • Switch posthog-integration and ai-observability to gpt-6.2-sol at low effort.
  • Pre-install the ai-observability skill when the manifest maps to one framework or provider. Match standalone guardrails to the orchestrator task.
  • Limit Task* tools and task-list instructions to linear runs, and batch TaskUpdate calls with real work.

4 of 10 gpt-6.2-sol orchestrator runs hit a 600s mid-stream stall, so this PR stays in draft (see benchmark comment).

Test plan

  • pnpm typecheck, pnpm build, pnpm test, and pnpm lint pass.
  • Benchmarked v3.0.0 against this branch on 6 integration repos and 5 standalone AIO repos (see comment).

@gewenyu99

gewenyu99 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Non-stalled runs cut wall-clock time by 16% to 33% on posthog-integration (median -25%, cost -56% to -71%) and 34% to 61% on standalone ai-observability (median -53%). All runs compare this branch against v3.0.0 with flag 779412 off locally.

Integration benchmarks

Repo Stack Before speed After speed Delta Before score After score Cost
tiny-node Node HTTP 232s 178s (r2) -23% 8/8 8/8 (r1 stalled) $1.36 -> $0.60
astro-ssr-docs Astro 5 SSR 311s 208s (r2) -33% 6/10, build PASS 8/8, build PASS (r1 stalled) $2.12 -> $0.72
fastapi3-ai-saas FastAPI 305s 229s -25% 9/9, compile PASS 8/8, compile PASS $2.73 -> $0.79
CMSaasStarter SvelteKit 2 406s 307s (r3) -24% 9/9, build PASS 9/9, build PASS (r1, r2 stalled) $2.97 -> $0.98
cloudflare-agents-starter CF Workers + AI SDK 379s 277s -27% 9/9, tsc FAIL 9/9, tsc PASS $2.87 -> $0.85
15-app-router-saas Next.js 15 + Stripe 345s 292s -16% 9/9, tsc PASS 9/9, tsc PASS $2.94 -> $0.94

Standalone AIO benchmarks

Repo Stack Before speed After speed Delta Before score After score
cloudflare-agents-starter CF Workers + AI SDK 245s 116s -53% PASS PASS
openai-node-weather Node OpenAI ^4.77 191s 83s -56% FAIL PASS
openai-python-docs-rag Python OpenAI RAG 142s 94s -34% PASS PASS
manual-node-http-chat Raw HTTP + posthog-node@^4.2 175s 69s -61% PASS PASS
hard-monorepo-ai pnpm monorepo 139s 88s -37% FAIL PASS

The 600s stall

4 of 10 gpt-6.2-sol orchestrator runs hung for 600s mid-stream on ai-gateway (http_status=200, context deadline exceeded), vs 0/6 on v3.0.0 and 0/8 standalone. Before marking ready, add a stream idle timeout or retry (#1363) or test gpt-6-sol as a fallback (0 deadline errors in 2,988 calls).

@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/go-sdk
  • /wizard-ci mcp-analytics/python-sdk
  • /wizard-ci mcp-analytics/ruby-sdk
  • /wizard-ci mcp-analytics/rust-sdk
  • /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.

Comment thread src/shared/constants.ts
export const GPT5_6_SOL_MODEL = 'openai/gpt-5.6-sol';
export const GPT6_SOL_MODEL = 'openai/gpt-6-sol';
export const GPT6_2_SOL_MODEL = 'openai/gpt-6.2-sol';

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added gpt-6.2-sol to wizard-gateway-allowlist (flag 960134, v7). Follow up in PostHog/posthog to add it to WIZARD_DEFAULT_MODELS in posthog/llm/wizard_gateway_token.py.

model_pi: openai/gpt-5.6-sol
effort_pi: medium
model_pi: openai/gpt-6.2-sol
effort_pi: low

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

wizard-orchestrator-override (flag 779412, 100% sol-review) overrides review to gpt-5.6-sol medium in prod, so turn it off or update it on rollout.

@gewenyu99 gewenyu99 changed the title perf(integration,aio): switch to gpt-6.2-sol low, pre-install AIO skill, and isolate linear Task tools perf(integration): switch to gpt-6.2-sol low, pre-install AIO skill, and isolate linear Task tools Nov 27, 2026
@gewenyu99
gewenyu99 marked this pull request as ready for review November 27, 2026 15:41
@gewenyu99
gewenyu99 requested review from a team as code owners November 27, 2026 15:41
@veria-ai

veria-ai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@posthog-security-review-bot posthog-security-review-bot Bot added the security-review Request a security review label Nov 27, 2026
@posthog-security-review-bot

posthog-security-review-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

✅ Security review complete — 70d338ac7502

1 finding posted as a review, in 9 min.

Add the security-review label to run again on the latest commit.

@posthog-security-review-bot posthog-security-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agent-driven security review - findings inline.

}
};

const req = readProjectFile(join(installDir, 'requirements.txt'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A symlinked manifest can block AI Observability preflight indefinitely

low non-security-availability (confidence 5/5)

Details

config.run in src/programs/ai-observability/index.ts:65-66 now invokes this resolver synchronously, and detectUnambiguousAioSkill calls parsePyDeps even for Node-only projects. These manifest reads use readProjectFile, whose implementation at src/shared/utils/bounded-fs.ts:302-303 follows symlinks and checks only stat.size before readFileSync. Pipes and terminal devices report size zero, so the byte cap does not bound the read. The preceding discovery walk skips symlinks; its protection does not carry over to these new direct reads.

Impact — a repository writer can add requirements.txt -> /dev/stdin alongside a normal package.json declaring openai. Running wizard ai-observability in an interactive terminal then blocks the main thread before skill installation or the optional fallback. An offline probe of the copied resolver on a real PTY remained blocked after 1.5 seconds and returned only after terminal EOF. Ordinary asynchronous cancellation cannot execute while this synchronous read is blocked. This affects the local run's availability, not credential or tenant isolation.

Fix — use the existing safeReadFile helper for all three root manifests, or otherwise reject non-regular targets before reading and enforce a bounded read. Add a regression test for a symlink to a terminal or FIFO so this optional optimization falls back rather than blocking.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 4ab3fc0. Switched detect-skill.ts manifest and scan reads to safeReadFile, added the same stat.isFile() guard to readProjectFile, and added a FIFO symlink regression test.

@posthog-security-review-bot posthog-security-review-bot Bot removed the security-review Request a security review label Nov 27, 2026

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

Verdict: REQUEST CHANGES

On rollout order: the model switch has no automatic fallback in code. posthog-integration and ai-observability hardcode GPT6_2_SOL_MODEL at low, and nothing retries on another model or times out an idle stream, so a stalled run still sits for 600s. The new gpt-6-2-sol scheme entry means flag 779412 can steer runs between models without a release, but that is a manual lever, not a fallback. Two parts don't depend on the model and could ship ahead of it: the Task-tool isolation and the batched TaskUpdate prompt changes. The AIO pre-install needs the routing fixes in the inline comments first.

See inline comments.

Automated review by Glimmervoid. Not written by a human

parseRequirementsTxt,
} from '@services/project-discovery';

const NODE_FRAMEWORK_SKILLS: ReadonlyArray<readonly [string, string]> = [

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.

[architecture/twin-logic] HIGH

This table copies context-mill's AIO routing (ai-observability/references/1-begin.md) into the wizard, and the copy has already drifted. 1-begin.md:42 maps both mastra and @mastra/core to the Mastra variant, but line 30 here only knows @mastra/core, so a project with {mastra, openai} gets ai-observability-openai-node pre-installed. Azure has the same problem: config.yaml ships azure-openai-node and azure-openai-python, those projects use the plain openai package, and GATEWAY_OVERRIDE_RE doesn't match azure_endpoint, so they get the plain OpenAI skill plus a prompt telling the agent to skip load_skill_menu.

Nothing checks this copy against context-mill, and released wizards keep the old routing after every context-mill release. Could the package-to-variant mapping live in context-mill instead, as a packages: field per variant in config.yaml compiled into skill-menu.json? The wizard already fetches that menu, so it could resolve from it and keep only the ambiguity guards locally. If that's too big for this PR, add the mastra and Azure cases and treat the menu move as a follow-up.

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed the drift in 4ab3fc0. Added unscoped mastra to NODE_FRAMEWORK_SKILLS and added Azure OpenAI signals (AzureOpenAI, azure_endpoint, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, openai.azure.com) to GATEWAY_OVERRIDE_RE so Azure projects fall back to the menu. Moving the package mapping into context-mill's skill-menu.json is left as a follow-up.

docsUrl: 'https://posthog.com/docs/ai-observability',
spinnerMessage: 'Setting up AI Observability...',
estimatedDurationMinutes: 5,
run: (session) => {

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.

[convergent: code/contract + redteam/signal + architecture/one-way-compat] MEDIUM

Making run a function drops the AIO docs link from three readers that only check object-form runs: src/headless/run.ts:241, src/tui/services/wizard-spellbook.ts:75 and src/programs/program-runner/detect-program.ts:158 all do typeof config.run === 'object' ? config.run.docsUrl : undefined. ai-observability never sets session.frameworkConfig, so headless failures and the mint-failure spell book now link to https://posthog.com/docs instead of https://posthog.com/docs/ai-observability. A mint failure is likely while gpt-6.2-sol is still missing from WIZARD_DEFAULT_MODELS. Suggest a static top-level docsUrl on ProgramConfig that all three read, or keeping run an object and resolving the skill in a separate hook.

The 37 literal skill ids also aren't registered in context-mill's scripts/lib/wizard-skill-picks.js, which only lists integration-, spend-audit-, replay-vision-* and posthog-best-practices, so a variant rename passes context-mill's build. Released wizards would then hit skill-not-found, fall back through optionalSkill, and lose the speedup with only a logToFile line to show for it. Adding the ai-observability ids to that registry in the same rollout closes it.

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed the docsUrl contract in 4ab3fc0. Added static docsUrl to ProgramConfig (matching reportFile), set it on ai-observability, and updated src/headless/run.ts, src/tui/services/wizard-spellbook.ts, and src/programs/program-runner/detect-program.ts to read it. Registering the ai-observability-* IDs in context-mill's scripts/lib/wizard-skill-picks.js is tracked as a cross-repo follow-up.

['portkey-ai', 'ai-observability-portkey-node'],
];

const PYTHON_FRAMEWORK_SKILLS: ReadonlyArray<readonly [string, string]> = [

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.

[redteam/input-variant] MEDIUM

The header says this returns a skill only for a single unambiguous framework or provider, but split integration packages slip past it. A requirements.txt listing only langchain-openai and openai gives pyFrameworks=[] and pyProviders=['ai-observability-openai-python'], so line 254 pre-installs the raw OpenAI skill and the prompt says to skip the menu. The same happens with langchain-anthropic, langchain-community, llama-index-core, llama-index-llms-openai, and on Node with @langchain/openai.

The prompt does tell the agent to switch variants when a framework wraps the calls, so maybe that's enough. My read is that the resolver should not pre-install the wrong one in the first place: a prefix match on langchain-*, @langchain/* and llama-index-* as a framework hit, or returning undefined when one shows up, keeps the old "prefer the higher abstraction" rule working.

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 4ab3fc0. Added prefix matching for langchain-*, llama-index-*, @langchain/*, and @llamaindex/* (skipping exact matches like @langchain/langgraph) with unit tests so split packages resolve as frameworks rather than raw providers.


const GATEWAY_OVERRIDE_RE =
/\b(OPENAI_BASE_URL|baseURL|base_url)\b|api\.groq\.com|openrouter\.ai|api\.together\.xyz|localhost:11434/;
const CODE_EXTS = new Set(['.ts', '.tsx', '.js', '.mjs', '.cjs', '.py']);

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.

[redteam/bound-fails-open] MEDIUM

The gateway scan can miss the override and still say "no override". .env files are filtered out by CODE_EXTS, and the OpenAI SDKs read OPENAI_BASE_URL straight from the environment, so a project pointing at OpenRouter through .env gets the plain OpenAI skill. .jsx, .mts and .cts are skipped too. On top of that, walkProjectFiles stops at GATEWAY_SCAN_DEPTH = 5 but leaves complete true, so a baseURL six levels deep reads as absent. Suggest scanning .env*, .jsx, .mts and .cts, and treating a depth-truncated walk as incomplete so the resolver falls back to the menu.

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 4ab3fc0. Gateway scanning now covers .env*, .jsx, .mts, and .cts files, and walkProjectFiles supports incompleteOnDepthLimit: true so depth-truncated trees fall back to the menu.

).toEqual(new Set(['read']));
});

it('never admits linear Task* tools into orchestrator task tool sets', () => {

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.

[code/false-proof] MEDIUM

This test passes with the PR's production changes reverted: it asserts on allowedPiCodingTools, allowedPiWizardTools and allowedOrchestratorTools, and this diff changes none of them (no production file under src/agent/runner/harness/pi changes). The Task-tool isolation lives in resolveRunToolLists on the Anthropic SDK path, which initialize-agent.test.ts already covers. Suggest dropping it, or pointing it at code this PR changed.

Automated review by Glimmervoid. Not written by a human

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 4ab3fc0. Removed the unchanged pi tool-mapping test from task-tools.test.ts since initialize-agent.test.ts already covers resolveRunToolLists.

@Radu-Raicea
Radu-Raicea removed the request for review from a team November 27, 2026 16:36
@gewenyu99
gewenyu99 requested review from a team and johncwaters and removed request for johncwaters November 27, 2026 19:15
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.

2 participants