Repository navigation
update test - #1189
update test#1189
Conversation
WalkthroughAdds multi-step tool orchestration to the llmDummy test agent and updates the test to validate tool_calls propagation across assistant/tool turns, including a follow-up assistant turn signaling continuation. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User/Test
participant A as llmDummy Agent
participant T as Tool
U->>A: Send messages (namedInputs)
A-->>U: Assistant with tool_calls (when tool is set)
A->>T: Invoke tool with arguments
T-->>A: Tool response (role: tool)
A-->>U: Assistant message "tool" (continue flow)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ 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 comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
llm_agents/tools_agent/tests/test_tools.ts (3)
47-56: Avoid duplicating tool_calls at top-level and inside message unless both are requiredYou return tool_calls both in message.tool_calls and at the top level, plus tool. If toolsAgent only needs tool and the assistant message carries tool_calls, consider dropping the top-level tool_calls to reduce duplication. If both are required by consumers, keep as-is.
If optional, a minimal trim could be:
if (tool) { return { message: { role: "assistant", tool_calls: [tool], }, - tool, - tool_calls: [tool], + tool, }; }
88-90: tools: [{}] placeholder may confuse schema expectationsYou pass tools: [{}] in tests with a comment explaining it’s a placeholder. If permissible, consider tools: [] for the “no tools” case or a minimal valid schema object where a tool is expected. This reduces confusion around what fields are actually required by toolsAgent.
Example for the “no tools” case:
- tools: [{}], // In fact, you set the tools schema here. + tools: [],Also applies to: 124-126, 191-193
170-170: Use a clearer continuation signal than literal "tool"A magic string like "tool" can be brittle. Consider a clearer sentinel (e.g., "continue") or an explicit flag (e.g., continue: true) in the agent output, and assert on that in tests.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
llm_agents/tools_agent/tests/test_tools.ts(6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
llm_agents/tools_agent/tests/test_tools.ts (1)
agent_filters/http_client_agent_filter/lib/http_client.js (1)
messages(34-34)
🔇 Additional comments (4)
llm_agents/tools_agent/tests/test_tools.ts (4)
29-46: Tool-selection logic reads cleanly and returns null when no tool is applicableThe desugaring from prompt to a specific tool call is straightforward and correctly falls back to null.
41-41: Argument update for textSpeach scenario is consistent with the new expectationsThe updated arguments align with the test’s expected transcript.
69-69: LGTM: default assistant replyThe neutral assistant response for the no-tool path matches the test.
57-64: Prompt forwarding on follow-ups is correctly omitted
Verified that onlymessages—notprompt—are passed in the follow-up LLM call, so the continuation guard (last.role === "tool") will fire and prevent an infinite loop.• In src/tools_agent.ts, under
toLLMToolCallAgentResponse.graph.nodes.toolsResponseLLM, theinputsobject is{ messages: ":toolsMessages" }with nopromptfield.
• The initial LLM invocation still usesprompt: userInput.text, but all subsequent calls derive solely from the accumulatedmessagesarray.
|
|
||
| const llmDummy: AgentFunction = async ({ namedInputs }) => { | ||
| const { prompt } = namedInputs; | ||
| const { prompt, messages } = namedInputs; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Default messages to an empty array to avoid undefined access
messages may be undefined; accessing messages.length would throw. Default it defensively.
- const { prompt, messages } = namedInputs;
+ const { prompt, messages = [] } = namedInputs;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const { prompt, messages } = namedInputs; | |
| const { prompt, messages = [] } = namedInputs; |
🤖 Prompt for AI Agents
In llm_agents/tools_agent/tests/test_tools.ts around line 27, the test
destructures namedInputs but does not provide a default for messages, so
messages can be undefined and accessing messages.length will throw; fix by
defaulting messages to an empty array when destructuring (or immediately after)
so subsequent code can safely call array methods.
Summary by CodeRabbit
New Features
Tests