Skip to content

Make subagent inherit tools from parent#51

Merged
ezynda3 merged 1 commit into
mark3labs:masterfrom
e4t:subagent_inherit_tools
Jun 9, 2026
Merged

Make subagent inherit tools from parent#51
ezynda3 merged 1 commit into
mark3labs:masterfrom
e4t:subagent_inherit_tools

Conversation

@e4t

@e4t e4t commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

There exist a number of ways to configure what tools are made available to agents:

  1. DisableCoreTools - a boolean which allows to disable all core tools.
  2. CoreTools - an explicit list ([]fantasy.AgentTool) of allowed core tools.
  3. ExtraTools - a list of tools provided by extensions.

Subagent however, receive the static list of subagent tools (core.SubagentTools()) - unless tools are explicitly provided through the API call to kit.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 the kit package.
Please let me know if I should address this differently!

Summary by CodeRabbit

  • Bug Fixes
    • Prevented recursive spawning by excluding the subagent tool from child subagent toolsets.
  • Improvements
    • Child subagents now inherit the parent agent’s active toolset (with subagent excluded), ensuring consistent tool availability across agent hierarchies.
  • Documentation
    • Clarified subagent toolset behavior for SDK-created versus internally spawned subagents.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 901023a6-e9fc-4fac-988f-6e3aa8de6bf1

📥 Commits

Reviewing files that changed from the base of the PR and between 4eabf11 and 1b48842.

📒 Files selected for processing (2)
  • internal/extbridge/extbridge.go
  • pkg/kit/kit.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/extbridge/extbridge.go
  • pkg/kit/kit.go

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Subagent Tool Filtering

Layer / File(s) Summary
Kit tool filtering helper and subagent spawning
pkg/kit/kit.go
Adds func (m *Kit) GetToolsForSubagent() []Tool that returns the current kit's tools excluding any named "subagent". Updates the in-process subagent spawn in Kit.generate() to set the spawned subagent's SubagentConfig.Tools to m.GetToolsForSubagent().
Extension bridge subagent tool filtering
internal/extbridge/extbridge.go
SpawnSubagent now sets the SDK kit.SubagentConfig.Tools using k.GetToolsForSubagent() when converting the extension-facing extensions.SubagentConfig.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A tiny hop through tool-filled woods,
I pick the useful ones with careful shoulds,
Leave out the "subagent" to stop the spin,
Child kits start clean — no loops tucked in,
I nibble a carrot and wink with a grin.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: making subagents inherit tools from their parent agent, which is the core objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between febdc53 and 489b9df.

📒 Files selected for processing (2)
  • internal/extbridge/extbridge.go
  • pkg/kit/kit.go

Comment thread pkg/kit/kit.go Outdated
@mark-iii-labs-huly

Copy link
Copy Markdown

Connected to Huly®: KIT-52

@e4t e4t force-pushed the subagent_inherit_tools branch from 489b9df to 4eabf11 Compare June 9, 2026 12:52

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/kit/kit.go (1)

141-152: ⚡ Quick win

Consider 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

📥 Commits

Reviewing files that changed from the base of the PR and between 489b9df and 4eabf11.

📒 Files selected for processing (2)
  • internal/extbridge/extbridge.go
  • pkg/kit/kit.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/extbridge/extbridge.go

Comment thread pkg/kit/kit.go Outdated
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]>
@e4t e4t force-pushed the subagent_inherit_tools branch from 4eabf11 to 1b48842 Compare June 9, 2026 12:59
@ezynda3 ezynda3 merged commit ef072f6 into mark3labs:master Jun 9, 2026
3 checks passed
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