Skip to content

feat(tasks): Accept context window and fast mode on runs - #73803

Merged
charlesvien merged 12 commits into
masterfrom
feat/task-run-context-window-fast-mode
Jul 27, 2026
Merged

feat(tasks): Accept context window and fast mode on runs#73803
charlesvien merged 12 commits into
masterfrom
feat/task-run-context-window-fast-mode

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 27, 2026

Copy link
Copy Markdown
Member

Problem

The PostHog Code desktop app now offers three Claude runtime settings that cloud task runs can't honor: the ultracode reasoning tier, a context window choice (200k vs 1M) and fast mode. The tasks API rejects the new effort and has no way to forward the two new toggles to the sandbox agent.

Changes

  • Added ULTRACODE to ReasoningEffort and PUBLIC_REASONING_EFFORTS, and appended it to the extended Claude models in CLAUDE_REASONING_EFFORTS_BY_MODEL. Codex sets are untouched.
  • TaskRunCreateRequestSerializer and TaskRunBootstrapCreateRequestSerializer accept optional context_window ("200k" | "1m") and fast_mode (bool), stored in run state alongside reasoning_effort (no migration, JSON state).
  • The values flow through TaskProcessingContext and start_agent_server into the sandbox launch env as POSTHOG_CODE_CONTEXT_WINDOW and POSTHOG_CODE_FAST_MODE, following the reasoning_effort pattern in both docker and modal sandboxes.

Companion client PR: PostHog/code#3821 (sends the new fields; deploy this PR first).

How did you test this code?

Automated only, run by the agent: ruff check and ruff format clean on all changed files; targeted pytest suites all passing, including the full products/tasks/backend/tests/test_api.py (618 passed), test_docker_sandbox.py and test_modal_sandbox.py (172), test_start_agent_server.py (64), facade tests (81) and the reasoning-effort serializer subset re-run after the final enum change (16 passed). New values are exercised by the existing choice/validation tests via the widened enums. No manual testing was performed.

Automatic notifications

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

Docs update

N/A

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Bundle size — 🔺 +104 B (+0.0%)

Uncompressed size of every built .js bundle, compared against the base branch.

Total: 65.15 MiB · 🔺 +104 B (+0.0%)

No file changed by more than 1000 B.

Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report

Eager graph — within budget

How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.

Root Eager (shipped) Δ vs base Budget
entry (logged-out pages, app bootstrap)
src/index.tsx
1.24 MiB · 22 files no change ███░░░░░░░ 27.6% of 4.51 MiB
authenticated shell (every logged-in page)
src/scenes/AuthenticatedShell.tsx
8.08 MiB · 3,013 files no change ████████░░ 83.2% of 9.71 MiB

🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx

Largest files eagerly shipped from src/index.tsx
Size File
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
24.6 KiB ../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
6.3 KiB ../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
4.5 KiB ../node_modules/.pnpm/@jspm+core@2.1.0/node_modules/@jspm/core/nodelibs/browser/process.js
3.9 KiB ../node_modules/.pnpm/scheduler@0.23.2/node_modules/scheduler/cjs/scheduler.production.min.js
1.4 KiB ../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
1.3 KiB src/RootErrorBoundary.tsx
912 B ../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
789 B src/scenes/ChunkLoadErrorBoundary.tsx
762 B src/index.tsx
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
Size File
281.5 KiB ../node_modules/.pnpm/posthog-js@1.407.3/node_modules/posthog-js/dist/rrweb.js
267.7 KiB ../node_modules/.pnpm/@posthog+icons@0.38.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js
234.2 KiB src/taxonomy/core-filter-definitions-by-group.json
226.4 KiB ../node_modules/.pnpm/posthog-js@1.407.3/node_modules/posthog-js/dist/module.js
154.3 KiB ../node_modules/.pnpm/re2js@0.4.1/node_modules/re2js/build/index.esm.js
126.8 KiB ../node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/cjs/react-dom.production.min.js
105.1 KiB src/lib/api.ts
94.0 KiB ../packages/quill/packages/quill/dist/index.js
93.3 KiB ../node_modules/.pnpm/prosemirror-view@1.40.1/node_modules/prosemirror-view/dist/index.js
90.6 KiB ../node_modules/.pnpm/@tiptap+core@3.20.6_@tiptap+pm@3.20.6/node_modules/@tiptap/core/dist/index.js

Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479

Toolbar bundle — eager 2.18 MiB within budget

What the toolbar ships to customer pages, measured from the esbuild output (minified, post-tree-shake). The eager set is the entry plus everything statically imported from it — fetched before any feature runs; deferred chunks load lazily. The eager guardrail is 5.72 MiB. Each output file must also stay below 10 MB, where CloudFront stops compressing it. The module boundary is enforced separately by check-toolbar-graph.

