[feat] Make the agent template panel read more from the schema (FE + SDK)#4932
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughPydantic sub-schemas gain ChangesSchema-driven harness titles and capability lookup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/design/agent-config-section-drawers/design.md (1)
134-135: 📐 Maintainability & Code Quality | 🔵 TrivialUse 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.,HarnessPermissionsorharness.permissions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6af9f890-75c8-4e99-b4e2-28f9ebc40c24
📒 Files selected for processing (6)
docs/design/agent-config-section-drawers/design.mdsdks/python/agenta/sdk/utils/types.pyweb/packages/agenta-entities/src/workflow/state/inspectMeta.tsweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/AgentTemplateControl.tsxweb/packages/agenta-entity-ui/src/DrillInView/SchemaControls/ClaudePermissionsControl.tsxweb/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.
Context
After #4913 landed the typed
agent-templatecatalog 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$defsbefore 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 explicittitleon each nested sub-schema'smodel_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: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).x-ag-harness-refonharness.kind(its target is the harnesses catalog), applied only when the ref is declared, instead of assuming the endpoint.harness.permissions.default_modesub-schema; it reads the enum fromanyOf(the field isOptional[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 fromToolConfig's discriminated union, so full adoption belongs with the schema-driven-config redesign (CHANGE-3).Tests / notes
ruff format+ruff checkclean.@agenta/entity-ui+@agenta/entities: tsc + eslint clean. OSS tsc unchanged at baseline.instructions.title = "Instructions"(was_InstructionsSchema); the playground renders the correct section headers on two agents including a fresh one; the catalog carriesx-ag-harness-refwhere the FE reads it (harness capability cards still render).default_modeenum matches the hardcoded set. The visible win is the_InstructionsSchemafix. The rest is forward-compatible and lights up as the schema carries more.types.pyis JP's Step-1 schema file; the change is trivial/cosmetic but flagged here for his awareness.What to QA
_InstructionsSchema).