Repository navigation
Separate agent filter - #1204
Conversation
|
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 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. 📒 Files selected for processing (1)
WalkthroughUpdated 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~6 minutes Poem
✨ 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: 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 errorsThe 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 → outSideFunctionMinor 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.
📒 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 goodNo 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"; |
There was a problem hiding this comment.
💡 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"' || trueLength 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", |
There was a problem hiding this comment.
💡 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"' || trueLength 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"; |
There was a problem hiding this comment.
💡 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
doneLength 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.
Summary by CodeRabbit