Metric Size Δ vs base Budget
Eager (shipped)
entry + static imports
2.18 MiB · 17 files no change ████░░░░░░ 38.2% of 5.72 MiB
Deferred (lazy) 2.07 MiB · 33 files no change n/a — loads on demand
Loader dist/toolbar.js 1.1 KiB no change █░░░░░░░░░ 5.8% of 19.5 KiB
Largest eagerly-shipped chunks
Size File
716.4 KiB dist/toolbar/toolbar-app-V5IF6GYH.css
545.6 KiB dist/toolbar/chunk-chunk-FXPCABFT.js
484.3 KiB dist/toolbar/chunk-chunk-6XXSRP4X.js
133.6 KiB dist/toolbar/chunk-chunk-IPCZ6XI2.js
131.8 KiB dist/toolbar/chunk-chunk-T5KY5WYR.js
71.0 KiB dist/toolbar/toolbar-app-QQPRCZD2.js
69.0 KiB dist/toolbar/chunk-chunk-27JL52RE.js
35.6 KiB dist/toolbar/chunk-chunk-MA3DSLUQ.js
20.9 KiB dist/toolbar/chunk-chunk-TJW7UT6L.js
12.2 KiB dist/toolbar/chunk-chunk-PIK3PADE.js

Posted automatically by check-toolbar-size · sizes are toolbar output bytes (shipped, post-tree-shake) from the esbuild metafile

Dist folder size — 🔺 +6.0 KiB (+0.0%)

Total size of the built frontend/dist folder (all assets), compared against the base branch.

Total: 1359.83 MiB · 🔺 +6.0 KiB (+0.0%)

⚠️ Backend coverage — 95.0% of changed backend lines covered — 4 uncovered

🧪 Backend test coverage

Patch coverage — changed backend lines (products + core): ███████████████████░ 95.0% (91 / 95)

File Patch Uncovered changed lines
products/tasks/backend/temporal/process_task/activities/get_task_processing_context.py 50.0% 163–164, 168–169

🤖 Agents: add a test covering the lines above, or note why under "How did you test this code?". Machine-readable gap list: the patch-coverage artifact on this run (gh run download 30299791453 -n patch-coverage), or the coverage-data block at the end of this comment.

Per-product line coverage (touched products)
Product Coverage Lines
demo ███████████░░░░░░░░░ 56.2% 1,497 / 2,663
tasks ██████████████░░░░░░ 69.6% 31,078 / 44,641
signals ████████████████░░░░ 80.5% 22,802 / 28,332
cdp ████████████████░░░░ 81.0% 3,146 / 3,883
data_modeling █████████████████░░░ 85.1% 7,287 / 8,560
notebooks █████████████████░░░ 85.7% 7,527 / 8,787
agent_platform █████████████████░░░ 86.4% 3,807 / 4,405
actions █████████████████░░░ 86.6% 717 / 828
cohorts ██████████████████░░ 87.8% 4,489 / 5,115
product_tours ██████████████████░░ 87.9% 1,303 / 1,482
data_warehouse ██████████████████░░ 88.2% 12,079 / 13,689
exports ██████████████████░░ 88.4% 6,950 / 7,862
dashboards ██████████████████░░ 89.4% 5,983 / 6,693
conversations ██████████████████░░ 89.4% 17,007 / 19,021
engineering_analytics ██████████████████░░ 89.4% 6,441 / 7,202
alerts ██████████████████░░ 90.1% 4,218 / 4,681
mcp_analytics ██████████████████░░ 90.1% 2,879 / 3,194
error_tracking ██████████████████░░ 90.2% 10,567 / 11,710
streamlit_apps ██████████████████░░ 90.4% 2,503 / 2,769
slack_app ██████████████████░░ 91.0% 9,075 / 9,978
marketing_analytics ██████████████████░░ 91.1% 11,905 / 13,074
stamphog ██████████████████░░ 91.1% 4,056 / 4,450
product_analytics ███████████████████░ 92.5% 5,849 / 6,321
early_access_features ███████████████████░ 92.6% 1,287 / 1,390
ai_observability ███████████████████░ 92.8% 15,228 / 16,409
surveys ███████████████████░ 93.0% 5,769 / 6,201
web_analytics ███████████████████░ 93.2% 14,826 / 15,906
posthog_ai ███████████████████░ 93.2% 1,326 / 1,422
approvals ███████████████████░ 93.3% 3,437 / 3,682
reminders ███████████████████░ 93.4% 468 / 501
workflows ███████████████████░ 93.9% 6,871 / 7,321
endpoints ███████████████████░ 94.2% 8,655 / 9,192
skills ███████████████████░ 94.6% 3,158 / 3,337
review_hog ███████████████████░ 94.6% 6,903 / 7,294
logs ███████████████████░ 95.4% 10,119 / 10,609
experiments ███████████████████░ 95.8% 25,402 / 26,522
annotations ███████████████████░ 96.2% 732 / 761
revenue_analytics ███████████████████░ 96.3% 1,887 / 1,960
replay_vision ███████████████████░ 96.3% 15,628 / 16,221
feature_flags ███████████████████░ 96.4% 17,372 / 18,025
user_interviews ███████████████████░ 96.5% 2,638 / 2,734
warehouse_sources ███████████████████░ 97.2% 341,577 / 351,481
customer_analytics ███████████████████░ 97.2% 9,757 / 10,038
data_catalog ████████████████████ 97.6% 2,469 / 2,530
pulse ████████████████████ 98.4% 2,017 / 2,049

Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.

