agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

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

Open LeonemFu opened this issue 6 months ago • 2 comments

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.

LeonemFu avatar May 30 '26 10:05 LeonemFu

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

vercel[bot] avatar May 30 '26 10:05 vercel[bot]

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.

coderabbitai[bot] avatar May 30 '26 10:05 coderabbitai[bot]

Thanks @LeonemFu — sdk.triggerVoid removal handled in v0.9.25 (PR #773 + release notes). Same fix shape (replace removed API with TriggerAction.Void). Closing because the fix is on main.

rohitg00 avatar Jun 02 '26 23:06 rohitg00