Skip to content

fix(loops): clamp stored reasoning efforts at fire time - #73424

Merged
charlesvien merged 2 commits into
masterfrom
fix/loop-effort-clamp
Jul 24, 2026
Merged

fix(loops): clamp stored reasoning efforts at fire time#73424
charlesvien merged 2 commits into
masterfrom
fix/loop-effort-clamp

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

A loop with no pinned model resolves its model per fire from DEFAULT_MODEL_BY_RUNTIME_ADAPTER, but the stored reasoning_effort was passed through untouched. If a future default change shrinks the supported effort set (e.g. a model that only takes high/max), existing unpinned loops would launch runs with an effort the runtime rejects. The serializer's model and effort validation also had no test coverage, including the exact 400 PostHog Code's loops picker was triggering with catalog ids like openai/gpt-5.6-sol.

This pairs with PostHog/code#3782, which fixes the loops model picker to only offer ids this API accepts. Defaults are unchanged: claude stays on claude-sonnet-5, codex on gpt-5.

Changes

  • fire_loop now clamps a stored reasoning effort to the effective model's supported set (via get_supported_reasoning_efforts), falling back to auto instead of launching a doomed run.
  • Comment on DEFAULT_MODEL_BY_RUNTIME_ADAPTER noting the posthog-code loops UI mirrors it.

How did you test this code?

Automated only, no manual testing. New parameterized tests: fire-time model/effort resolution in test_loop_runs.py (6 cases, catches an unpinned loop firing an unsupported effort, previously untested) and create-time model/effort validation in test_loops_api.py (5 cases, catches out-of-catalog model ids and effort/model mismatches, previously untested). Ran test_loop_runs.py, test_loops_api.py and process_task/tests/test_utils.py (242 passed), plus ruff check, ruff format and ty on the changed files.

Automatic notifications

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

Docs update

N/A

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written by Claude (Claude Code) while resolving loops model-picker feedback with Charles directing. An earlier revision made GLM-5.2 the claude loop default; Charles decided to keep the existing defaults, so this PR kept only the defensive clamp and the test coverage. The pre-commit hook hung on flox activation, so the commit used --no-verify after running the hook's checks (ruff lint, ruff format, ty) manually on the changed files, all clean.

@charlesvien charlesvien self-assigned this Jul 24, 2026
@charlesvien
charlesvien marked this pull request as ready for review July 24, 2026 06:24
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 24, 2026 06:25
@charlesvien charlesvien added the stamphog Request AI approval (no full review) label Jul 24, 2026
@charlesvien
charlesvien enabled auto-merge (squash) July 24, 2026 06:25
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "clamp loop reasoning effort at fire time" | Re-trigger Greptile

stamphog[bot]
stamphog Bot previously approved these changes Jul 24, 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.

Small, well-tested defensive fix to loop-fire model/effort resolution by the owning-team author with strong familiarity (100% of touched lines, 4/4 files); no risky-territory concerns (auth/billing/migrations/public API/CI) and no outstanding review issues.

  • Author wrote 100% of the modified lines and has 10 merged PRs in these paths (familiarity STRONG).
  • 👍 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 21L, 2F substantive, 77L/4F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1b-small (77L, 4F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 8fa03f8 · reviewed head 9b00588

@stamphog

stamphog Bot commented Jul 24, 2026

Copy link
Copy Markdown

Retaining stamphog approval — delta since last review classified as trivial_paths.

@charlesvien
charlesvien force-pushed the fix/loop-effort-clamp branch from 9177213 to cc36547 Compare July 24, 2026 07:13
@stamphog
stamphog Bot dismissed their stale review July 24, 2026 07:14

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

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

Contained defensive fix clamping a stored reasoning effort at fire time, well covered by new parameterized tests, author is on the owning team with strong recent familiarity, and Greptile's review shows no concerns.

  • Author wrote 100% of the modified lines and has 10 merged PRs in these paths (familiarity STRONG).
  • 👍 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 21L, 2F substantive, 78L/4F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1b-small (78L, 4F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 6f146ab · reviewed head cc36547

@charlesvien
charlesvien force-pushed the fix/loop-effort-clamp branch from cc36547 to 559276f Compare July 24, 2026 07:54
@charlesvien
charlesvien merged commit 93554d4 into master Jul 24, 2026
233 checks passed
@charlesvien
charlesvien deleted the fix/loop-effort-clamp branch July 24, 2026 08:24
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-24 08:53 UTC Run
prod-us ✅ Deployed 2026-07-24 09:10 UTC Run
prod-eu ✅ Deployed 2026-07-24 09:11 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