Make subagent inherit tools from parent#51
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds Kit.GetToolsForSubagent() to return the agent's tools without "subagent", uses it when Kit spawns in-process subagents, and sets the same filtered tool list in extbridge.SpawnSubagent's conversion to kit.SubagentConfig. ChangesSubagent Tool Filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/kit/kit.go`:
- Around line 141-152: Kit.Subagent currently falls back to the static
SubagentTools() when its config.tools is nil, preventing inheritance from the
parent; change Subagent() so that when config.tools is nil it uses
m.GetToolsForSubagent() (the filtered parent tool list that excludes the
"subagent" tool) instead of SubagentTools(), and ensure any downstream uses of
SubagentTools() remain for the static default only when you explicitly want the
core set rather than inheriting from m.agent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d9c54e98-e989-4879-bd27-dbc52546a88c
📒 Files selected for processing (2)
internal/extbridge/extbridge.gopkg/kit/kit.go
|
Connected to Huly®: KIT-52 |
489b9df to
4eabf11
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/kit/kit.go (1)
141-152: ⚡ Quick winConsider extracting "subagent" as a package constant.
The hardcoded string
"subagent"on line 146 couples this package to internal/core knowledge of the tool name. If the subagent tool is ever renamed, this filter silently breaks. A named constant (e.g.,const subagentToolName = "subagent") would make the dependency explicit and ease future refactoring.♻️ Proposed refactor
Add a constant near the top of the file:
const subagentToolName = "subagent"Then use it in the filter:
func (m *Kit) GetToolsForSubagent() []Tool { var tools []Tool for _, t := range m.agent.GetTools() { - if t.Info().Name == "subagent" { + if t.Info().Name == subagentToolName { continue } tools = append(tools, t) } return tools }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/kit/kit.go` around lines 141 - 152, Extract the hardcoded "subagent" string into a package-level constant and use it in GetToolsForSubagent to make the dependency explicit; add something like const subagentToolName = "subagent" near the top of the file and replace the literal check if t.Info().Name == "subagent" with if t.Info().Name == subagentToolName so GetToolsForSubagent, m.agent.GetTools(), and t.Info().Name reference the constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/kit/kit.go`:
- Line 141: Update the godoc comment to match the actual exported function name:
replace the plural "GetToolsForSubagents" with the singular
"GetToolsForSubagent" in the comment above the GetToolsForSubagent function so
the docstring accurately reflects the method name and purpose.
---
Nitpick comments:
In `@pkg/kit/kit.go`:
- Around line 141-152: Extract the hardcoded "subagent" string into a
package-level constant and use it in GetToolsForSubagent to make the dependency
explicit; add something like const subagentToolName = "subagent" near the top of
the file and replace the literal check if t.Info().Name == "subagent" with if
t.Info().Name == subagentToolName so GetToolsForSubagent, m.agent.GetTools(),
and t.Info().Name reference the constant.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 72529a03-17c0-49d8-a13e-cc9c56693073
📒 Files selected for processing (2)
internal/extbridge/extbridge.gopkg/kit/kit.go
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/extbridge/extbridge.go
While the tool list of the main agent could be controlled by several options, subagent used to be equipped with all available tools (except for the subagent tool itself). With this change the list of tools is taken from the parent, the subagent tool itself is removed and the remaining tool list is added to the subagent. Signed-off-by: Egbert Eich <[email protected]>
4eabf11 to
1b48842
Compare
There exist a number of ways to configure what tools are made available to agents:
[]fantasy.AgentTool) of allowed core tools.Subagent however, receive the static list of subagent tools (
core.SubagentTools()) - unless tools are explicitly provided through the API call tokit.Subagent(). This ignores all settings concerning tools for the main agent. This affects subagents created in the TUI as the tools list provided in the subagent configuration will always be empty.IHMO, subagent should inherit tools from the main agent unless an explicit list of tools has been provided.
This patch provides this: It retrieves the list of agent tools, removes the subagent tool and adds it to the subagent configuration with the subagent tool itself removed.
The removal of the subaagent tool makes this change slightly ugly as it adds knowledge about details from
internal/core(name of subagent tool) known to thekitpackage.Please let me know if I should address this differently!
Summary by CodeRabbit