Repository navigation
improve error log - #1206
improve error log#1206
Conversation
WalkthroughUpdated GraphAI.getAgentFunctionInfo to accept an optional nodeId and added a node-scoped error when an agentId is missing. Updated node.ts to pass nodeId to all getAgentFunctionInfo calls, affecting hasGraphData checks, agent retrieval, input schema, and cache type. No other logic changes. Changes
Sequence Diagram(s)sequenceDiagram
participant Node
participant GraphAI
Node->>GraphAI: getAgentFunctionInfo(agentId, nodeId)
alt agent found in dictionary
GraphAI-->>Node: { agent, hasGraphData, inputs, cacheType }
else agentId in bypass list
GraphAI-->>Node: { hasGraphData: false, ...stub }
else not found and nodeId provided
GraphAI-->>Node: throw Error("No agent: {agentId} in {nodeId} node")
else not found and no nodeId
GraphAI-->>Node: throw Error("No agent: {agentId}")
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 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 as they are similar to previous changes (1)
✨ 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: 2
🧹 Nitpick comments (3)
packages/graphai/src/graphai.ts (1)
195-197: Refine node-scoped error message and handle unresolved agentIdWhen agentId is undefined, the current message prints “undefined,” which is less actionable. Minor tweak improves clarity.
Apply this diff:
- if (nodeId) { - throw new Error(`No agent: ${agentId} in ${nodeId} node`); - } + if (nodeId) { + const id = agentId ?? "<unresolved>"; + throw new Error(`No agent "${id}" referenced by node "${nodeId}"`); + }Optionally, I can add targeted tests asserting the refined message. Want me to follow up?
packages/graphai/src/node.ts (2)
461-461: Avoid duplicate lookups and add a type guard for inputSchemaWe call getAgentFunctionInfo multiple times. Cache it once with a type guard to reduce lookups and avoid accidental calls with non-string agentId.
Apply this diff to Line 461:
- inputSchema: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(agentId, this.nodeId)?.inputs, + inputSchema: agentInfo?.inputs,And define agentInfo once near the top of getContext (outside this hunk):
// Insert near the start of getContext(), after computing params and before constructing `context` const agentInfo = !this.agentFunction && typeof agentId === "string" ? this.graph.getAgentFunctionInfo(agentId, this.nodeId) : undefined;
464-464: Reuse cached agentInfo for cacheType as wellSame rationale as inputSchema: fewer lookups, proper type guard.
Apply this diff to Line 464:
- cacheType: this.agentFunction ? undefined : this.graph.getAgentFunctionInfo(agentId, this.nodeId)?.cacheType, + cacheType: agentInfo?.cacheType,
📜 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)
packages/graphai/src/graphai.ts(2 hunks)packages/graphai/src/node.ts(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/graphai/src/graphai.ts (1)
agent_filters/http_client_agent_filter/lib/http_client.js (1)
agentId(68-68)
⏰ 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)
- GitHub Check: build (24.x)
- GitHub Check: build (22.x)
🔇 Additional comments (2)
packages/graphai/src/graphai.ts (1)
180-180: Add nodeId to getAgentFunctionInfo for contextual errors — LGTMThis improves diagnostics without breaking existing one-arg callers.
packages/graphai/src/node.ts (1)
341-341: Agent resolution fallback — LGTMUsing the locally set this.agentFunction when present avoids unnecessary dictionary lookups and prevents errors on function-based agents.
| } | ||
|
|
||
| public getAgentFunctionInfo(agentId?: string) { | ||
| public getAgentFunctionInfo(agentId?: string, nodeId?: string) { |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Confirm all call sites are compatible with the new signature
The second parameter is optional, so one-arg callers should remain valid. Still, verify that all dynamic/late-resolved agent lookups pass nodeId where available to benefit from the improved error message.
Run this to list all call sites and confirm usage patterns:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== All call sites of getAgentFunctionInfo =="
rg -n -C2 -P '\bgetAgentFunctionInfo\s*\('
echo
echo "== Call sites that do NOT pass nodeId (2nd argument) =="
# Heuristic: lines with only 1 argument inside the parens
rg -n -C2 -P '\bgetAgentFunctionInfo\s*\(\s*[^,)\s][^,)]*\)'Length of output: 7411
Rebuild artifacts & docs — source call sites updated, lib/docs still show old signature
Findings (from ripgrep):
- Source call sites pass nodeId: packages/graphai/src/node.ts (lines ~328, 341, 461).
- Out-of-date compiled/docs still omit nodeId or show old signature:
- packages/graphai/lib/graphai.d.ts
- packages/graphai/lib/graphai.js
- packages/graphai/lib/node.js
- docs/apiDocMd/classes/GraphAI.md
Action required:
- Rebuild/regenerate the package so lib/.js, lib/.d.ts and generated docs reflect the new (optional) second parameter.
- After rebuild, re-run the search to confirm no remaining source call sites unintentionally omit nodeId when it can be provided.
🤖 Prompt for AI Agents
In packages/graphai/src/graphai.ts around line 180, the public signature was
updated to accept an optional nodeId but the compiled artifacts and generated
docs were not rebuilt; regenerate the package so lib/graphai.js,
lib/graphai.d.ts, lib/node.js and docs/apiDocMd/classes/GraphAI.md reflect the
new (optional) nodeId parameter, run the TypeScript build/publish task (or npm
run build) to produce updated lib files, regenerate API docs, and then re-run
ripgrep across the repo to verify source call sites (notably
packages/graphai/src/node.ts at the reported call sites ~lines 328, 341, 461)
either supply nodeId where available or intentionally omit it.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
Refactor
Notes