Skip to content

fix: replace non-existent sdk.triggerVoid with sdk.trigger + action: { type: 'void' }#731

Open
LeonemFu wants to merge 2 commits into
rohitg00:mainfrom
LeonemFu:fix/726-replace-triggerVoid
Open

fix: replace non-existent sdk.triggerVoid with sdk.trigger + action: { type: 'void' }#731
LeonemFu wants to merge 2 commits into
rohitg00:mainfrom
LeonemFu:fix/726-replace-triggerVoid

Conversation

@LeonemFu
Copy link
Copy Markdown

@LeonemFu LeonemFu commented May 30, 2026

Problem

iii-sdk (the underlying engine SDK) has never exposed a triggerVoid method. Every
call site was silently throwing:


TypeError: sdk.triggerVoid is not a function

The errors were caught by local try/catch, so the process didn't crash, but the
intended background tasks were never executed.

Affected fire-and-forget paths:

  • mem::disk-size-delta
  • mem::vision-embed
  • mem::image-quota-cleanup
  • mem::slot-reflect
  • mem::graph-extract
  • event::session::stopped

Fix

Replace every sdk.triggerVoid("id", payload) with the canonical iii-sdk API:

sdk.trigger({
  function_id: "id",
  payload: { ... },
  action: { type: "void" }
});

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

  • Refactor
    • Updated internal trigger invocation mechanism across disk management, image handling, and session tracking functions for improved consistency.
    • Updated corresponding tests to reflect trigger handling changes.

…{ 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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

SDK trigger API migration

Layer / File(s) Summary
Disk-size manager and quota cleanup
src/functions/disk-size-manager.ts, src/functions/image-quota-cleanup.ts, src/functions/image-refs.ts, test/multimodal.test.ts
Quota enforcement, image deletion, and reference-count disk-size events now call sdk.trigger({ function_id, payload, action: TriggerAction.Void() }); tests updated to assert structured trigger objects and payload.deltaBytes.
Observe function image & disk-size tracking
src/functions/observe.ts, test/multimodal.test.ts
Post-save follow-ups (disk-size-delta, optional vision-embed) and rollback negative-delta emissions use structured sdk.trigger(...) with TriggerAction.Void(); related test mocks/assertions updated.
Session end and event fan-out
src/triggers/api.ts, src/triggers/events.ts, test/session-end-triggers-graph.test.ts, test/sliding-window.test.ts
Non-blocking session-stopped fan-out and downstream mem::slot-reflect / mem::graph-extract now invoke the structured trigger with explicit void action; tests and mock SDK surface adjusted to reflect the new call shape.

🎯 3 (Moderate) | ⏱️ ~20 minutes

"🐰
I hopped through code to make voids explicit,
Replaced the helpers with calls well-structured and brisk,
Now triggers carry function IDs and payloads bright,
Tests learned the new shape and leap with delight,
A tidy patch, a carrot, and a debug-free night."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing non-existent sdk.triggerVoid calls with the canonical sdk.trigger API using TriggerAction.Void().
Linked Issues check ✅ Passed The PR fully addresses issue #726 by replacing all sdk.triggerVoid calls with sdk.trigger + action: TriggerAction.Void() across all affected fire-and-forget paths.
Out of Scope Changes check ✅ Passed All changes are directly related to replacing sdk.triggerVoid with sdk.trigger and updating corresponding test mocks; no unrelated changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 win

Stale triggerVoid mock — incomplete migration.

sdk.triggerVoid no longer exists in the source, so mocking it and asserting expect(localTriggerVoid).not.toHaveBeenCalled() is now a tautology that always passes and tests nothing meaningful. Switch this case to mock/assert trigger like 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 win

Handle promise rejections for fire-and-forget trigger.

The sdk.trigger call returns a Promise, but it's not awaited and the try/catch block 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 win

Handle promise rejections for fire-and-forget trigger.

Same issue as in api.ts: the sdk.trigger call returns a Promise that isn't awaited, so the try/catch won'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 win

Handle promise rejections and consider using TriggerAction.Void() for consistency.

Two issues here:

  1. The try/catch won't catch promise rejections (same as slot-reflect above).
  2. This file imports TriggerAction (line 1) and uses TriggerAction.Void() at line 136, but the new code uses the plain object form { type: "void" }. Consider using TriggerAction.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/catch was only wrapping the trigger call, so it's been removed. If you need to catch errors from kv.list or .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

📥 Commits

Reviewing files that changed from the base of the PR and between fd9e3bd and c03615a.

📒 Files selected for processing (8)
  • src/functions/disk-size-manager.ts
  • src/functions/image-quota-cleanup.ts
  • src/functions/image-refs.ts
  • src/functions/observe.ts
  • src/triggers/api.ts
  • src/triggers/events.ts
  • test/multimodal.test.ts
  • test/session-end-triggers-graph.test.ts

Comment thread src/functions/disk-size-manager.ts
Comment thread src/functions/observe.ts
Comment on lines +159 to 173
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" },
});
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 | 🟡 Minor | ⚡ Quick win

🧩 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:


🏁 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
done

Repository: 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
fi

Repository: 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.ts

Repository: 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 || true

Repository: 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:


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

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

Suggested change
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>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between c03615a and 1edca87.

📒 Files selected for processing (9)
  • src/functions/disk-size-manager.ts
  • src/functions/image-quota-cleanup.ts
  • src/functions/image-refs.ts
  • src/functions/observe.ts
  • src/triggers/api.ts
  • src/triggers/events.ts
  • test/multimodal.test.ts
  • test/session-end-triggers-graph.test.ts
  • test/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

Comment on lines +28 to +32
sdk.trigger({
function_id: "mem::disk-size-delta",
payload: { deltaBytes: -deletedBytes },
action: TriggerAction.Void(),
});
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 | 🟡 Minor | ⚡ Quick win

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.

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

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.

v.0.9.24 sdk.triggerVoid is not a function

1 participant