Skip to content

fix(pi): preserve cloud model selection - #4032

Merged
trunk-io[bot] merged 1 commit into
mainfrom
fix/pi-cloud-model-controls
Jul 31, 2026
Merged

fix(pi): preserve cloud model selection#4032
trunk-io[bot] merged 1 commit into
mainfrom
fix/pi-cloud-model-controls

Conversation

@jonathanlab

@jonathanlab jonathanlab commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Problem

Cloud Pi tasks did not use the selected model at start. After a renderer reload, the Pi picker could show only the saved model.

Cloudflare GLM 5.2 also failed before responding because LiteLLM interpreted the client-side web_search tool as native web search and forwarded unsupported web_search_options.

Changes

  • Send the selected model and thinking level when a cloud Pi task starts.
  • Reapply the deferred model and thinking level after a cloud sandbox retry replaces the session.
  • Use the PostHog provider catalog for Pi pickers.
  • Add the harness source alias to the web Vite build.
  • Save model changes when a cloud sandbox is inactive. Apply them before the next prompt starts the sandbox.
  • Move PostHog Pi catalog code from the agent package to the provider extension.
  • Rename the client-side web search tool to posthog_web_search so LiteLLM does not treat it as a native web-search tool for GLM.
  • Preserve legacy web_search subagent tool settings by translating them to the new tool name.

Validation

  • pnpm --filter @posthog/harness build
  • pnpm --filter @posthog/harness test
  • pnpm --filter @posthog/core test -- piSessionController.test.ts
  • pnpm --filter @posthog/web build

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@jonathanlab jonathanlab self-assigned this Jul 31, 2026
@trunk-io

trunk-io Bot commented Jul 31, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/pi-sessions/PiSessionView.tsx

Reviewed by React Doctor for commit e8f8e2a.

@jonathanlab
jonathanlab marked this pull request as ready for review July 31, 2026 09:35
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/core/src/pi-runtime/piSessionController.ts, line 1146-1148 (link)

    P1 Deferred config lost on retry

    When the initial send fails with "No active sandbox", this retry replaces the session without reapplying the deferred model and thinking level. The prompt then runs with the previous configuration, and the successful submission causes the UI to clear the user's pending selection.

    Context Used: CLAUDE.md (source)

    Knowledge Base Used: Shared foundation: packages/shared, packages/core, packages/di

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/core/src/pi-runtime/piSessionController.ts
    Line: 1146-1148
    
    Comment:
    **Deferred config lost on retry**
    
    When the initial send fails with "No active sandbox", this retry replaces the session without reapplying the deferred model and thinking level. The prompt then runs with the previous configuration, and the successful submission causes the UI to clear the user's pending selection.
    
    **Context Used:** CLAUDE.md ([source](https://github.com/posthog/code/blob/main/CLAUDE.md))
    
    **Knowledge Base Used:** [Shared foundation: `packages/shared`, `packages/core`, `packages/di`](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/shared-foundation.md)
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Prompt To Fix All With AI
### Issue 1
packages/core/src/pi-runtime/piSessionController.ts:1146-1148
**Deferred config lost on retry**

When the initial send fails with "No active sandbox", this retry replaces the session without reapplying the deferred model and thinking level. The prompt then runs with the previous configuration, and the successful submission causes the UI to clear the user's pending selection.

### Issue 2
apps/web/src/web-host-router.ts:7
**Harness import bypasses web alias**

The web production build resolves workspace subpaths through `posthogSrcAliases` because their fallback exports do not resolve under Rollup, but the new `@posthog/harness` import has no corresponding alias. As a result, the web build cannot resolve this module.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(pi): preserve cloud model selection" | Re-trigger Greptile

import { TEAM_SKILLS_SERVICE } from "@posthog/core/skills/identifiers";
import type { TeamSkillsService } from "@posthog/core/skills/teamSkillsService";
import { resolveService } from "@posthog/di/container";
import { fetchPosthogPiModelCatalog } from "@posthog/harness/extensions/posthog-provider/model-catalog";

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.

P1 Harness import bypasses web alias

The web production build resolves workspace subpaths through posthogSrcAliases because their fallback exports do not resolve under Rollup, but the new @posthog/harness import has no corresponding alias. As a result, the web build cannot resolve this module.

Context Used: CLAUDE.md (source)

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/src/web-host-router.ts
Line: 7

Comment:
**Harness import bypasses web alias**

The web production build resolves workspace subpaths through `posthogSrcAliases` because their fallback exports do not resolve under Rollup, but the new `@posthog/harness` import has no corresponding alias. As a result, the web build cannot resolve this module.

**Context Used:** CLAUDE.md ([source](https://github.com/posthog/code/blob/main/CLAUDE.md))

**Knowledge Base Used:**
- [apps/web and apps/mobile: browser and mobile clients](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/client-apps-web-mobile.md)
- [Harness (`hog`/`harness` CLI)](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/harness-cli.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@jonathanlab
jonathanlab force-pushed the fix/pi-cloud-model-controls branch from a1a9c8b to e8f8e2a Compare July 31, 2026 09:47
@tatoalo

tatoalo commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Cloudflare GLM 5.2

Is this a worker limitation on CF side or model-wide? meaning, will this impact the baseten rollout as well?

@jonathanlab

Copy link
Copy Markdown
Contributor Author

Cloudflare GLM 5.2

Is this a worker limitation on CF side or model-wide? meaning, will this impact the baseten rollout as well?

Cloudflare specific limitation

@trunk-io
trunk-io Bot merged commit 32c0189 into main Jul 31, 2026
34 checks passed
@trunk-io
trunk-io Bot deleted the fix/pi-cloud-model-controls branch July 31, 2026 10:25
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