Skip to content

mapIndex - #1170

Merged
isamu merged 1 commit into
receptron:mainfrom
isamu:mapIndex
Jul 19, 2025
Merged

isamu merged 1 commit into
receptron:mainfrom
isamu:mapIndex

Conversation

@isamu

@isamu isamu commented Jul 19, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added a new optional property to support tracking the index of subgraphs within map operations.
    • Exposed the subgraph index as a public property in relevant classes for enhanced traceability.
  • Bug Fixes

    • None.
  • Tests

    • Added a new test case to validate the updated behavior with subgraph indexing.

@coderabbitai

coderabbitai Bot commented Jul 19, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce a mapIndex property to the GraphAI class and related components. This index is propagated through the graph instantiation process, made available in options and transaction logs, and is now accessible within subgraphs created by the map operation. A new test case was also added to exercise this behavior.

Changes

File(s) Change Summary
agents/vanilla_agents/src/graph_agents/map_agent.ts Passes mapIndex into GraphAI options for each subgraph in the map operation.
packages/graphai/src/graphai.ts, packages/graphai/src/type.ts Adds optional mapIndex property to GraphAI class and GraphOptions type.
packages/graphai/src/node.ts, packages/graphai/src/transaction_log.ts Passes and stores mapIndex in TransactionLog via Node constructor.
agents/vanilla_agents/tests/graph/test_map.ts Adds a new test that instantiates and runs a GraphAI with logging, using the new mapIndex.

Sequence Diagram(s)

sequenceDiagram
    participant MapAgent
    participant GraphAI
    participant Node
    participant TransactionLog

    MapAgent->>GraphAI: new GraphAI(nestedGraphData, agents, { ...graphOptions, mapIndex })
    GraphAI->>Node: new Node(nodeId, this)
    Node->>TransactionLog: new TransactionLog(nodeId, graph.mapIndex)
Loading

Poem

A hop, a skip, a mapIndex hop,
Now every subgraph knows its spot!
From options passed to logs so neat,
Each node’s aware, the loop’s complete.
With tests that run and logs that show,
The graph’s new order’s all aglow!
🗺️🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

agents/vanilla_agents/src/graph_agents/map_agent.ts

Oops! Something went wrong! :(

ESLint: 9.31.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

agents/vanilla_agents/tests/graph/test_map.ts

Oops! Something went wrong! :(

ESLint: 9.31.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

packages/graphai/src/graphai.ts

Oops! Something went wrong! :(

ESLint: 9.31.0

ESLint couldn't find an eslint.config.(js|mjs|cjs) file.

From ESLint v9.0.0, the default configuration file is now eslint.config.js.
If you are using a .eslintrc.* file, please follow the migration guide
to update your configuration file to the new format:

https://eslint.org/docs/latest/use/configure/migration-guide

If you still have problems after following the migration guide, please stop by
https://eslint.org/chat/help to chat with the team.

  • 3 others
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70b4004 and bfc8ff0.

📒 Files selected for processing (6)
  • agents/vanilla_agents/src/graph_agents/map_agent.ts (1 hunks)
  • agents/vanilla_agents/tests/graph/test_map.ts (2 hunks)
  • packages/graphai/src/graphai.ts (3 hunks)
  • packages/graphai/src/node.ts (1 hunks)
  • packages/graphai/src/transaction_log.ts (1 hunks)
  • packages/graphai/src/type.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/graphai/src/node.ts (1)
packages/graphai/src/transaction_log.ts (1)
  • TransactionLog (7-93)
⏰ 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 (6)
packages/graphai/src/type.ts (1)

103-103: LGTM! Clean type definition addition.

The optional mapIndex property is correctly typed and follows TypeScript conventions. This provides type safety for the mapIndex feature throughout the codebase.

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

25-28: LGTM! Proper constructor parameter and assignment.

The constructor correctly accepts the optional mapIndex parameter and assigns it to the instance property. This aligns well with the existing property declaration and enables mapIndex tracking in transaction logs.

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

42-42: LGTM! Correct mapIndex propagation.

The change properly propagates the mapIndex from the GraphAI instance to the TransactionLog constructor, maintaining the context chain from graph to node to transaction log.

packages/graphai/src/graphai.ts (2)

40-40: LGTM! Proper readonly property declaration.

The mapIndex property is correctly declared as readonly and optional, preventing accidental modification while allowing the feature to be optional.


140-140: LGTM! Consistent constructor implementation.

The constructor properly handles the mapIndex option with an explicit default value and correct assignment. This completes the mapIndex feature implementation in the core GraphAI class.

Also applies to: 160-160

agents/vanilla_agents/src/graph_agents/map_agent.ts (1)

57-57: LGTM! Clean implementation of mapIndex propagation.

The modification correctly adds the mapIndex property to each GraphAI instance's options, enabling subgraphs to be aware of their position in the map iteration. The use of object spread syntax with nullish coalescing (??) safely handles undefined graphOptions while preserving all existing configuration.

Comment on lines +52 to +56
test("test map 6", async () => {
const graph = new GraphAI(graphDataMap1, agents);
graph.callbacks = [console.log];
await graph.run();
});

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.

⚠️ Potential issue

Fix duplicate test name and add assertions.

This test has several issues:

  1. Duplicate test name: "test map 6" is used twice (lines 46 and 52)
  2. No assertions: The test doesn't verify that the mapIndex feature works correctly
  3. Missing validation: No verification that mapIndex values are properly set in logs or callbacks

Apply this diff to fix the test name and add meaningful assertions:

-test("test map 6", async () => {
+test("test map with logging", async () => {
   const graph = new GraphAI(graphDataMap1, agents);
-  graph.callbacks = [console.log];
+  const logs: any[] = [];
+  graph.callbacks = [(log) => logs.push(log)];
   await graph.run();
+  
+  // Verify that mapIndex is properly set in transaction logs when using map operations
+  const mapIndexLogs = logs.filter(log => log.mapIndex !== undefined);
+  assert(mapIndexLogs.length > 0, "Expected transaction logs to contain mapIndex when using map operations");
 });
📝 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.

Suggested change
test("test map 6", async () => {
const graph = new GraphAI(graphDataMap1, agents);
graph.callbacks = [console.log];
await graph.run();
});
test("test map with logging", async () => {
const graph = new GraphAI(graphDataMap1, agents);
const logs: any[] = [];
graph.callbacks = [(log) => logs.push(log)];
await graph.run();
// Verify that mapIndex is properly set in transaction logs when using map operations
const mapIndexLogs = logs.filter(log => log.mapIndex !== undefined);
assert(
mapIndexLogs.length > 0,
"Expected transaction logs to contain mapIndex when using map operations"
);
});
🤖 Prompt for AI Agents
In agents/vanilla_agents/tests/graph/test_map.ts around lines 52 to 56, the test
name "test map 6" is duplicated and the test lacks assertions to verify
functionality. Rename the test to a unique name, such as "test map 7", and add
assertions that check the mapIndex feature works correctly by validating that
mapIndex values are properly set and appear in the logs or callbacks during the
graph run.

@isamu
isamu requested a review from snakajima July 19, 2025 04:24
@isamu
isamu merged commit 0d9ea36 into receptron:main Jul 19, 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