Skip to content

test(kit): Add test for GetToolsForSubagent()#73

Open
e4t wants to merge 1 commit into
mark3labs:masterfrom
e4t:test_agent_inheritance_by_subagents
Open

test(kit): Add test for GetToolsForSubagent()#73
e4t wants to merge 1 commit into
mark3labs:masterfrom
e4t:test_agent_inheritance_by_subagents

Conversation

@e4t

@e4t e4t commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

GetToolsForSubagent() was added in commit:
Make subagent inherit tools from parent (#51)
ef072f6
to collect all tools from the main agent but exclude the 'subagent' tool. The resulting tool list may be passed to the Tools argument of SubagentConfig.

The test works as follows:

  1. The main 'kit' instance is configured with a CoreToolList only containing 'subagent' and 'bash'.
  2. A 'hello' tool is provided as ExtraTools in kit.Options. In this case, the main 'kit' instance will only have the 'subagent', 'bash' and 'hello' tool. GetToolsForSubagent() should filter out the 'subagent' tool. GetToolsForSubagent() is called and the result is checked against the expected list.

Summary by CodeRabbit

  • Tests
    • Added coverage to ensure subagent tool availability behaves correctly when core tools are disabled.
    • Verified that subagent does not include the core subagent tool, while still exposing both custom extra tools and remaining allowed core tools.

@mark-iii-labs-huly

Copy link
Copy Markdown

Connected to Huly®: KIT-74

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new test for GetToolsForSubagent in pkg/kit/kit_test.go. The test builds a custom tool, configures core and extra tools, and verifies the returned list includes the expected tools and excludes subagent.

Changes

GetToolsForSubagent test

Layer / File(s) Summary
TestGetToolsForSubagent case
pkg/kit/kit_test.go
Adds a test that registers hello, configures NoExtensions, CoreToolList, and ExtraTools, then asserts GetToolsForSubagent() returns hello and bash and omits subagent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

  • mark3labs/kit#51: Implements GetToolsForSubagent() and the subagent spawning behavior that this test exercises.
  • mark3labs/kit#57: Changes subagent tool handling under DisableCoreTools, which matches the configuration path used here.

Poem

🐇 Hello hops in with a carrot and grin,
Bash tags along while subagent stays thin.
The tool list is tidy, the test gives a cheer,
A small bunny check for the right tools here.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a test for GetToolsForSubagent().
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

@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: 2

🤖 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_test.go`:
- Around line 675-676: The HelloInput.Query struct field in kit_test.go uses a
non-standard JSON tag, so update its tag to follow the repository’s snake_case
convention and keep the schema key consistent; locate the Query field in
HelloInput and change the json tag to a snake_case name, using omitempty if that
field is optional.
- Around line 695-711: The subagent test is asserting model prose in
result.Response instead of the actual tool selection, so update the test around
host.Subagent and host.GetToolsForSubagent() to directly inspect the returned
tool set and verify the expected tools are present or absent. Use the
SubagentConfig setup as-is, but replace the “hello”/“subagent” string checks
with assertions on the tool list/filtering behavior so the test validates
GetToolsForSubagent() deterministically.
🪄 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: 77a6fe3c-365c-4359-a6d2-3430636210c0

📥 Commits

Reviewing files that changed from the base of the PR and between ad9aa06 and bc7f670.

📒 Files selected for processing (1)
  • pkg/kit/kit_test.go

Comment thread pkg/kit/kit_test.go Outdated
Comment thread pkg/kit/kit_test.go Outdated
@e4t e4t force-pushed the test_agent_inheritance_by_subagents branch from bc7f670 to 6e2c5ca Compare June 24, 2026 10:59
`GetToolsForSubagent()` was added in commit:
   Make subagent inherit tools from parent (mark3labs#51)
   ef072f6
to collect all tools from the main agent but exclude the 'subagent'
tool. The resulting tool list may be passed to the `Tools` argument
of `SubagentConfig`.

The test works as follows:
1. The main 'kit' instance is configured with a `CoreToolList`
   only containing 'subagent' and 'bash'.
2. A 'hello' tool is provided as `ExtraTools` in `kit.Options`.
In this case, the main 'kit' instance will only have the 'subagent',
'bash' and 'hello' tool. `GetToolsForSubagent()` should filter out
the 'subagent' tool.
`GetToolsForSubagent()` is called and the result is checked
against the expected list.

Signed-off-by: Egbert Eich <eich@suse.com>
@e4t e4t force-pushed the test_agent_inheritance_by_subagents branch from 6e2c5ca to d0437f9 Compare June 24, 2026 14:13
@e4t

e4t commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

The linter issues seen in the CI are false positives and not related to the changes I've submitted:

  Error: internal/models/custom_test.go:23:6: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
  		if p == nil {
  		   ^
  Error: internal/models/custom_test.go:26:8: SA5011: possible nil pointer dereference (staticcheck)
  		if p.Temperature == nil || *p.Temperature != 0.7 {
  		     ^

apparently, the linter doesn't recognize that a call to test.Fatal() does not return. I cannot reproduce these locally so I'm unsure on how exactly to 'whitelist' then.

@ezynda3

ezynda3 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@e4t can you try pulling in the latest changes and see if that fixes it?

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