fix: replace non-existent sdk.triggerVoid with sdk.trigger + action: { type: 'void' }#731
fix: replace non-existent sdk.triggerVoid with sdk.trigger + action: { type: 'void' }#731LeonemFu wants to merge 2 commits into
Conversation
…{ type: 'void' }
sdk.triggerVoid has never existed in iii-sdk. All fire-and-forget
background tasks were silently failing with:
TypeError: sdk.triggerVoid is not a function
Replace every occurrence with the canonical iii-sdk API:
sdk.trigger({ function_id: '...', payload: { ... }, action: { type: 'void' } })
Affected paths:
- mem::disk-size-delta
- mem::vision-embed
- mem::image-quota-cleanup
- mem::slot-reflect
- mem::graph-extract
- event::session::stopped
Also updates corresponding test mocks and log messages.
Fixes rohitg00#726
Signed-off-by: Fu <1340468261@qq.com>
|
@LeonemFu is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThis PR replaces all sdk.triggerVoid(...) uses with sdk.trigger({ function_id, payload, action: TriggerAction.Void() }) across disk-size accounting, image observation/rollback, session-event fan-out, and updates tests/mocks to assert the new structured trigger call shape. ChangesSDK trigger API migration
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
test/multimodal.test.ts (1)
170-171:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winStale
triggerVoidmock — incomplete migration.
sdk.triggerVoidno longer exists in the source, so mocking it and assertingexpect(localTriggerVoid).not.toHaveBeenCalled()is now a tautology that always passes and tests nothing meaningful. Switch this case to mock/asserttriggerlike the other tests in this file.💚 Proposed fix
- const localTriggerVoid = vi.fn(); - const localSdk = { triggerVoid: localTriggerVoid } as any; + const localTrigger = vi.fn(); + const localSdk = { trigger: localTrigger } as any; @@ - expect(localTriggerVoid).not.toHaveBeenCalled(); + expect(localTrigger).not.toHaveBeenCalled();Also applies to: 194-194
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/multimodal.test.ts` around lines 170 - 171, The test is mocking and asserting the removed sdk.triggerVoid (localTriggerVoid/localSdk.triggerVoid) which always passes; update the mock to use the current method name sdk.trigger instead: replace localTriggerVoid with localTrigger (or similar), set localSdk = { trigger: localTrigger } as any, and change the assertion from expect(localTriggerVoid).not.toHaveBeenCalled() to expect(localTrigger).not.toHaveBeenCalled(); do the same replacement for the other occurrence referenced (around the other test at the same file).src/triggers/api.ts (1)
616-626:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle promise rejections for fire-and-forget trigger.
The
sdk.triggercall returns a Promise, but it's not awaited and thetry/catchblock won't catch asynchronous rejections. This could lead to unhandled promise rejections if the trigger fails to queue.🔧 Proposed fix to properly handle rejections
Choose one of these patterns:
Option 1 (Recommended): Use
.catch()for true fire-and-forget:- try { - sdk.trigger({ - function_id: "event::session::stopped", - payload: { sessionId }, - action: { type: "void" }, - }); - } catch (err) { - logger.warn("event::session::stopped trigger failed", { - sessionId, - error: err instanceof Error ? err.message : String(err), - }); - } + sdk.trigger({ + function_id: "event::session::stopped", + payload: { sessionId }, + action: { type: "void" }, + }).catch((err) => { + logger.warn("event::session::stopped trigger failed", { + sessionId, + error: err instanceof Error ? err.message : String(err), + }); + });Option 2: Await to ensure the trigger is queued before continuing:
try { - sdk.trigger({ + await sdk.trigger({ function_id: "event::session::stopped", payload: { sessionId }, action: { type: "void" }, }); } catch (err) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/triggers/api.ts` around lines 616 - 626, The fire-and-forget sdk.trigger call (sdk.trigger with function_id "event::session::stopped" and payload containing sessionId) can reject asynchronously and the surrounding try/catch won't catch it; update the call to handle promise rejections explicitly—either await sdk.trigger(...) inside the try block or (preferred for true fire-and-forget) append a .catch(...) to the returned Promise that calls logger.warn("event::session::stopped trigger failed", { sessionId, error: err instanceof Error ? err.message : String(err) }) so all async errors are logged and no unhandled promise rejections occur.src/triggers/events.ts (2)
51-61:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle promise rejections for fire-and-forget trigger.
Same issue as in
api.ts: thesdk.triggercall returns a Promise that isn't awaited, so thetry/catchwon't catch asynchronous rejections.🔧 Proposed fix
- try { - sdk.trigger({ - function_id: "mem::slot-reflect", - payload: { sessionId: data.sessionId }, - action: { type: "void" }, - }); - } catch (err) { - logger.warn("slot-reflect trigger failed", { - sessionId: data.sessionId, - error: err instanceof Error ? err.message : String(err), - }); - } + sdk.trigger({ + function_id: "mem::slot-reflect", + payload: { sessionId: data.sessionId }, + action: { type: "void" }, + }).catch((err) => { + logger.warn("slot-reflect trigger failed", { + sessionId: data.sessionId, + error: err instanceof Error ? err.message : String(err), + }); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/triggers/events.ts` around lines 51 - 61, The try/catch around the fire-and-forget call to sdk.trigger in events.ts won't catch asynchronous rejections because the Promise isn't awaited; modify the handling of sdk.trigger (the call with function_id "mem::slot-reflect" and payload { sessionId: data.sessionId }) by either adding await so the call is awaited inside the existing try/catch or explicitly attach a .catch handler that logs the error (using logger.warn) to handle rejections; ensure you reference sdk.trigger and keep the same log shape (sessionId and error) when handling the rejected promise.
70-81:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle promise rejections and consider using TriggerAction.Void() for consistency.
Two issues here:
- The
try/catchwon't catch promise rejections (same as slot-reflect above).- This file imports
TriggerAction(line 1) and usesTriggerAction.Void()at line 136, but the new code uses the plain object form{ type: "void" }. Consider usingTriggerAction.Void()for consistency within this file.🔧 Proposed fix addressing both issues
- try { const observations = await kv.list<CompressedObservation>( KV.observations(data.sessionId), ); const compressed = observations.filter((o) => o.title); if (compressed.length > 0) { - sdk.trigger({ + sdk.trigger({ function_id: "mem::graph-extract", payload: { observations: compressed }, - action: { type: "void" }, - }); + action: TriggerAction.Void(), + }).catch((err) => { + logger.warn("graph-extract trigger failed", { + sessionId: data.sessionId, + error: err instanceof Error ? err.message : String(err), + }); + }); } - } catch (err) { - logger.warn("graph-extract trigger failed", { - sessionId: data.sessionId, - error: err instanceof Error ? err.message : String(err), - }); - }Note: The outer
try/catchwas only wrapping the trigger call, so it's been removed. If you need to catch errors fromkv.listor.filter(), add a try/catch around those operations separately.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/triggers/events.ts` around lines 70 - 81, The sdk.trigger call is creating an unhandled promise and uses a plain object action; update the call to await the trigger (or attach .catch) so promise rejections are caught instead of relying on the surrounding try/catch, and replace the action object { type: "void" } with TriggerAction.Void() for consistency with other calls; locate the sdk.trigger invocation in this block and make it awaited (or add .catch(err => logger.warn(...))) and swap the action to use TriggerAction.Void().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/functions/disk-size-manager.ts`:
- Around line 29-33: The fire-and-forget call to sdk.trigger in
disk-size-manager.ts (triggering "mem::image-quota-cleanup") lacks error
handling so rejections are silent; update the code around sdk.trigger to either
await it inside a try/catch or attach a .catch(...) and log the error (use the
existing logger or processLogger) with contextual text including
"mem::image-quota-cleanup" and the triggering function name so failures are
recorded; ensure the change references the sdk.trigger(...) call site in
disk-size-manager.ts and does not block the main flow if you prefer non-blocking
behavior (use .catch to log) or awaits inside async function when you want to
observe errors.
In `@src/functions/observe.ts`:
- Around line 159-173: Replace the literal void action objects in the
sdk.trigger calls in observe.ts (the triggers for function_id
"mem::disk-size-delta" and "mem::vision-embed") with the migrated
TriggerAction.Void() helper so the code is consistent with iii-sdk@0.11.2; also
handle the unawaited sdk.trigger promises (either await them or append
.catch(...) to each call) to prevent unhandled rejections, keeping the rest of
the payloads (imageRef: filePath, sessionId: payload.sessionId, observationId:
obsId, deltaBytes: bytesWritten) unchanged.
---
Outside diff comments:
In `@src/triggers/api.ts`:
- Around line 616-626: The fire-and-forget sdk.trigger call (sdk.trigger with
function_id "event::session::stopped" and payload containing sessionId) can
reject asynchronously and the surrounding try/catch won't catch it; update the
call to handle promise rejections explicitly—either await sdk.trigger(...)
inside the try block or (preferred for true fire-and-forget) append a
.catch(...) to the returned Promise that calls
logger.warn("event::session::stopped trigger failed", { sessionId, error: err
instanceof Error ? err.message : String(err) }) so all async errors are logged
and no unhandled promise rejections occur.
In `@src/triggers/events.ts`:
- Around line 51-61: The try/catch around the fire-and-forget call to
sdk.trigger in events.ts won't catch asynchronous rejections because the Promise
isn't awaited; modify the handling of sdk.trigger (the call with function_id
"mem::slot-reflect" and payload { sessionId: data.sessionId }) by either adding
await so the call is awaited inside the existing try/catch or explicitly attach
a .catch handler that logs the error (using logger.warn) to handle rejections;
ensure you reference sdk.trigger and keep the same log shape (sessionId and
error) when handling the rejected promise.
- Around line 70-81: The sdk.trigger call is creating an unhandled promise and
uses a plain object action; update the call to await the trigger (or attach
.catch) so promise rejections are caught instead of relying on the surrounding
try/catch, and replace the action object { type: "void" } with
TriggerAction.Void() for consistency with other calls; locate the sdk.trigger
invocation in this block and make it awaited (or add .catch(err =>
logger.warn(...))) and swap the action to use TriggerAction.Void().
In `@test/multimodal.test.ts`:
- Around line 170-171: The test is mocking and asserting the removed
sdk.triggerVoid (localTriggerVoid/localSdk.triggerVoid) which always passes;
update the mock to use the current method name sdk.trigger instead: replace
localTriggerVoid with localTrigger (or similar), set localSdk = { trigger:
localTrigger } as any, and change the assertion from
expect(localTriggerVoid).not.toHaveBeenCalled() to
expect(localTrigger).not.toHaveBeenCalled(); do the same replacement for the
other occurrence referenced (around the other test at the same file).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 813064c1-3e43-4425-9125-2a4c1b071e73
📒 Files selected for processing (8)
src/functions/disk-size-manager.tssrc/functions/image-quota-cleanup.tssrc/functions/image-refs.tssrc/functions/observe.tssrc/triggers/api.tssrc/triggers/events.tstest/multimodal.test.tstest/session-end-triggers-graph.test.ts
| sdk.trigger({ | ||
| function_id: "mem::disk-size-delta", | ||
| payload: { deltaBytes: bytesWritten }, | ||
| action: { type: "void" }, | ||
| }); | ||
| if (process.env["AGENTMEMORY_IMAGE_EMBEDDINGS"] === "true") { | ||
| sdk.triggerVoid("mem::vision-embed", { | ||
| imageRef: filePath, | ||
| sessionId: payload.sessionId, | ||
| observationId: obsId, | ||
| sdk.trigger({ | ||
| function_id: "mem::vision-embed", | ||
| payload: { | ||
| imageRef: filePath, | ||
| sessionId: payload.sessionId, | ||
| observationId: obsId, | ||
| }, | ||
| action: { type: "void" }, | ||
| }); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
iii-sdk TriggerAction.Void() return value shape trigger action void
💡 Result:
When using TriggerAction.Void() in the iii-sdk, the function call is dispatched as a "fire-and-forget" operation [1][2]. Because this mode does not wait for the target function to execute or return a result, the return value is effectively empty or null depending on the implementation language [2]: - In Node.js/TypeScript, it returns undefined [2]. - In Python, it returns None [2]. - In Rust, it resolves to Value::Null [2]. When TriggerAction.Void() is used, the caller continues execution immediately after dispatching the request [1][3]. The engine provides no delivery guarantees, meaning if the target function fails or the worker is unavailable, the message is lost without notifying the caller [1][2].
Citations:
- 1: https://iii.dev/docs/0-10-0/how-to/trigger-actions
- 2: https://tessl.io/registry/skills/github/iii-hq/iii/iii-trigger-actions
- 3: https://iii.dev/docs/using-iii/triggers
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Inspect the relevant portion of observe.ts (small range)
sed -n '130,220p' src/functions/observe.ts | nl -ba | sed -n '1,120p'
# 2) Find all occurrences of action void patterns in observe.ts
rg -n 'action:\s*(\{[^}]*type:\s*"void"[^}]*\}|TriggerAction\.Void\(\))' src/functions/observe.ts
# 3) Check for awaited sdk.trigger calls near those lines
rg -n 'await\s+sdk\.trigger\(|sdk\.trigger\(' src/functions/observe.ts
# 4) Locate iii-sdk TriggerAction.Void definition (search repo for TriggerAction)
# Try common places: node_modules (if present), lockfile, or local types.
rg -n --hidden --no-ignore-vcs 'class TriggerAction|enum TriggerAction|TriggerAction\.Void|Void\(\)\s*[:=]' . || true
# 5) If package.json/lockfile exist, print iii-sdk version
if [ -f package.json ]; then echo "package.json:"; cat package.json; fi
if ls package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null; then
echo "Lockfiles:"; ls package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true
fi
# Print iii-sdk version from lockfile if possible
for f in package-lock.json pnpm-lock.yaml yarn.lock; do
if [ -f "$f" ]; then
echo "---- $f iii-sdk version ----"
rg -n 'iii-sdk@|iii-sdk' "$f" | head -n 50 || true
fi
doneRepository: rohitg00/agentmemory
Length of output: 107
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Print the relevant section of observe.ts with line numbers (using cat -n)
sed -n '140,220p' src/functions/observe.ts | cat -n
# 2) Find all occurrences of the two void styles in observe.ts
rg -n 'action:\s*\{[^}]*type:\s*"void"[^}]*\}' src/functions/observe.ts
rg -n 'action:\s*TriggerAction\.Void\(\)' src/functions/observe.ts
# 3) Check which sdk.trigger calls are awaited around those regions
rg -n 'await\s+sdk\.trigger\(|sdk\.trigger\(' src/functions/observe.ts
# 4) Locate iii-sdk TriggerAction.Void implementation or typings in the repo
# (search for TriggerAction.Void() and for the trigger action shape types)
rg -n --hidden --no-ignore-vcs 'TriggerAction\.Void\(\)' . || true
rg -n --hidden --no-ignore-vcs 'class TriggerAction|enum TriggerAction|function TriggerAction|type TriggerAction' . || true
# 5) Print package.json and lockfile (to know iii-sdk version)
if [ -f package.json ]; then echo "---- package.json ----"; cat package.json; fi
for f in package-lock.json pnpm-lock.yaml yarn.lock; do
if [ -f "$f" ]; then echo "---- $f ----"; head -n 60 "$f"; fi
done
# 6) If iii-sdk sources exist in node_modules, try to locate it
if [ -d node_modules ]; then
echo "---- Searching node_modules for TriggerAction.Void() ----"
rg -n 'TriggerAction\.Void\(\)' node_modules 2>/dev/null | head -n 50 || true
fiRepository: rohitg00/agentmemory
Length of output: 6832
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check whether node_modules exists in this sandbox
if [ -d node_modules ]; then
echo "node_modules present"
else
echo "node_modules missing"
fi
# Inspect observe.ts around the void trigger sites (use absolute line numbers via sed+cat)
echo "---- observe.ts lines 150-240 ----"
sed -n '140,240p' src/functions/observe.ts | cat -n
echo "---- observe.ts lines 260-330 ----"
sed -n '250,330p' src/functions/observe.ts | cat -n
# List all void action styles in observe.ts with some nearby context
echo "---- void action literals ----"
rg -n 'action:\s*\{\s*type:\s*"void"\s*\}' -n src/functions/observe.ts
echo "---- TriggerAction.Void() usages ----"
rg -n 'action:\s*TriggerAction\.Void\(\)\s*' src/functions/observe.tsRepository: rohitg00/agentmemory
Length of output: 8395
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# show more around the originally cited "awaited void trigger at ~line 210"
sed -n '200,240p' src/functions/observe.ts | cat -n
# locate TriggerAction import and any local type re-exports
rg -n 'import\s*\{[^}]*TriggerAction|from\s*["'\'']iii-sdk["'\'']|TriggerAction\.Void\(' src/functions/observe.ts
# search repo for TriggerAction definition (including dist)
rg -n --hidden --no-ignore-vcs 'export\s+enum\s+TriggerAction|enum\s+TriggerAction|class\s+TriggerAction|TriggerAction\s*=\s*|interface\s+TriggerAction|type\s+TriggerAction' . || true
# search dist for TriggerAction (sometimes bundled)
rg -n --hidden --no-ignore-vcs 'TriggerAction\.Void\(\)' dist src || trueRepository: rohitg00/agentmemory
Length of output: 2325
🌐 Web query:
iii-sdk 0.11.2 TriggerAction.Void() serialized action shape type:"void"
💡 Result:
In the iii-sdk (version 0.11.2 and related versions), the serialized action shape for TriggerAction.Void is defined as an object with the property type set to "void" [1][2]. Specifically, the SDK utilizes a discriminated union for trigger actions [1][2]. When you use TriggerAction.Void, it produces a serialized structure equivalent to: { "type": "void" } This action tells the engine to perform a fire-and-forget invocation, where the caller dispatches the request but does not wait for a result, acknowledgement, or retry [3][4][5]. Because it is fire-and-forget, the operation provides no delivery guarantees; if the target function fails or the worker is unavailable, the message is typically lost [4][5]. This is commonly used for non-critical side effects like logging, analytics, or event tracking [4][5].
Citations:
- 1: https://motiadev.mintlify.app/sdk-reference/node-sdk
- 2: https://motiadev.mintlify.app/0-12-0/sdk-reference/node-sdk
- 3: https://iii.dev/docs/using-iii/triggers
- 4: https://iii.dev/docs/0-10-0/how-to/trigger-actions
- 5: https://tessl.io/registry/skills/github/iii-hq/iii/iii-trigger-actions
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect disk-size-manager.ts for how unawaited/void triggers are handled
sed -n '1,220p' src/functions/disk-size-manager.ts | cat -n
rg -n 'sdk\.trigger\(' src/functions/disk-size-manager.ts
rg -n '\.catch\(' src/functions/disk-size-manager.ts
rg -n 'TriggerAction\.Void\(|action:\s*\{\s*type:\s*"void"\s*\}' src/functions/disk-size-manager.tsRepository: rohitg00/agentmemory
Length of output: 1963
Use TriggerAction.Void() for consistency in observe.ts
TriggerAction.Void() in iii-sdk@0.11.2 serializes to the same action payload as action: { type: "void" } ({ type: "void" }), so swapping the migrated calls is safe and keeps the file consistent (including the rollback mem::disk-size-delta path that also uses the literal).
The void sdk.trigger(...) calls are unawaited; ensure dispatch failures don’t turn into unhandled rejections (e.g., add a .catch(...) or await where required).
♻️ Proposed change
- sdk.trigger({
- function_id: "mem::disk-size-delta",
- payload: { deltaBytes: bytesWritten },
- action: { type: "void" },
- });
+ sdk.trigger({
+ function_id: "mem::disk-size-delta",
+ payload: { deltaBytes: bytesWritten },
+ action: TriggerAction.Void(),
+ });
if (process.env["AGENTMEMORY_IMAGE_EMBEDDINGS"] === "true") {
- sdk.trigger({
- function_id: "mem::vision-embed",
- payload: {
- imageRef: filePath,
- sessionId: payload.sessionId,
- observationId: obsId,
- },
- action: { type: "void" },
- });
+ sdk.trigger({
+ function_id: "mem::vision-embed",
+ payload: {
+ imageRef: filePath,
+ sessionId: payload.sessionId,
+ observationId: obsId,
+ },
+ action: TriggerAction.Void(),
+ });
}📝 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.
| sdk.trigger({ | |
| function_id: "mem::disk-size-delta", | |
| payload: { deltaBytes: bytesWritten }, | |
| action: { type: "void" }, | |
| }); | |
| if (process.env["AGENTMEMORY_IMAGE_EMBEDDINGS"] === "true") { | |
| sdk.triggerVoid("mem::vision-embed", { | |
| imageRef: filePath, | |
| sessionId: payload.sessionId, | |
| observationId: obsId, | |
| sdk.trigger({ | |
| function_id: "mem::vision-embed", | |
| payload: { | |
| imageRef: filePath, | |
| sessionId: payload.sessionId, | |
| observationId: obsId, | |
| }, | |
| action: { type: "void" }, | |
| }); | |
| sdk.trigger({ | |
| function_id: "mem::disk-size-delta", | |
| payload: { deltaBytes: bytesWritten }, | |
| action: TriggerAction.Void(), | |
| }); | |
| if (process.env["AGENTMEMORY_IMAGE_EMBEDDINGS"] === "true") { | |
| sdk.trigger({ | |
| function_id: "mem::vision-embed", | |
| payload: { | |
| imageRef: filePath, | |
| sessionId: payload.sessionId, | |
| observationId: obsId, | |
| }, | |
| action: TriggerAction.Void(), | |
| }); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/functions/observe.ts` around lines 159 - 173, Replace the literal void
action objects in the sdk.trigger calls in observe.ts (the triggers for
function_id "mem::disk-size-delta" and "mem::vision-embed") with the migrated
TriggerAction.Void() helper so the code is consistent with iii-sdk@0.11.2; also
handle the unawaited sdk.trigger promises (either await them or append
.catch(...) to each call) to prevent unhandled rejections, keeping the rest of
the payloads (imageRef: filePath, sessionId: payload.sessionId, observationId:
obsId, deltaBytes: bytesWritten) unchanged.
…cross codebase Refactor `sdk.trigger` calls to use the `TriggerAction.Void()` utility for improved readability and consistency with iii-sdk's canonical API. Updated test mocks and logs accordingly. Affected paths: - mem::disk-size-delta - mem::vision-embed - mem::image-quota-cleanup - mem::slot-reflect - mem::graph-extract - event::session::stopped Signed-off-by: Fu <1340468261@qq.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/functions/image-refs.ts`:
- Around line 28-32: The unawaited fire-and-forget call to sdk.trigger({
function_id: "mem::disk-size-delta", payload: { deltaBytes: -deletedBytes },
action: TriggerAction.Void() }) can produce an unhandled rejection; update the
call site to attach a rejection handler (e.g., append .catch(...)) so the void
trigger remains fire-and-forget but any errors are swallowed or logged, ensuring
sdk.trigger and TriggerAction.Void usage is preserved and you do not leave an
unhandled promise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 31f75de4-abb5-46ed-8b9c-a74887a9dbc5
📒 Files selected for processing (9)
src/functions/disk-size-manager.tssrc/functions/image-quota-cleanup.tssrc/functions/image-refs.tssrc/functions/observe.tssrc/triggers/api.tssrc/triggers/events.tstest/multimodal.test.tstest/session-end-triggers-graph.test.tstest/sliding-window.test.ts
💤 Files with no reviewable changes (1)
- test/sliding-window.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- test/session-end-triggers-graph.test.ts
- src/functions/disk-size-manager.ts
- src/triggers/events.ts
- src/triggers/api.ts
- test/multimodal.test.ts
| sdk.trigger({ | ||
| function_id: "mem::disk-size-delta", | ||
| payload: { deltaBytes: -deletedBytes }, | ||
| action: TriggerAction.Void(), | ||
| }); |
There was a problem hiding this comment.
Same floating-promise risk on the void trigger.
As with the cleanup path, this unawaited void sdk.trigger(...) has no rejection handler; a failed dispatch becomes an unhandled rejection. Append .catch(...) to keep it truly fire-and-forget without risking process crashes.
🛡️ Proposed fix
- sdk.trigger({
- function_id: "mem::disk-size-delta",
- payload: { deltaBytes: -deletedBytes },
- action: TriggerAction.Void(),
- });
+ sdk.trigger({
+ function_id: "mem::disk-size-delta",
+ payload: { deltaBytes: -deletedBytes },
+ action: TriggerAction.Void(),
+ }).catch(() => {});📝 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.
| sdk.trigger({ | |
| function_id: "mem::disk-size-delta", | |
| payload: { deltaBytes: -deletedBytes }, | |
| action: TriggerAction.Void(), | |
| }); | |
| sdk.trigger({ | |
| function_id: "mem::disk-size-delta", | |
| payload: { deltaBytes: -deletedBytes }, | |
| action: TriggerAction.Void(), | |
| }).catch(() => {}); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/functions/image-refs.ts` around lines 28 - 32, The unawaited
fire-and-forget call to sdk.trigger({ function_id: "mem::disk-size-delta",
payload: { deltaBytes: -deletedBytes }, action: TriggerAction.Void() }) can
produce an unhandled rejection; update the call site to attach a rejection
handler (e.g., append .catch(...)) so the void trigger remains fire-and-forget
but any errors are swallowed or logged, ensuring sdk.trigger and
TriggerAction.Void usage is preserved and you do not leave an unhandled promise.
Problem
iii-sdk(the underlying engine SDK) has never exposed atriggerVoidmethod. Everycall site was silently throwing:
The errors were caught by local
try/catch, so the process didn't crash, but theintended background tasks were never executed.
Affected fire-and-forget paths:
mem::disk-size-deltamem::vision-embedmem::image-quota-cleanupmem::slot-reflectmem::graph-extractevent::session::stoppedFix
Replace every
sdk.triggerVoid("id", payload)with the canonicaliii-sdkAPI:Also updates log messages (triggerVoid failed → trigger failed) and corresponding test
mocks.
Verification
• npm run build — TypeScript compiles clean
• npm test — 1285 tests pass (6 pre-existing failures in embedding-provider.test.ts
unrelated to this change)
• grep -r "triggerVoid" dist/ — no occurrences in built output
Fixes #726
Summary by CodeRabbit