Skip to content

feat(agent-core): defer registered user tools#2119

Merged
7Sageer merged 3 commits into
MoonshotAI:mainfrom
pvzheroes125:codex/deferred-user-tools
Jul 24, 2026
Merged

feat(agent-core): defer registered user tools#2119
7Sageer merged 3 commits into
MoonshotAI:mainfrom
pvzheroes125:codex/deferred-user-tools

Conversation

@pvzheroes125

@pvzheroes125 pvzheroes125 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Related Issue

No linked issue. This follows a maintainer request to let hosts defer selected registered tool schemas.

Problem

select_tools only progressively disclosed MCP tools. Hosts with large registered user-tool surfaces had to expose every schema inline, increasing prompt size even when most tools were irrelevant.

What changed

  • Added optional disclosure: "inline" | "deferred" metadata to registered user tools, defaulting to inline.
  • Made deferred host/user tools discoverable and loadable through select_tools in both agent-core v1 and v2.
  • Propagated disclosure through v2 user-tool state, direct registry registration, and module-level registerTool.
  • Preserved inline fallback when the model capability or feature flag gate is closed.
  • Added persistence, inheritance, removal, provider-wire, and execution coverage.
  • Added a changeset for @moonshot-ai/kimi-code; no CLI-facing documentation update is needed.

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

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 861d61c

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

This PR includes changesets to release 1 package
Name Type
@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

Allow hosts to mark registered user tools as deferred so select_tools can discover and load their schemas on demand in both agent-core implementations.
@pvzheroes125
pvzheroes125 force-pushed the codex/deferred-user-tools branch from 5f2a533 to 1908dd5 Compare July 23, 2026 16:20
@pvzheroes125
pvzheroes125 marked this pull request as ready for review July 23, 2026 16:22

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

Copy link
Copy Markdown

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: 1908dd597e

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/toolSelect/toolSelectService.ts Outdated
Comment thread packages/agent-core/src/agent/tool/index.ts
Filter loaded deferred user-tool schemas from provider history and loaded-state checks after unregister while preserving canonical history and disconnected MCP behavior.

Copy link
Copy Markdown
Contributor Author

@codex review

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

Copy link
Copy Markdown

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: 7236167da6

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agent-core-v2/src/agent/toolSelect/toolSelectService.ts Outdated
Stop treating previously loaded user-tool schemas as active after the same tool is re-registered for inline disclosure.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Copy link
Copy Markdown

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: 861d61c496

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const info = this.toolRegistry.list().find((entry) => entry.name === name);
if (info !== undefined) {
return (
this.isDynamicallyLoadable(info) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow inline re-registered tools to execute

When a host re-registers a previously loaded deferred user tool as inline, the old schema message remains in canonical context while shapeHistory merely hides it from the provider view. Because this branch returns false for registered inline tools, isInactiveLoadedTool() still sees the stale loaded name and rejects the next valid inline tool call as “no longer active” before the executor can run it; this affects tools that change disclosure from deferred to inline during a session.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 861d61c496

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@7Sageer
7Sageer merged commit f06eb5c into MoonshotAI:main Jul 24, 2026
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.

2 participants