Skip to content

[feat] Make the agent template panel read more from the schema (FE + SDK)#4932

Merged
ardaerzin merged 4 commits into
big-agentsfrom
fe-feat/agent-template-schema-driven
Jun 29, 2026
Merged

[feat] Make the agent template panel read more from the schema (FE + SDK)#4932
ardaerzin merged 4 commits into
big-agentsfrom
fe-feat/agent-template-schema-driven

Conversation

@ardaerzin

Copy link
Copy Markdown
Contributor

Context

After #4913 landed the typed agent-template catalog type, the playground panel can read more of its shape from the schema instead of hardcoding it. This makes a few of those reads real, and fixes a backend schema-gen quirk that was leaking a private class name into the UI.

The headline bug: the Instructions section header rendered _InstructionsSchema (a raw Pydantic class name) instead of "Instructions". Root cause below.

Changes

SDK (types.py) — the real fix. The catalog endpoint inlines $defs before serving, and an inlined nested model carries its own schema title, which Pydantic defaults to the class name. So once the field-level title was dropped during inlining, the private execution sub-schemas surfaced their class names. Setting an explicit title on each nested sub-schema's model_config (Connection / Model / Instructions / Permissions / Harness / Interactions / Runner / Sandbox) makes the inlined node carry the human label.

Before (served schema): properties.instructions.title = "_InstructionsSchema"
After: properties.instructions.title = "Instructions"

Cosmetic only: no change to validation, the wire contract, or runtime parsing; no test asserts these titles.

FE (@agenta/entity-ui) — read more from the schema, where today's schema supports it:

  • Per-field section headers (Instructions / Tools / MCP servers / Skills) read their label from props.<field>.title, so a field rename propagates without editing the section array. Composite sections (Model & harness, Advanced) and Triggers keep their FE labels; icons aren't in the schema. A guard rejects leading-underscore titles and falls back to the literal (belt-and-suspenders for any nested field still missing a title).
  • Harness capabilities resolve from the schema's declared x-ag-harness-ref on harness.kind (its target is the harnesses catalog), applied only when the ref is declared, instead of assuming the endpoint.
  • The Claude permission-mode option set + field label/description come from the typed harness.permissions.default_mode sub-schema; it reads the enum from anyOf (the field is Optional[Literal]), falling back to the hardcoded options.

G2 (discriminator-aware item classification) is documented as deferred in the design doc: the FE tool classifier is built on the legacy {function:{name}} shape absent from ToolConfig's discriminated union, so full adoption belongs with the schema-driven-config redesign (CHANGE-3).

Tests / notes

  • SDK: ruff format + ruff check clean. @agenta/entity-ui + @agenta/entities: tsc + eslint clean. OSS tsc unchanged at baseline.
  • Verified live against the dev server for this branch (confirmed serving this worktree): the running backend now serves instructions.title = "Instructions" (was _InstructionsSchema); the playground renders the correct section headers on two agents including a fresh one; the catalog carries x-ag-harness-ref where the FE reads it (harness capability cards still render).
  • Honest scope note: on today's schema the FE reads are mostly decoupling — the list-field titles already equalled the literals, the harness ref resolves to the one global catalog, and the default_mode enum matches the hardcoded set. The visible win is the _InstructionsSchema fix. The rest is forward-compatible and lights up as the schema carries more.
  • types.py is JP's Step-1 schema file; the change is trivial/cosmetic but flagged here for his awareness.

What to QA

  • Open an agent in the playground. The config sections read Instructions / Tools / MCP servers / Skills (the Instructions header must NOT read _InstructionsSchema).
  • Open Model & harness: the harness capability cards (Pi / Pi (Agenta) / Claude Code with provider + model info) still render — confirms the harness-ref resolution didn't regress capabilities.
  • On the Claude harness, Advanced → the Permission mode dropdown still lists Default / Accept edits / Plan / Bypass.

After #4913 landed the typed agent-template catalog type, the panel can infer
more from the template shape instead of hardcoding it. This closes the
schema-driven gaps that are implementable on today's schema without regression:

- G1 — section header titles for the per-field sections (Instructions / Tools /
  MCP servers / Skills) now come from props.<field>.title, so a field rename in
  the template propagates without editing the section array. Composite sections
  (Model & harness, Advanced) and Triggers keep their FE labels; icons aren't in
  the schema.
- G3 — harness capabilities resolve from the schema's declared x-ag-harness-ref
  on harness.kind (its target is the harnesses catalog) and are only applied when
  the ref is declared, instead of assuming the endpoint. revisionId drops from
  useModelHarness (capabilities key on the ref, not the revision).
- G4 — the Claude permission-mode option set + field label/description come from
  the typed harness.permissions.default_mode sub-schema (enum + title), keeping
  the FE display labels, so a backend mode change propagates.

G2 (discriminator-aware item classification) is documented as gated: the FE tool
classifier is built on the legacy {function:{name}} shape absent from ToolConfig's
discriminated union, so full adoption belongs with the schema-driven-config
redesign (CHANGE-3). Tracked in the design doc checklist.