⚠️ MCP snapshots — 3 updated (3 modified, 0 added, 0 deleted)

Snapshots: MCP unit test snapshots updated

Changes: 3 snapshots (3 modified, 0 added, 0 deleted)

What this means:

  • Snapshots have been automatically updated to match current output

Next steps:

  • Review the changes to ensure they're intentional
  • If unexpected, investigate what caused the output to change

Review snapshot changes →

@charlesvien
charlesvien marked this pull request as ready for review July 27, 2026 06:02
@github-actions
github-actions Bot requested a deployment to preview-pr-73803 July 27, 2026 06:03 In progress
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

🦔 Hogbox preview · ✅ ready

▶ Open the preview

🔑 Login test@posthog.com / 12345678 (demo data)
🧩 Running this PR's backend and frontend, on the PostHog :master base
🔗 Link stable across rebuilds — a re-push swaps the box underneath, the URL stays
🔒 Access tailnet only (PostHog VPN)
🛠️ Admin inspect & debug state in hogland
💤 Idle sleeps after ~30 min idle (snapshot to S3, zero node cost) and wakes on your next visit in ~30s, behind a brief "waking up" screen

commit c18d581 · box box-6222de93f989 · ready in 799s (push → usable) · build log · rebuilds on every push, torn down on close

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 27, 2026 06:03
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
products/tasks/backend/facade/api.py:4454-4455
**Warm runs discard new settings**

When an idling warm run matches the existing compatibility fields, this path activates and returns it before reading `context_window` or `fast_mode`, causing the agent to start without the runtime settings requested by the user.

### Issue 2 of 2
products/tasks/backend/facade/api.py:4544-4545
**Resume drops runtime settings**

When a configured run is resumed without explicitly resending these optional fields, the resume inheritance map omits `context_window` and `fast_mode`, causing the successor agent to launch with default settings instead of preserving the predecessor's configuration.

Reviews (1): Last reviewed commit: "chore: update OpenAPI generated types" | Re-trigger Greptile

Comment thread products/tasks/backend/facade/api.py
Comment thread products/tasks/backend/facade/api.py
@charlesvien
charlesvien force-pushed the feat/task-run-context-window-fast-mode branch from ea9105d to 425bf14 Compare July 27, 2026 19:23
@charlesvien charlesvien added the stamphog Request AI approval (no full review) label Jul 27, 2026
stamphog[bot]
stamphog Bot previously approved these changes Jul 27, 2026

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

Additive, backward-compatible feature (optional context_window/fast_mode fields threaded through task run creation, resume, and sandbox launch); the two P1 logic bugs Greptile flagged (warm-run reuse and resume inheritance ignoring the new fields) are both fixed in this diff and covered by new dedicated tests, with no unresolved comments or holds.

  • Author wrote 23% of the modified lines and has 15 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 200L, 11F substantive, 599L/21F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (599L, 21F, two-areas, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ c1c720e · reviewed head 425bf14

@charlesvien
charlesvien enabled auto-merge (squash) July 27, 2026 19:38
@posthog

posthog Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Visual changes approved by @charlesvien — baseline updated in c18d581.

View this run in PostHog

4 changed.

4 updated
Run: 0ebf9952-602a-4907-8c8e-bbc83037e75e

Co-authored-by: charlesvien <5378415+charlesvien@users.noreply.github.com>
@stamphog
stamphog Bot dismissed their stale review July 27, 2026 19:48

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@charlesvien
charlesvien disabled auto-merge July 27, 2026 19:52

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

Additive-only API/enum change (new optional context_window/fast_mode fields, new ultracode effort value) with no schema migration; the two Greptile P1 findings about warm-run matching and resume inheritance dropping the new fields are both fixed in the current diff and covered by new tests, giving independent assurance over the public-API surface touched.

  • Author wrote 23% of the modified lines and has 17 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 208L, 12F substantive, 607L/22F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1d-complex (607L, 22F, cross-cutting, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ f4290e2 · reviewed head c18d581

@charlesvien
charlesvien merged commit 4e3773e into master Jul 27, 2026
253 checks passed
@charlesvien
charlesvien deleted the feat/task-run-context-window-fast-mode branch July 27, 2026 20:13
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 27, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-27 20:49 UTC Run
prod-us ✅ Deployed 2026-07-27 21:30 UTC Run
prod-eu ✅ Deployed 2026-07-27 21:33 UTC Run

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

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant