Skip to content

Separate agent filter - #1204

Merged
isamu merged 3 commits into
receptron:mainfrom
isamu:separateAgentFilter
Aug 14, 2025
Merged

isamu merged 3 commits into
receptron:mainfrom
isamu:separateAgentFilter

Conversation

@isamu

@isamu isamu commented Aug 14, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Updated import sources for cache and streaming agent filters across samples and test utilities with no functional changes.
  • Chores
    • Replaced a development dependency to align with the updated package structure.

@coderabbitai

coderabbitai Bot commented Aug 14, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@isamu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 56 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 716e3b7 and ce20b7a.

📒 Files selected for processing (1)
  • packages/test_utils/package.json (2 hunks)

Walkthrough

Updated import sources to new package names in samples and test utils, and replaced a devDependency accordingly. No symbol renames, API changes, or control-flow modifications.

Changes

Cohort / File(s) Summary of changes
Samples import path updates
packages/samples/src/cache/cache_example.ts, packages/samples/src/streaming/streamAgentFilter.ts
Switched imports from @graphai/agent_filters to specific packages: @graphai/cache_agent_filter and @graphai/stream_agent_filter. No code logic changes.
Test utils dependency and import updates
packages/test_utils/package.json, packages/test_utils/src/test_runner.ts
Replaced devDependency @graphai/agent_filters with @graphai/namedinput_validator_agent_filter. Updated corresponding import path in test_runner.ts. No API/signature changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~6 minutes

Poem

A rabbit taps keys with delighted cheer,
Imports hop paths—now crystal clear.
Cache and stream, they find new homes,
Tests align where the hare now roams.
Dependencies trimmed, neat and bright—
Thump-thump! The code feels light. 🐇✨

✨ Finishing Touches
🧪 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: 3

🔭 Outside diff range comments (2)
packages/samples/src/cache/cache_example.ts (2)

14-21: setCache resolves before the write completes and drops DB errors

The Promise resolves immediately after scheduling db.run, so callers may proceed before the write actually finishes. Errors (including unique constraint violations) are silently ignored.

Apply this diff to await the write and handle conflicts/errors:

-const setCache = async (key: string, data: any) => {
-  await new Promise((resolve) => {
-    db.serialize(() => {
-      db.run("insert into cache(key, data) values(?,?)", key, JSON.stringify(data));
-      resolve(null);
-    });
-  });
-};
+const setCache = async (key: string, data: unknown): Promise<void> => {
+  await new Promise<void>((resolve, reject) => {
+    db.run(
+      // Upsert so the same key updates instead of throwing on UNIQUE
+      'insert into cache(key, data) values(?, ?) on conflict(key) do update set data = excluded.data',
+      [key, JSON.stringify(data)],
+      (err) => {
+        if (err) return reject(err);
+        resolve();
+      },
+    );
+  });
+};

Note: If your SQLite version is too old for ON CONFLICT DO UPDATE, switch to “insert or replace into cache(key, data) values(?, ?)” as a fallback.


23-35: getCache ignores DB errors and contains unreachable code

  • db.all callback’s err is ignored, potentially masking DB issues.
  • db.all fetches all rows but only the first is used; db.get is more appropriate.
  • The final “return null” after the Promise is unreachable.

Apply this diff to properly handle errors, fetch a single row, and remove unreachable code:

-const getCache = async (key: string) => {
-  return new Promise((resolve) => {
-    db.serialize(() => {
-      db.all("select * from cache where key = ?", key, (err, rows) => {
-        if (rows && rows[0]) {
-          console.log("cache hit");
-          resolve(JSON.parse((rows[0] as any).data));
-        } else {
-          resolve(null);
-        }
-      });
-    });
-  });
-  return null;
-};
+const getCache = async (key: string): Promise<unknown | null> => {
+  return await new Promise((resolve, reject) => {
+    db.get("select data from cache where key = ?", [key], (err, row) => {
+      if (err) return reject(err);
+      if (row && (row as any).data) {
+        try {
+          resolve(JSON.parse((row as any).data));
+        } catch (e) {
+          return reject(e);
+        }
+      } else {
+        resolve(null);
+      }
+    });
+  });
+};
🧹 Nitpick comments (1)
packages/samples/src/streaming/streamAgentFilter.ts (1)

6-10: Typo: outSideFunciton → outSideFunction

Minor readability nit.

Apply this diff to fix the typo and its usage:

