Skip to content

feat(agents): render model_policy in agent config + chat banner#2778

Draft
benjackwhite wants to merge 1 commit into
posthog-code/m3a-finalfrom
ben/agent-builder-model-policy
Draft

feat(agents): render model_policy in agent config + chat banner#2778
benjackwhite wants to merge 1 commit into
posthog-code/m3a-finalfrom
ben/agent-builder-model-policy

Conversation

@benjackwhite

Copy link
Copy Markdown

What

Mirrors the backend's breaking spec.modelspec.model_policy change (PostHog/posthog#64825) in the desktop agent-applications UI.

  • AgentSpec: model: stringmodel_policy?: ModelPolicy (auto/manual discriminated union), plus ModelEntry / ModelLevel / ReasoningEffort types mirroring the backend schema.
  • Model config pane (ModelBody): renders the policy — auto shows policy / level / reasoning; manual shows the primary model + ordered fallback rows (per-model reasoning inline).
  • Chat preview banner: new modelPolicySummary() helper → compact label (auto · high, or <model> +N for 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 in main. The merged agent-builder-polish (#2770) also targeted m3a-final.

Testing

  • @posthog/shared + @posthog/ui typecheck clean for these files (the only @posthog/web typecheck failures are pre-existing on this branch, in canvas/WebsiteLayout.tsx and code-review/InteractiveFileDiff.tsx — untouched here); Biome clean.
  • Verified live against local posthog: patched the local agent-builder live revision to model_policy: { mode: auto, level: high } and confirmed the config pane renders POLICY auto / LEVEL high / REASONING high correctly.

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 1b1deaf.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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"}

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.

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

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.

1 participant