Skip to content

fix: register LLM-backed tools only when configured - #117

Open
ntmspavan wants to merge 1 commit into
kagent-dev:mainfrom
ntmspavan:fix/conditional-llm-tools
Open

ntmspavan wants to merge 1 commit into
kagent-dev:mainfrom
ntmspavan:fix/conditional-llm-tools

Conversation

@ntmspavan

Copy link
Copy Markdown

Fixes #93

The server advertises k8s_generate_resource and prometheus_promql_tool even when their LLM configuration is missing. Agents can select these tools, but every call then fails.

Only register resource generation when the caller supplies an LLM, and PromQL generation when OPENAI_API_KEY is non-empty. Other tools and the existing read-only restrictions stay available as before. The README explains the optional Helm Secret and why the CLI cannot currently offer Kubernetes resource generation, even with an OpenAI key.

Tests exercise MCP tool discovery and invocation with missing and configured models, unset and empty keys, and both access modes. Configured generation uses a mock model or local HTTP server.

Validation with Go 1.27.3 in an isolated container:

  • make fmt
  • make lint — zero issues
  • make test — passed, including all five platform builds
  • go test -tags=test -race ./pkg/k8s ./pkg/prometheus ./cmd -coverprofile=/tmp/issue93-coverage.out — passed

Both changed registration functions have 100% statement coverage. Package coverage is 86.7% for Prometheus and 77.2% for Kubernetes. I checked Kubernetes coverage on the unchanged base: it was already 77.1%, below the documented 80% target.

No public function signatures or tool inputs/outputs change. Tools without configuration intentionally disappear from discovery. Configuration is checked at registration; restart the server after adding the key. This does not validate credentials or model access, and no live-cluster or real-model testing was performed.

Hide resource generation without an injected model and PromQL generation without an OpenAI API key. Cover tool discovery and invocation through MCP in both read-only and read-write mode.

Fixes kagent-dev#93

Signed-off-by: Pavan Nalam <pavan.nalam3693@gmail.com>
@ntmspavan
ntmspavan marked this pull request as ready for review November 16, 2026 23:21
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.

LLM-backed tools are registered without an LLM

1 participant