Repository navigation
Tools iterator - #1207
Tools iterator#1207
Conversation
WalkthroughRefactors the tools agent to run multiple tool invocations in a loop, accumulate per-call messages and results, and route the final aggregation from either the initial text path or collected tool responses. Tests updated to use array-based tool_calls and per-call data payloads. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant ToolsAgent
participant textMessagesResult
participant llmAgent
participant llmToolAgentCallMap
participant toolCallAgent
participant toolsResponseLLM
participant toolsResponseResultMessages
participant FinalAggregator
User->>ToolsAgent: input text
ToolsAgent->>textMessagesResult: build messages [user, current llmCallWithTools]
ToolsAgent->>llmAgent: send messages
llmAgent-->>ToolsAgent: assistant message with tool_calls[]
ToolsAgent->>llmToolAgentCallMap: start loop over llmToolCalls
loop For each llmToolCall
llmToolAgentCallMap->>toolCallAgent: assemble per-call payload (arg, func, tool_call, data)
toolCallAgent-->>llmToolAgentCallMap: toolCallMessagesResult.messages
llmToolAgentCallMap->>toolsResponseLLM: feed per-call messages
toolsResponseLLM-->>toolsResponseResultMessages: per-call LLM output
end
ToolsAgent->>FinalAggregator: choose first non-empty from text path or toolsResponseResultMessages
FinalAggregator-->>User: final result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ Finishing Touches🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
llm_agents/tools_agent/tests/test_tools.ts (1)
72-78: Guard against non-string tool contents in success message
last.contentis assumed to be a string. For resilience (e.g., if a tool returns an object), coerce to string.- content: "success " + last.content, + content: "success " + (typeof last.content === "string" ? last.content : JSON.stringify(last.content)),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
llm_agents/tools_agent/src/tools_agent.ts(2 hunks)llm_agents/tools_agent/tests/test_tools.ts(10 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- llm_agents/tools_agent/src/tools_agent.ts
🔇 Additional comments (6)
llm_agents/tools_agent/tests/test_tools.ts (6)
14-16: LGTM: tool responses now include data payloadsIncluding structured data in tool results aligns with the new multi-step flow and matches expectations asserted in the tests’
extra.datafield.Also applies to: 22-24
36-42: LGTM: array-based tool_calls for multi-step flowsReturning an array of tool calls (with unique ids and arguments) cleanly models the multi-tool sequence and improves extensibility for future steps.
Also applies to: 45-56
117-120: LGTM: initial user message is persistedCapturing the initial user message in the transcript improves traceability in the “no tools” scenario.
165-169: LGTM: single-tool path expectations are consistentThe sequence (assistant tool_calls → tool result with extra payload → assistant success) accurately reflects the updated loop-driven pipeline.
Also applies to: 175-187, 191-191
65-69: Do not remove top-leveltool/tool_calls— they're consumed by tools_agenttools_agent references both keys, so removing the top-level fields would break consumers.
- llm_agents/tools_agent/src/tools_agent.ts — line ~36 references ":llmCallWithTools.tool.id" (justTextMessagesResult).
- llm_agents/tools_agent/src/tools_agent.ts — lines ~47–53 reference/forward ":llmCallWithTools.tool_calls" (llmToolAgentCallMap → inputs.llmToolCalls).
Keep the returned top-level fields as-is, or update these consumers before removing the duplication.
Likely an incorrect or invalid review comment.
263-265: Interleaving verified — no change neededI inspected llm_agents/tools_agent/src/tools_agent.ts. The nested graph maps llmToolCalls (":llmCallWithTools.tool_calls"), uses loop: while ":llmToolCalls", and the node toolsResponseLLM invokes agent ":llmAgent" with messages ":toolCallMessagesResult.messages". That confirms the agent iterates the pre-announced llmToolCalls and calls the LLM between tool executions.
- File: llm_agents/tools_agent/src/tools_agent.ts
- llmToolAgentCallMap / graph.loop: while ":llmToolCalls" (approx. lines 46–61)
- toolCallMessagesResult (approx. lines 82–88)
- toolsResponseLLM → agent ":llmAgent" (approx. lines 107–113)
No changes required.
| }, | ||
| }; | ||
| } | ||
| if (func === "textSpeach") { |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Typo: rename textSpeach → textSpeech for clarity
Minor naming nit. Standard spelling is “Speech.” If you adopt this, ensure consistency across the codebase and tools schema.
- if (func === "textSpeach") {
+ if (func === "textSpeech") {
return {
content: "speech",
data: {
talk: "snow",
},
};
}- name: "toolsTestAgent--textSpeach",
+ name: "toolsTestAgent--textSpeech",- name: "toolsTestAgent--textSpeach",
+ name: "toolsTestAgent--textSpeech",- func: "textSpeach",
+ func: "textSpeech",To find other occurrences you may need to rename:
Also applies to: 53-55, 239-239, 269-269, 277-277
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C2 '\btextSpeach\b'Length of output: 1898
Typo: rename textSpeach → textSpeech
Standard spelling is "speech" — please rename occurrences in the test to keep names and tool schema consistent.
Files / locations to change:
- llm_agents/tools_agent/tests/test_tools.ts:19 — if-check
- llm_agents/tools_agent/tests/test_tools.ts:53 — name
- llm_agents/tools_agent/tests/test_tools.ts:239 — name
- llm_agents/tools_agent/tests/test_tools.ts:269 — name
- llm_agents/tools_agent/tests/test_tools.ts:276 — func
Suggested edits:
- if (func === "textSpeach") {
+ if (func === "textSpeech") {
return {
content: "speech",
data: {
talk: "snow",
},
};
}- name: "toolsTestAgent--textSpeach",
+ name: "toolsTestAgent--textSpeech",(Apply the name change at all three name locations above.)
- func: "textSpeach",
+ func: "textSpeech",Quick check you can run to find any remaining occurrences:
rg -n -C2 '\btextSpeach\b'🤖 Prompt for AI Agents
In llm_agents/tools_agent/tests/test_tools.ts around lines 19–276, there's a
typo using "textSpeach" instead of "textSpeech"; update all occurrences listed
(line 19 if-check, line 53 name, line 239 name, line 269 name, and line 276
func) to "textSpeech" so tests and tool schema match, then run a quick search
(e.g., rg -n '\btextSpeach\b') to ensure no remaining references and update any
additional occurrences found.
Summary by CodeRabbit
New Features
Refactor
Tests
Chores