feat(agents): render model_policy in agent config + chat banner#2778
Draft
benjackwhite wants to merge 1 commit into
Draft
feat(agents): render model_policy in agent config + chat banner#2778benjackwhite wants to merge 1 commit into
benjackwhite wants to merge 1 commit into
Conversation
Mirror the backend's breaking spec.model -> spec.model_policy change (PostHog/posthog#64825) in the agent-applications UI. - AgentSpec: replace `model: string` with `model_policy?: ModelPolicy` (auto/manual discriminated union) + ModelEntry/ModelLevel/ ReasoningEffort types mirroring the backend schema. - ModelBody: render the policy — auto shows policy/level/reasoning; manual shows the primary model + ordered fallback rows (per-model reasoning inline). - PreviewBanner: new modelPolicySummary() helper for a compact label ("auto · high", or "<model> +N" for a manual list). Display-only; the builder agent still authors specs via its tools. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/ui/src/features/agent-applications/components/AgentConfigurationPane.tsx:640-643
Duplicate-key risk in manual model list. The composite key `${m.model}:${m.reasoning ?? "_"}` is not guaranteed unique — if the same model appears twice in the priority list (e.g., two entries for `"claude-3-5-sonnet"` with no per-entry reasoning), React will emit a duplicate-key warning and reconciliation may misbehave. Array index is a safe alternative for a stable, ordered priority list where items are never reordered in-place.
```suggestion
{policy.models.map((m, i) => (
<Row
key={i}
label={i === 0 ? "model" : "fallback"}
```
Reviews (1): Last reviewed commit: "feat(agents): render model_policy in age..." | Re-trigger Greptile |
Comment on lines
+640
to
+643
| {policy.models.map((m, i) => ( | ||
| <Row | ||
| key={`${m.model}:${m.reasoning ?? "_"}`} | ||
| label={i === 0 ? "model" : "fallback"} |
Contributor
There was a problem hiding this comment.
Duplicate-key risk in manual model list. The composite key
${m.model}:${m.reasoning ?? "_"} is not guaranteed unique — if the same model appears twice in the priority list (e.g., two entries for "claude-3-5-sonnet" with no per-entry reasoning), React will emit a duplicate-key warning and reconciliation may misbehave. Array index is a safe alternative for a stable, ordered priority list where items are never reordered in-place.
Suggested change
| {policy.models.map((m, i) => ( | |
| <Row | |
| key={`${m.model}:${m.reasoning ?? "_"}`} | |
| label={i === 0 ? "model" : "fallback"} | |
| {policy.models.map((m, i) => ( | |
| <Row | |
| key={i} | |
| label={i === 0 ? "model" : "fallback"} |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/agent-applications/components/AgentConfigurationPane.tsx
Line: 640-643
Comment:
Duplicate-key risk in manual model list. The composite key `${m.model}:${m.reasoning ?? "_"}` is not guaranteed unique — if the same model appears twice in the priority list (e.g., two entries for `"claude-3-5-sonnet"` with no per-entry reasoning), React will emit a duplicate-key warning and reconciliation may misbehave. Array index is a safe alternative for a stable, ordered priority list where items are never reordered in-place.
```suggestion
{policy.models.map((m, i) => (
<Row
key={i}
label={i === 0 ? "model" : "fallback"}
```
How can I resolve this? If you propose a fix, please make it concise.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Mirrors the backend's breaking
spec.model→spec.model_policychange (PostHog/posthog#64825) in the desktop agent-applications UI.AgentSpec:model: string→model_policy?: ModelPolicy(auto/manual discriminated union), plusModelEntry/ModelLevel/ReasoningEfforttypes mirroring the backend schema.ModelBody): renders the policy —autoshowspolicy/level/reasoning;manualshows the primarymodel+ orderedfallbackrows (per-model reasoning inline).modelPolicySummary()helper → compact label (auto · high, or<model> +Nfor a manual list).Display-only — the builder agent still authors specs via its tools; there's no model picker in the desktop UI.
Base
Stacked on
posthog-code/m3a-final(#2700) — the agent-applications files only exist there, not yet inmain. The merged agent-builder-polish (#2770) also targeted m3a-final.Testing
@posthog/shared+@posthog/uitypecheck clean for these files (the only@posthog/webtypecheck failures are pre-existing on this branch, incanvas/WebsiteLayout.tsxandcode-review/InteractiveFileDiff.tsx— untouched here); Biome clean.agent-builderlive revision tomodel_policy: { mode: auto, level: high }and confirmed the config pane rendersPOLICY auto/LEVEL high/REASONING highcorrectly.🤖 Generated with Claude Code