-
Notifications
You must be signed in to change notification settings - Fork 61
feat(loops): Align model fields with GLM fire-time default #3740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
packages/ui/src/features/loops/hooks/useLoopDisplayModel.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| loopEffectiveModel, | ||
| loopSupportedReasoningEfforts, | ||
| } from "./loopModelDefaults"; | ||
|
|
||
| describe("loopEffectiveModel", () => { | ||
| it.each([ | ||
| ["claude", "", "@cf/zai-org/glm-5.2"], | ||
| ["codex", "", "gpt-5"], | ||
| ["claude", "claude-opus-4-8", "claude-opus-4-8"], | ||
| ["codex", "gpt-5.5", "gpt-5.5"], | ||
| ] as const)( | ||
| "resolves adapter %s with model %j to %s", | ||
| (adapter, model, expected) => { | ||
| expect(loopEffectiveModel(adapter, model)).toBe(expected); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| describe("loopSupportedReasoningEfforts", () => { | ||
| it.each([ | ||
| ["claude", "", ["high", "max"]], | ||
| ["claude", "@cf/zai-org/glm-5.2", ["high", "max"]], | ||
| ["claude", "claude-sonnet-4-6", ["low", "medium", "high"]], | ||
| ["claude", "claude-opus-4-8", ["low", "medium", "high", "xhigh", "max"]], | ||
| ["codex", "", ["low", "medium", "high"]], | ||
| ["codex", "gpt-5.5", ["low", "medium", "high", "xhigh"]], | ||
| ["codex", "gpt-5.6-sol", ["low", "medium", "high", "xhigh", "max"]], | ||
| ["codex", "gpt-unknown", ["low", "medium", "high"]], | ||
| ["claude", "claude-unknown", ["low", "medium", "high", "xhigh", "max"]], | ||
| ] as const)( | ||
| "adapter %s with model %j supports %j", | ||
| (adapter, model, expected) => { | ||
| expect(loopSupportedReasoningEfforts(adapter, model)).toEqual(expected); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import type { LoopSchemas } from "@posthog/api-client/loops"; | ||
|
|
||
| // Mirrors DEFAULT_MODEL_BY_RUNTIME_ADAPTER and the per-model effort tables in posthog's products/tasks/backend/temporal/process_task/utils.py. | ||
| export const LOOP_DEFAULT_MODEL_BY_ADAPTER: Record< | ||
| LoopSchemas.LoopRuntimeAdapterEnum, | ||
| string | ||
| > = { | ||
| claude: "@cf/zai-org/glm-5.2", | ||
| codex: "gpt-5", | ||
| }; | ||
|
|
||
| const ALL_EFFORTS: LoopSchemas.LoopReasoningEffortEnum[] = [ | ||
| "low", | ||
| "medium", | ||
| "high", | ||
| "xhigh", | ||
| "max", | ||
| ]; | ||
| const LOW_TO_HIGH: LoopSchemas.LoopReasoningEffortEnum[] = [ | ||
| "low", | ||
| "medium", | ||
| "high", | ||
| ]; | ||
|
|
||
| const EFFORTS_BY_MODEL: Record<string, LoopSchemas.LoopReasoningEffortEnum[]> = | ||
| { | ||
| "@cf/zai-org/glm-5.2": ["high", "max"], | ||
| "claude-opus-4-5": LOW_TO_HIGH, | ||
| "claude-sonnet-4-6": LOW_TO_HIGH, | ||
| "gpt-5": LOW_TO_HIGH, | ||
| "gpt-5.5": ["low", "medium", "high", "xhigh"], | ||
| "gpt-5.6-sol": ALL_EFFORTS, | ||
| "gpt-5.6-terra": ALL_EFFORTS, | ||
| "gpt-5.6-luna": ALL_EFFORTS, | ||
| }; | ||
|
|
||
| export function loopEffectiveModel( | ||
| adapter: LoopSchemas.LoopRuntimeAdapterEnum, | ||
| model: string, | ||
| ): string { | ||
| return model || LOOP_DEFAULT_MODEL_BY_ADAPTER[adapter]; | ||
| } | ||
|
|
||
| export function loopSupportedReasoningEfforts( | ||
| adapter: LoopSchemas.LoopRuntimeAdapterEnum, | ||
| model: string, | ||
| ): LoopSchemas.LoopReasoningEffortEnum[] { | ||
| const efforts = EFFORTS_BY_MODEL[loopEffectiveModel(adapter, model)]; | ||
| if (efforts) return efforts; | ||
| return adapter === "codex" ? LOW_TO_HIGH : ALL_EFFORTS; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an unpinned loop retains an effort unsupported by its current fire-time default, this code preserves that effort and cleanup runs only after a model or adapter change. Saving an unrelated edit therefore resubmits the invalid model-effort combination and the API rejects the update.
Rule Used: When implementing new features, ensure that the UI... (source)
Learned From
PostHog/posthog#32595
PostHog/posthog#32677
Prompt To Fix With AI