Skip to content

fix: filter unregistered profile tools from active set and improve missing tool error#228

Draft
LifeJiggy wants to merge 2 commits into
MoonshotAI:mainfrom
LifeJiggy:fix/tool-websearch-not-found-filter
Draft

fix: filter unregistered profile tools from active set and improve missing tool error#228
LifeJiggy wants to merge 2 commits into
MoonshotAI:mainfrom
LifeJiggy:fix/tool-websearch-not-found-filter

Conversation

@LifeJiggy
Copy link
Copy Markdown

Related Issue

Resolve #127

Problem

When a profile includes tools that require service configuration (e.g. WebSearch requires moonshotSearch), self-hosted users without that service see confusing "Tool not found" errors at runtime. The unavailable tools also appear in the LLM's tool list, wasting context and causing failed calls.

What changed

  1. setActiveTools filtering — tools listed in the active profile that have no registered builtin or user implementation are filtered out at enable time, with a clear warning explaining which tools were omitted and why. Previously the enabledTools set could contain names with no backing implementation.
  2. Improved error message — when a tool is still called despite being unavailable (e.g. because it was registered after the profile was loaded), the error now explains that it may require configuration or was removed from the profile, and suggests using available tools instead.
  3. Telemetry detection update — the telemetry classifier now recognizes both the old and new error message formats for missing-tool errors.
  4. Tests — unit tests for the filtering and warning behavior, plus updated compaction snapshot.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: 144340f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53daca0daf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core/src/agent/tool/index.ts
When setActiveTools() is called before initializeBuiltinTools()
(e.g. profile applied before model config lands), every builtin name
was silently dropped because �uiltinTools was empty.

- Save pending builtin names in pendingBuiltinToolNames instead of
  warning immediately when �uiltinTools.size === 0
- Reapply pending names inside initializeBuiltinTools() after the
  builtins map is populated; warn only for tools still genuinely missing
- Reset pendingBuiltinToolNames when a subsequent setActiveTools
  call resolves all names
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 144340ff1f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +430 to +436
if (this.pendingBuiltinToolNames.length > 0) {
const nowAvailable = this.pendingBuiltinToolNames.filter(
(name) => this.builtinTools.has(name) || this.userTools.has(name),
);
if (nowAvailable.length > 0) {
for (const name of nowAvailable) {
this.enabledTools.add(name);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replay pending tools before constructing background-capable tools

When a profile is applied before builtins are initialized, setActiveTools now leaves enabledTools empty and stores TaskList/TaskOutput/TaskStop in pendingBuiltinToolNames. This replay happens only here, after initializeBuiltinTools() has already computed allowBackground and constructed BashTool/AgentTool, so fresh sessions that configure the model after applying the default profile still expose the task tools but permanently reject run_in_background=true as unavailable. Move the replay (or compute allowBackground from pending names too) before constructing those tools.

Useful? React with 👍 / 👎.

@LifeJiggy LifeJiggy marked this pull request as draft May 29, 2026 16:55
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.

Tool "WebSearch" not found

1 participant