-const outSideFunciton = (context: AgentFunctionContext, data: string) => {
+const outSideFunction = (context: AgentFunctionContext, data: string) => {
   const nodeId = context.debugInfo.nodeId;
   streamData[nodeId] = (streamData[nodeId] || "") + data;
   console.log(streamData);
 };
@@
   {
     name: "streamAgentFilter",
-    agent: streamAgentFilterGenerator<string>(outSideFunciton),
+    agent: streamAgentFilterGenerator<string>(outSideFunction),
   },

Also applies to: 15-15

📜 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 settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6fb5f04 and 716e3b7.

📒 Files selected for processing (4)
  • packages/samples/src/cache/cache_example.ts (1 hunks)
  • packages/samples/src/streaming/streamAgentFilter.ts (1 hunks)
  • packages/test_utils/package.json (1 hunks)
  • packages/test_utils/src/test_runner.ts (1 hunks)
⏰ 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 (22.x)
  • GitHub Check: build (24.x)
🔇 Additional comments (1)
packages/samples/src/streaming/streamAgentFilter.ts (1)

2-2: Import path migration looks good

No API change; usage remains the same.

import { GraphAI } from "graphai";
import * as vanilla_agents from "@graphai/vanilla";
import { cacheAgentFilterGenerator } from "@graphai/agent_filters";
import { cacheAgentFilterGenerator } from "@graphai/cache_agent_filter";

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

Import path migration looks good

The symbol and usage remain unchanged; this aligns with the package split to dedicated agent-filter modules.

Run this script to verify that:

  • No lingering imports from @graphai/agent_filters remain.
  • The new packages are referenced in the appropriate package.json files.

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "[1] Search for legacy imports from @graphai/agent_filters"
rg -n --no-ignore-vcs '@graphai/agent_filters' || true

echo
echo "[2] Ensure new filter packages are declared in package.json"
fd -a package.json | while read -r f; do
  echo "---- $f"
  rg -n '"@graphai/(cache_agent_filter|stream_agent_filter|namedinput_validator_agent_filter)"' "$f" || true
done

echo
echo "[3] Ensure no package.json still depends on @graphai/agent_filters"
rg -n --no-ignore-vcs '"@graphai/agent_filters"' || true

Length of output: 12413


Import path migration mostly OK — leftover @graphai/agent_filters references found

Import in packages/samples/src/cache/cache_example.ts is correct: import { cacheAgentFilterGenerator } from "@graphai/cache_agent_filter";

However verification found remaining legacy references that must be updated:

  • packages/samples/htmlSample/chat-sample.html:6 — CDN script tag referencing @graphai/[email protected] (update CDN to new packages or remove).
  • packages/test_utils/lib/test_runner.js:42 — const agent_filters_1 = require("@graphai/agent_filters"); (update the source import and rebuild so lib/ doesn't require the legacy package).
  • packages/agent_filters/package.json — still defines "name": "@graphai/agent_filters" (leftover package).
  • packages/agent_filters/README.md — contains yarn add and import examples referencing @graphai/agent_filters.
  • agent_filters/namedinput_validator_agent_filter/README.md:20 — README imports @graphai/agent_filters.

package.jsons do contain the new packages (e.g., @graphai/cache_agent_filter, @graphai/stream_agent_filter, @graphai/namedinput_validator_agent_filter in packages/agent_filters/package.json, packages/cli/package.json, packages/test_utils/package.json).

Action required: update/remove the legacy references listed above (CDN, built artifacts, and docs), and rebuild affected packages. Re-run verification after fixes.

🤖 Prompt for AI Agents
packages/samples/src/cache/cache_example.ts (around lines 3): remaining legacy
references to @graphai/agent_filters are present elsewhere; update or remove
them: 1) In packages/samples/htmlSample/chat-sample.html line ~6 replace the CDN
script tag referencing @graphai/[email protected] with the correct new package
CDN (or remove the CDN if no longer needed). 2) In
packages/test_utils/lib/test_runner.js line ~42 change
require("@graphai/agent_filters") to require the new package name (or point to
the rebuilt local lib) and then rebuild packages so lib/ artifacts don’t
reference the legacy package. 3) In packages/agent_filters/package.json change
the "name" field from "@graphai/agent_filters" to the appropriate new package
name(s) used in the monorepo (or remove the legacy package entry), and update
README files (packages/agent_filters/README.md and
agent_filters/namedinput_validator_agent_filter/README.md) to use the new
import/install names. After making these edits, rebuild the affected packages
(especially test_utils and any packages producing lib/ artifacts) and re-run
verification to ensure no remaining references to @graphai/agent_filters exist.

},
"devDependencies": {
"@graphai/agent_filters": "^2.0.0",
"@graphai/namedinput_validator_agent_filter": "^2.0.1",

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

Dev dependency updated to the new module-specific filter package

This aligns with the import migration in test_runner.ts.

Verify that the chosen version exists and is the intended one, and that no packages still depend on the deprecated @graphai/agent_filters:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "[1] Latest published version on npm (requires npm)"
if command -v npm >/dev/null 2>&1; then
  npm view @graphai/namedinput_validator_agent_filter version
else
  echo "npm not found; using registry API via curl"
  curl -s https://registry.npmjs.org/@graphai%2Fnamedinput_validator_agent_filter | jq -r '."dist-tags".latest'
fi

echo
echo "[2] Ensure no package.json still references @graphai/agent_filters"
rg -n --no-ignore-vcs '"@graphai/agent_filters"' || true

Length of output: 942


Action required: published package verified, but repo still references @graphai/agent_filters

Verified: @graphai/namedinput_validator_agent_filter latest = 2.0.1 (matches ^2.0.1). However, I found remaining references to the deprecated @graphai/agent_filters — please fix/rebuild the following:

  • git/packages/test_utils/lib/test_runner.js — still requires "@graphai/agent_filters" (likely a stale build artifact). Rebuild package or regenerate lib output so it imports the new package.
  • git/packages/agent_filters/README.md (lines ~23,185) — update example imports to the module-specific packages.
  • git/packages/agent_filters/package.json — currently named "@graphai/agent_filters"; confirm whether this package should remain, be deprecated, or be renamed/removed.
  • git/agent_filters/namedinput_validator_agent_filter/README.md — update example import to the new package.

After applying fixes, re-run: rg -n --no-ignore-vcs '"@graphai/agent_filters"' to confirm no remaining references.

🤖 Prompt for AI Agents
In packages/test_utils/package.json around line 31 and related build artifacts
(git/packages/test_utils/lib/test_runner.js), README files
(git/packages/agent_filters/README.md lines ~23 and ~185,
git/agent_filters/namedinput_validator_agent_filter/README.md) and the
agent_filters package manifest (git/packages/agent_filters/package.json):
replace any remaining imports of the deprecated "@graphai/agent_filters" with
the module-specific package names (e.g.,
"@graphai/namedinput_validator_agent_filter"), update README examples
accordingly, and decide whether git/packages/agent_filters/package.json should
be deprecated/renamed or removed (update its name/README to reflect that
decision). Then rebuild/regenerate the lib output for packages/test_utils so
lib/test_runner.js imports the correct package, and run rg -n --no-ignore-vcs
'"@graphai/agent_filters"' to confirm no references remain.

import { GraphAI, GraphData, AgentFunctionInfoDictionary, DefaultResultData, ValidationError } from "graphai";
import * as defaultTestAgents from "@graphai/vanilla";
import { namedInputValidatorFilter } from "@graphai/agent_filters";
import { namedInputValidatorFilter } from "@graphai/namedinput_validator_agent_filter";

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

Import path migration looks good

The symbol and usage are unchanged, consistent with the modular split of agent filters.

To ensure the migration is complete across the repo, run:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "[1] Legacy imports check"
rg -n --no-ignore-vcs '@graphai/agent_filters' || true

echo
echo "[2] Confirm the new package is declared for this workspace package"
fd -a package.json | while read -r f; do
  if rg -n '"name": "@receptron/test_utils"' "$f" >/dev/null; then
    echo "---- $f"
    rg -n '"@graphai/namedinput_validator_agent_filter"' "$f" || true
  fi
done

Length of output: 5110


Import path migration looks good — remaining legacy references found

Source import and package.json were updated to @graphai/namedinput_validator_agent_filter, but the repo still contains references to @graphai/agent_filters. Please update these and/or rebuild artifacts.

Files/locations needing attention:

  • packages/test_utils/lib/test_runner.js:42 — const agent_filters_1 = require("@graphai/agent_filters");
  • packages/samples/htmlSample/chat-sample.html:6 — CDN script referencing @graphai/[email protected]
  • packages/agent_filters/package.json — package still named "@graphai/agent_filters"
  • packages/agent_filters/README.md — multiple import examples using "@graphai/agent_filters"
  • agent_filters/namedinput_validator_agent_filter/README.md:20 — imports from "@graphai/agent_filters"
  • packages/test_utils/package.json:31 — already depends on "@graphai/namedinput_validator_agent_filter": "^2.0.1" (so dependency is declared)

Recommended actions (concise):

  • Update README and sample usages to the new package (or clearly document both if intentional).
  • Rebuild packages (clean lib/) so compiled JS no longer requires the legacy package.
  • Decide whether to keep or deprecate @graphai/agent_filters and propagate that decision across the repo.
🤖 Prompt for AI Agents
In packages/test_utils/src/test_runner.ts around line 3, the import was migrated
to @graphai/namedinput_validator_agent_filter but the repo still contains legacy
references to @graphai/agent_filters (notably
packages/test_utils/lib/test_runner.js:42 and several READMEs and sample files);
update all remaining imports and docs to the new package name (search for
"@graphai/agent_filters" and replace with
"@graphai/namedinput_validator_agent_filter" or add a note if both names must be
supported), update packages/agent_filters/package.json if you intend to
deprecate or rename that package, rebuild the packages (clean lib/ and run the
build) so compiled JS no longer requires the legacy package, and verify sample
HTML/CDN references and README examples are updated to prevent runtime/consumer
confusion.

@isamu
isamu merged commit 1002bb6 into receptron:main Aug 14, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Sep 22, 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.

1 participant