Skip to content

feat(ai): add Helm release management tools for the AI agent - #665

Open
yupanzi wants to merge 2 commits into
kite-org:mainfrom
yupanzi:feature/ai-helm-tool
Open

feat(ai): add Helm release management tools for the AI agent#665
yupanzi wants to merge 2 commits into
kite-org:mainfrom
yupanzi:feature/ai-helm-tool

Conversation

@yupanzi

@yupanzi yupanzi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Depends on #663 — this branch is stacked on it and includes its commit. Only the last commit (feat(ai): add Helm release management tools for the AI agent) is new; the shared value-redaction placeholder comes from #663. Happy to rebase once that lands.

Summary

Give the AI agent first-class Helm release tools:

  • Six new tools: list_helm_releases, get_helm_release (optionally with the chart's default values), get_helm_release_history, update_helm_release_values (merge — like --reuse-values — or replace semantics), rollback_helm_release, uninstall_helm_release.
  • Bounded results: item caps for lists/history/managed resources and a size cap per values section, so one large chart cannot consume the whole tool-result budget.
  • Value redaction: sensitive-looking values are masked with the shared placeholder, and update_helm_release_values rejects payloads that contain the placeholder so the agent cannot write "***" back into a release.
  • RBAC: tools map onto helmrelease get/update/delete permissions per namespace, and namespaced tools reject the _all pseudo-namespace — helm's storage would treat it as cluster-wide, which would bypass namespace deny rules.
  • Confirmation flow: the three mutating tools are registered as mutation tools, so they require the existing user confirmation; the chat UI describes them ("Update values of Helm release …") and previews the values_yaml like resource mutations.
  • Refactor: DeleteHelmReleaseAutoUpgradeTask moves from the resources handler into pkg/scheduler (exported) so uninstalling via the agent also clears a configured auto-upgrade task.

Why

The agent could only investigate Helm releases by poking at release Secrets with the generic resource tools, which is slow, leaks chart values wholesale, and cannot perform release operations safely.

Related issue

Closes #670

Validation

  • go test ./pkg/ai/... ./pkg/resources/... — new tool_helm_test.go plus authorization tests covering every helm tool, the _all rejection, and a coverage test asserting every registered tool has an authorization mapping
  • pnpm run type-check && pnpm run lint && pnpm run test

Checklist

  • I reviewed this PR myself before requesting review.
  • I understand the changes, including AI-generated parts (if any).
  • For new features, a feature request issue is linked.
  • I cleaned up AI noise (unnecessary comments, dead code, and unrelated changes).
  • This PR is reasonably scoped (or split into smaller PRs).

🤖 Generated with Claude Code

yupanzi and others added 2 commits September 1, 2026 12:53
Update the Claude integration to the current API surface and fix several
agent-loop problems:

- Move the Anthropic path to the Beta Messages API with adaptive thinking,
  context management, and output_config.effort. Effort is the reasoning-depth
  knob on current Claude models (budget_tokens returns 400 there); it is
  exposed as a new AIEffort setting (low/medium/high/xhigh/max, default xhigh)
  in the general settings. Use is gated per model by
  anthropicModelSupportsModernFeatures, so models that reject the modern
  request surface keep the classic shape.
- Send AIMaxTokens as configured and make the default provider-aware (64000
  for Anthropic, 8192 for OpenAI): on current Claude models thinking and
  answer share max_tokens, so a small default truncates the answer
  mid-sentence. The default Anthropic model becomes claude-opus-5.
- Bound the conversation with per-message and total character budgets, trimming
  oldest-first, so a long session cannot silently overflow the request.
- Strip tool calls the model emits as plain text or XML instead of through the
  native mechanism, and instruct it not to in the system prompt. A textual call
  is never executed, and echoing it back poisons later turns into repeating it.
- Mask Secret data in tool results before they reach the model.
- Emit an SSE keepalive comment every 20s. An agent turn is legitimately silent
  while a tool runs, and ingress-nginx closes a connection after 60s of backend
  silence. Raise the chart's gateway request timeout to 900s and document the
  matching ingress-nginx annotations next to it.
- Tighten resource tool schemas and descriptions with explicit caps, and fix
  long-token overflow in AI chat markdown tables.
- Cover conversation replay, handler streaming, settings migration and the
  agent loop with tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Give the agent first-class Helm capabilities instead of forcing it to
poke at release Secrets with generic resource tools:

- New tools: list_helm_releases, get_helm_release (with optional chart
  default values), get_helm_release_history, update_helm_release_values
  (merge or replace semantics), rollback_helm_release,
  uninstall_helm_release. Results are bounded (item caps, values size
  cap) so one large chart cannot consume the tool-result budget.
- Sensitive-looking values are masked with the shared redaction
  placeholder; masked placeholders written back in values_yaml are
  rejected so the agent cannot corrupt a release with "***".
- RBAC: helm tools map onto helmrelease get/update/delete permissions
  per namespace; namespaced tools reject the _all pseudo-namespace so
  helm's cluster-wide storage cannot bypass namespace deny rules. The
  three mutating tools require the existing user confirmation flow, and
  the chat UI describes and previews them like resource mutations.
- Export scheduler.DeleteHelmReleaseAutoUpgradeTask (moved from the
  resources handler) so uninstalling via the agent also clears a
  configured auto-upgrade task.

Built on top of the Anthropic modernization branch, which provides the
shared value-redaction placeholder.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@yupanzi
yupanzi force-pushed the feature/ai-helm-tool branch from 2e93fdb to 69941bf Compare September 1, 2026 04:56
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.

AI: first-class Helm release tools for the agent

1 participant