core: refactor tool system to remove agent context from initialization#21052
Open
core: refactor tool system to remove agent context from initialization#21052
Conversation
Simplify tool initialization by removing unnecessary agent context parameter from tool.init() calls. This makes tool behavior more predictable and consistent regardless of which agent is using them. Replace hardcoded named tool references (registry.named.task, registry.named.read) with a cleaner fromID() lookup method that works for any tool. Update TaskTool to display all available subagents without permission-based filtering, making it easier to discover and use subagents from any context.
Skills are now displayed in alphabetical order when listing available skills, making it easier for users to locate specific skills in the output.
Contributor
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Member
Author
|
fyi this removes the agent permission filtering from tool init - we'll need to add that back at execution time instead. right now task/skill tools show everything regardless of whether the agent can actually use them. |
Document two approaches for handling synthetic messages in prompt hooks: - Option 1: Separate PromptMessage type for lightweight prompt surgery - Option 2: PromptEditor API with append/prepend/insert mutators This enables plugin developers to inject instructions or context into prompts without manually fabricating message IDs and timestamps. The design supports resumable sessions while keeping the API simple for common prompt manipulation use cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor the tool system to simplify initialization and remove unnecessary agent context dependencies. This makes tool behavior more predictable and consistent across different agents.
Changes
agentparameter fromTool.init()calls - tools no longer need to know which agent is using them during initializationnamedproperty with cleanerfromID()method for dynamic tool lookupWhy
Previously, tools received agent context during initialization which led to:
init()registry.named.task,registry.named.read)Now tools are initialized once and behave consistently regardless of the calling agent.