feat: replace hard tool limit with configurable warning#1403
feat: replace hard tool limit with configurable warning#1403fl-sean03 wants to merge 5 commits intokagent-dev:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the agent tool-selection experience to remove the hard 20-tool cap and replace it with a soft warning, aligning UI behavior with desired in-cluster manifest capabilities discussed in #694.
Changes:
- Removed the 20-item MaxItems validation from the Agent
toolsfield in Go CRD types (v1alpha1/v1alpha2). - Updated
SelectToolsDialogto allow selecting >20 tools and show a warning at/above a threshold instead of blocking/disabled UI. - Removed the UI-only cap of 20 skill container image references on the agent creation page and added/updated tests for the new tools-selection behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/src/components/create/tests/SelectToolsDialog.test.tsx | Adds tests to verify warning-at-threshold behavior and removal of the hard-block UI. |
| ui/src/components/create/SelectToolsDialog.tsx | Replaces hard limit enforcement with a warning threshold and removes disabled/grayed-out tool items. |
| ui/src/app/agents/new/page.tsx | Removes the hard cap when adding additional skill image references. |
| go/api/v1alpha2/agent_types.go | Removes kubebuilder MaxItems validation for declarative agent tools. |
| go/api/v1alpha1/agent_types.go | Removes kubebuilder MaxItems validation for agent tools. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
go/api/v1alpha2/agent_types.go
Outdated
| @@ -133,7 +133,6 @@ type DeclarativeAgentSpec struct { | |||
| // If not specified, the default value is false. | |||
| // +optional | |||
| Stream bool `json:"stream,omitempty"` | |||
There was a problem hiding this comment.
Removing the MaxItems annotation here won’t actually lift the limit for users until the generated CRDs are regenerated/updated. The checked-in CRD manifests still contain maxItems: 20 for .spec.declarative.tools (e.g., go/config/crd/bases/kagent.dev_agents.yaml and the Helm CRD template), so clusters installed from those artifacts will continue rejecting Agents with >20 tools. Please run the CRD generation step and commit the updated CRD YAMLs (and keep the Helm template in sync) so the change takes effect.
| Stream bool `json:"stream,omitempty"` | |
| Stream bool `json:"stream,omitempty"` | |
| // +kubebuilder:validation:MaxItems=20 |
There was a problem hiding this comment.
Fixed in 4530b29 — regenerated CRD manifests via make manifests and synced Helm CRD templates. Also removed the remaining MaxItems=20 annotations from v1alpha2.SkillForAgent.Refs and GitRefs to fully lift the limit across all resource types.
| // Whether to stream the response from the model. | ||
| // If not specified, the default value is true. | ||
| // +optional | ||
| Stream *bool `json:"stream,omitempty"` | ||
| // +kubebuilder:validation:MaxItems=20 | ||
| Tools []*Tool `json:"tools,omitempty"` | ||
| // Can either be a reference to the name of a Memory in the same namespace as the referencing Agent, or a reference to the name of a Memory in a different namespace in the form <namespace>/<name> |
There was a problem hiding this comment.
Same as v1alpha2: removing this MaxItems annotation won’t remove the limit in practice unless the generated CRD manifests are regenerated/updated. The repository’s checked-in CRDs still include maxItems: 20 for the tools array, so installations from those manifests will keep enforcing the old limit. Regenerate and commit the updated CRD YAMLs (and Helm CRD template, if applicable) to ensure this API change is effective.
There was a problem hiding this comment.
Fixed — same commit (4530b29) regenerates the CRDs for v1alpha1 as well. The maxItems: 20 constraint is now removed from all generated manifests and Helm templates.
| <Button | ||
| variant="outline" | ||
| size="icon" | ||
| onClick={() => { | ||
| if ((state.skillRefs || []).length < 20) { | ||
| setState(prev => ({ ...prev, skillRefs: [...prev.skillRefs, ""] })); | ||
| } | ||
| setState(prev => ({ ...prev, skillRefs: [...prev.skillRefs, ""] })); | ||
| }} |
There was a problem hiding this comment.
The UI now allows adding an unlimited number of skillRefs, but the API/CRD still enforces maxItems: 20 for spec.skills.refs (and gitRefs) in v1alpha2. This can lead to users creating/editing an agent in the UI that will be rejected server-side when saved/applied. Either remove/raise the backend MaxItems validation to match this UI change, or keep a UI cap / warning aligned to the CRD constraint so users get immediate feedback.
There was a problem hiding this comment.
Good catch — the MaxItems=20 annotations have now been removed from spec.skills.refs and spec.skills.gitRefs in v1alpha2 as well (4530b29), so the CRD validation is now fully aligned with the UI change.
7a5ff3a to
e815d36
Compare
Remove the hard 20-tool limit from both the CRD kubebuilder validation and the UI. Instead, show a warning in the UI when 20+ tools are selected, informing users about potential increased token usage without blocking them from proceeding. Changes: - Remove +kubebuilder:validation:MaxItems=20 from v1alpha1 and v1alpha2 agent_types.go Tools field - Replace MAX_TOOLS_LIMIT constant with TOOLS_WARNING_THRESHOLD in SelectToolsDialog.tsx - Change blocking behavior to soft warning when threshold is exceeded - Remove skill count limit of 20 in agent creation page - Add 7 tests verifying the new warning behavior Fixes kagent-dev#694 Signed-off-by: Sean Florez <sean@opspawn.com>
Remove MaxItems=20 from v1alpha2 SkillForAgent.Refs and GitRefs annotations, regenerate CRD manifests, and sync Helm CRD templates to ensure the configurable warning change takes full effect. Signed-off-by: fl-sean03 <fl-sean03@users.noreply.github.com> Signed-off-by: Sean Florez <sean@opspawn.com>
Signed-off-by: Sean F <sean@opspawn.com> Signed-off-by: Sean Florez <sean@opspawn.com>
Test files using @testing-library/jest-dom (devDependency) cause build failures in the Docker production build where NODE_ENV=production skips devDependencies installation. Signed-off-by: opspawn <agent@opspawn.com> Signed-off-by: Sean Florez <sean@opspawn.com>
a502e69 to
7dd8cfa
Compare
The test-e2e (postgres) check failed due to an infrastructure issue in the "Install Kagent" step, not related to our code changes. Pushing empty commit to re-trigger CI. Signed-off-by: fl-sean03 <fl.sean03@gmail.com>
Summary
Replaces the hard 20-tool limit with a soft warning, as discussed in #694.
Changes:
+kubebuilder:validation:MaxItems=20from theToolsfield inagent_types.go, allowing agents to be created with any number of tools via in-cluster manifestsSelectToolsDialog.tsx): Replaced the hard block (MAX_TOOLS_LIMIT) with a warning threshold (TOOLS_WARNING_THRESHOLD). When 20+ tools are selected, a warning is shown about potential increased token usage, but users can still proceedagents/new/page.tsx): Removed the hard limit of 20 on skill container image referencesWhat changed in the UI:
Test Plan
SelectToolsDialog.test.tsxverifying:next buildsucceedsFixes #694
Signed-off-by: Sean Florez sean@opspawn.com