Verified: entity-ui + entities tsc and eslint clean; OSS tsc at baseline 593;
live in the playground (titles, harness/model summary, Claude permission options
all render; no console errors).
Live verification (proper worktree this time) surfaced two issues in the
schema-driven work the original commit claimed to have verified:

- G1 regression: schema-gen emits the wrapper class name as a nested-model
  field's title, so the Instructions section header rendered the raw
  '_InstructionsSchema'. fieldTitle now rejects leading-underscore titles and
  falls back to the literal; the list fields (Tools/MCP servers/Skills) carry
  real titles and still pass through. Forward-compatible: a real backend title
  lights up automatically.
- G4 was inert: default_mode is Optional[Literal], so its enum sits under
  anyOf, not on the node. ClaudePermissionsControl now reads the enum from
  anyOf too (it matched the hardcoded set, so options are unchanged).

Confirmed against the dev server serving THIS worktree: catalog schema carries
x-ag-harness-ref on harness.kind (G3 resolves), and the Instructions header now
reads 'Instructions'. tsc + eslint clean.
The catalog endpoint inlines $defs before serving, and an inlined nested model
carries its own schema title — which Pydantic defaults to the class name. So the
private execution sub-schemas surfaced their class names (e.g. the Instructions
section header rendered "_InstructionsSchema" in the playground) once the
field-level title was dropped during inlining.

Set an explicit `title` on each nested sub-schema's model_config
(Connection / Model / Instructions / Permissions / Harness / Interactions /
Runner / Sandbox) so the inlined node carries the human label. Cosmetic only:
no change to validation, the wire contract, or runtime parsing; no test asserts
these titles. Unblocks the FE's schema-driven section titles (the panel's
fieldTitle now reads a real label instead of falling back to the literal).

ruff format + check clean.
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 29, 2026
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 29, 2026 12:15pm

Request Review

@dosubot dosubot Bot added enhancement New feature or request Frontend labels Jun 29, 2026
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e890b700-f2b6-4fa7-9d40-a45332da2617

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Pydantic sub-schemas gain title metadata; the frontend's useModelHarness hook drops revisionId and instead keys harness capability lookup by x-ag-harness-ref. AgentTemplateControl adds a fieldTitle helper to read section titles from schema, and ClaudePermissionsControl gains a modeSchema prop to derive permission mode options and labels from the backend schema.

Changes

Schema-driven harness titles and capability lookup

Layer / File(s) Summary
Python sub-schema title metadata
sdks/python/agenta/sdk/utils/types.py
Eight model_config blocks gain a title field (Connection, Model, Instructions, Permissions, Harness, Interactions, Runner, Sandbox).
Harness capability lookup via x-ag-harness-ref
web/packages/agenta-entities/src/workflow/state/inspectMeta.ts, web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx
useModelHarness removes revisionId from its signature; harness capabilities are now keyed by harnessProps["x-ag-harness-ref"] instead of revisionId. modeSchema is passed to ClaudePermissionsControl. Atom family comment updated.
Schema-driven section titles and permission mode options
web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentTemplateControl.tsx, web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ClaudePermissionsControl.tsx
AgentTemplateControl drops revisionId from the useModelHarness call, adds fieldTitle helper, and uses it for instructions/tools/mcps/skills headers. ClaudePermissionsControl adds modeSchema prop and derives modeOptions/modeLabel/modeDescription from schema data.
Design doc update
docs/design/agent-config-section-drawers/design.md
New "Schema-driven section work package" section with G1–G4 checklist items.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Agenta-AI/agenta#4923: Refactors AgentTemplateControl and introduces the useModelHarness API that this PR further modifies by removing revisionId and switching to x-ag-harness-ref-based capability lookup.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: making the agent template panel read more from the schema.
Description check ✅ Passed The description is clearly related to the changeset and explains the SDK and frontend schema-driven updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fe-feat/agent-template-schema-driven

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
docs/design/agent-config-section-drawers/design.md (1)

134-135: 📐 Maintainability & Code Quality | 🔵 Trivial

Use human-readable schema title instead of private Pydantic name.

G4 references _HarnessPermissionsSchema, but the PR specifically fixes private Pydantic class names (like _InstructionsSchema) being exposed as titles. The design doc should align with the fix by using the human-readable title that the schema now serves, e.g., HarnessPermissions or harness.permissions.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6af9f890-75c8-4e99-b4e2-28f9ebc40c24

📥 Commits

Reviewing files that changed from the base of the PR and between 0755d86 and a6b353e.

📒 Files selected for processing (6)
  • docs/design/agent-config-section-drawers/design.md
  • sdks/python/agenta/sdk/utils/types.py
  • web/packages/agenta-entities/src/workflow/state/inspectMeta.ts
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentTemplateControl.tsx
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ClaudePermissionsControl.tsx
  • web/packages/agenta-entity-ui/src/DrillInView/SchemaControls/agentTemplate/useModelHarness.tsx

… path

Readability tweak in the G4 checklist item: the field path `harness.permissions`
reads cleaner than the private `_HarnessPermissionsSchema` class name. Same
sub-schema, no content change.
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 29, 2026
@ardaerzin ardaerzin merged commit addfe93 into big-agents Jun 29, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Frontend lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants