Repository navigation
fix: unable use agent as a tool in agent component - #17228
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAgent parameters now support descriptions and nested sub-agents. Canvas configuration parses child Agents into dynamic tools, which invoke child components with structured prompts and return their output. Tests cover parsing, tool metadata, invocation, depth handling, and prompt forwarding. ChangesAgent sub-agent tooling
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CanvasConfig
participant ParentAgent
participant subAgentTool
participant ChildAgent
CanvasConfig->>ParentAgent: provide Agent tool specification
ParentAgent->>subAgentTool: build dynamic tool
ParentAgent->>subAgentTool: invoke with JSON arguments
subAgentTool->>ChildAgent: invoke with forwarded prompt sections
ChildAgent-->>subAgentTool: return agent output
subAgentTool-->>ParentAgent: return content or JSON output
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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: 3
🧹 Nitpick comments (1)
internal/agent/component/agent_test.go (1)
626-658: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSolid happy-path coverage; consider adding an error-path case.
Covers argument decoding → child invocation → prompt-forwarding well. Consider adding a case for malformed
argsJSONto lock in thejson.Unmarshalerror-wrapping behavior insubAgentTool.InvokableRun.🤖 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 `@internal/agent/component/agent_test.go` around lines 626 - 658, Extend TestAgent_SubAgentToolInvokableRunCallsChildAgent with a malformed argsJSON case that calls subAgentTool.InvokableRun, asserts an error is returned, and verifies the error preserves the json.Unmarshal failure context through the expected wrapping. Ensure the child agent is not invoked for invalid arguments.
🤖 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 `@internal/agent/component/agent.go`:
- Around line 543-552: Thread a nested-agent depth counter through the context
used by sub-agent invocation: update subAgentTool.InvokableRun and the
NewAgentComponent/Invoke path to increment and validate depth before creating
another child agent, returning a clear error when the configured maximum is
reached. Ensure the guard applies transitively across buildAgentTools and
recursive canvas parsing, while preserving normal invocation behavior within the
allowed depth.
- Around line 1432-1499: Update agentParamFromMap to reuse mergeAgentParam for
user_prompt parsing instead of assigning the schema default as a literal prompt.
Ensure both New("Agent", ...) and embedded sub-agents interpret the placeholder
consistently, while preserving the existing fallback behavior when no parsed
user prompt is available.
- Around line 605-647: Update normalizeAgentToolName and the buildAgentTools
flow to guarantee unique sub-agent tool names, including names that normalize to
"agent" or otherwise collide. Track already-used names and either reject
duplicates clearly or assign a deterministic collision-resistant suffix before
appending each tool, ensuring every registered sub-agent remains callable.
---
Nitpick comments:
In `@internal/agent/component/agent_test.go`:
- Around line 626-658: Extend TestAgent_SubAgentToolInvokableRunCallsChildAgent
with a malformed argsJSON case that calls subAgentTool.InvokableRun, asserts an
error is returned, and verifies the error preserves the json.Unmarshal failure
context through the expected wrapping. Ensure the child agent is not invoked for
invalid arguments.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3bf7af43-dd94-4976-bb9f-2d408abea803
📒 Files selected for processing (2)
internal/agent/component/agent.gointernal/agent/component/agent_test.go
|
LGTM |
Summary
As title