Repository navigation
add test - #1187
add test#1187
Conversation
WalkthroughAdds a new TypeScript end-to-end test file that validates LLM-produced tool_calls are executed by a Tools Agent in GraphAI across two scenarios, asserting exact tool outputs, message sequences, and propagated metadata. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User Input
participant Graph as GraphAI
participant LLM as Dummy LLM Agent
participant Tools as Tools Agent
participant Results as Result Messages
User->>Graph: send prompt ("testWithNext" / "test1")
Graph->>LLM: deliver messages (system + user)
LLM-->>Graph: assistant message with tool_call
Graph->>Tools: invoke tool (agent, func, arg)
Tools-->>Graph: return tool response (content, hasNext?, metadata)
Graph->>Results: append tool result message and metadata
Graph->>LLM: continue if needed
LLM-->>Graph: final assistant message (no tool_call)
Graph-->>User: return tools data + full message sequence
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous 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 comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (6)
llm_agents/tools_agent/tests/test_tools.ts (6)
58-58: Give each test a distinct nameHaving two tests named "test tools" is confusing in runners and reports. Rename to reflect scenarios.
-test("test tools", async () => { +test("tools agent with hasNext flow", async () => {-test("test tools", async () => { +test("tools agent simple weather", async () => {Also applies to: 126-126
148-148: Remove stray console.log from test outputThis pollutes CI logs without adding value.
- console.log(JSON.stringify(res, null, 2)); + // console.log(JSON.stringify(res, null, 2));
47-54: Guard against unknown prompts to avoid undefined tool_callsIf prompt is unexpected, tool becomes undefined and you’ll emit
[undefined]in tool_calls. Make it robust.- return { - message: { - role: "assistant", - tool_calls: [tool], - }, - tool, - tool_calls: [tool], - }; + if (!tool) { + return { + message: { role: "assistant", tool_calls: [] }, + tool_calls: [], + }; + } + return { + message: { role: "assistant", tool_calls: [tool] }, + tool, + tool_calls: [tool], + };
123-123: Swap assert.deepStrictEqual argument order to (actual, expected)Conventional order improves failure messages and readability.
- assert.deepStrictEqual(expect, res); + assert.deepStrictEqual(res, expect);- assert.deepStrictEqual(expect, res); + assert.deepStrictEqual(res, expect);Also applies to: 185-185
17-22: Fix typo: “textSpeach” → “textSpeech” across code and expectationsSpelling consistency helps avoid future confusion.
- if (func === "textSpeach") { + if (func === "textSpeech") {- name: "toolsTestAgent--textSpeach", + name: "toolsTestAgent--textSpeech",- "toolsTestAgent--textSpeach": { + "toolsTestAgent--textSpeech": {- name: "toolsTestAgent--textSpeach", + name: "toolsTestAgent--textSpeech",- name: "toolsTestAgent--textSpeach", + name: "toolsTestAgent--textSpeech",- func: "textSpeach", + func: "textSpeech",If you’d like, I can provide a repo-wide codemod to update all occurrences.
Also applies to: 41-43, 85-89, 96-97, 106-107, 113-114
2-2: Remove unused importdefaultTestContext is imported but not used in this test file.
-import { defaultTestContext } from "graphai";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
llm_agents/tools_agent/tests/test_tools.ts(1 hunks)
🔇 Additional comments (1)
llm_agents/tools_agent/tests/test_tools.ts (1)
10-24: Good test tools agent stub; clear hasNext coverageThe dummy tools agent is concise and models both a simple tool and a hasNext flow well. This gives meaningful end-to-end coverage.
Summary by CodeRabbit