Skip to content

feat: replace hard tool limit with configurable warning#1403

Open
fl-sean03 wants to merge 5 commits intokagent-dev:mainfrom
fl-sean03:feat/694-tool-limit-warning
Open

feat: replace hard tool limit with configurable warning#1403
fl-sean03 wants to merge 5 commits intokagent-dev:mainfrom
fl-sean03:feat/694-tool-limit-warning

Conversation

@fl-sean03
Copy link
Contributor

Summary

Replaces the hard 20-tool limit with a soft warning, as discussed in #694.

Changes:

  • Go CRD (v1alpha1 & v1alpha2): Removed +kubebuilder:validation:MaxItems=20 from the Tools field in agent_types.go, allowing agents to be created with any number of tools via in-cluster manifests
  • UI (SelectToolsDialog.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 proceed
  • UI (agents/new/page.tsx): Removed the hard limit of 20 on skill container image references

What changed in the UI:

  • "Tool limit reached. Deselect a tool to add another." → "You have selected N tools. A large number of tools may increase token usage and affect performance."
  • "Selected (N/20)" → "Selected (N)"
  • "Select up to 20 tools" → "Select tools for your agent"
  • Tools are no longer grayed out / disabled when the threshold is reached

Test Plan

  • Added 7 new tests in SelectToolsDialog.test.tsx verifying:
    • No warning shown below threshold
    • Warning shown at/above threshold with correct count
    • No hard limit blocking message
    • No disabled items at threshold
    • Footer text updated
  • All 114 existing tests pass
  • ESLint passes
  • next build succeeds

Fixes #694

Signed-off-by: Sean Florez sean@opspawn.com

Copilot AI review requested due to automatic review settings February 28, 2026 01:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tools field in Go CRD types (v1alpha1/v1alpha2).
  • Updated SelectToolsDialog to 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.

@@ -133,7 +133,6 @@ type DeclarativeAgentSpec struct {
// If not specified, the default value is false.
// +optional
Stream bool `json:"stream,omitempty"`
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
Stream bool `json:"stream,omitempty"`
Stream bool `json:"stream,omitempty"`
// +kubebuilder:validation:MaxItems=20

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 39 to 44
// 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>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 773 to 778
<Button
variant="outline"
size="icon"
onClick={() => {
if ((state.skillRefs || []).length < 20) {
setState(prev => ({ ...prev, skillRefs: [...prev.skillRefs, ""] }));
}
setState(prev => ({ ...prev, skillRefs: [...prev.skillRefs, ""] }));
}}
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@fl-sean03 fl-sean03 force-pushed the feat/694-tool-limit-warning branch from 7a5ff3a to e815d36 Compare February 28, 2026 01:51
Sean Florez and others added 4 commits February 28, 2026 02:53
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>
@fl-sean03 fl-sean03 force-pushed the feat/694-tool-limit-warning branch from a502e69 to 7dd8cfa Compare February 28, 2026 02:55
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>
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.

[BUG] Replace tool limit in UI with warning

2 participants