Skip to content

improve error log - #1206

Merged
isamu merged 3 commits into
receptron:mainfrom
isamu:improveErrorLog
Aug 15, 2025
Merged

isamu merged 3 commits into
receptron:mainfrom
isamu:improveErrorLog

Conversation

@isamu

@isamu isamu commented Aug 15, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Public API accepts an optional node identifier to resolve agent metadata per node.
    • Contextual error messages when an agent is not found within a specific node.
  • Refactor

    • Internal lookups now resolve agent metadata with node context for more accurate behavior across nodes.
  • Notes

    • Existing behavior unchanged for known and bypassed agents; no action required unless you use the new optional parameter.

@isamu
isamu requested a review from snakajima August 15, 2025 00:13
@coderabbitai

coderabbitai Bot commented Aug 15, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Updated 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

Cohort / File(s) Summary
Graph core API
packages/graphai/src/graphai.ts
Changed signature to getAgentFunctionInfo(agentId?: string, nodeId?: string). Added error path that throws No agent: {agentId} in {nodeId} node when nodeId is provided and the agent is not found. Preserved existing behavior for known agents and bypass agents.
Node integration
packages/graphai/src/node.ts
All graph.getAgentFunctionInfo calls now pass this.nodeId. Uses of hasGraphData, agent selection, inputSchema, and cacheType now rely on node-scoped lookups. No other control flow or error handling 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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

I’m a rabbit peeking through the code,
Hop by node down every road.
If an agent’s lost, I loudly state,
“Which burrow missed this tidy trait?”
A cheerful hop — now look, it’s clear! 🐇✨

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 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0caf52a and a52ec3b.

📒 Files selected for processing (1)
  • packages/graphai/src/node.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/graphai/src/node.ts
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
packages/graphai/src/graphai.ts (1)

195-197: Refine node-scoped error message and handle unresolved agentId

When 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 inputSchema

We 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 well

Same 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 55f8453 and 7bfbafc.

📒 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 — LGTM

This improves diagnostics without breaking existing one-arg callers.

packages/graphai/src/node.ts (1)

341-341: Agent resolution fallback — LGTM

Using 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.

Comment thread packages/graphai/src/node.ts Resolved
isamu and others added 2 commits August 15, 2025 09:28
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@isamu
isamu merged commit 3778f07 into receptron:main Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants