fix(examples): use valid event kinds in lobu-crm reactions#1072
Conversation
The funnel-digest and inbound-triage reactions called client.knowledge.save
with semantic_type "funnel_digest" / "lead_interaction", which are not
registered event kinds. knowledge.save validates semantic_type against the
agent's event_kinds and throws ScriptError ("Invalid kind") — and because it
runs before client.notifications.send, the reaction aborts and the digest
never reaches #leads.
Switch to the built-in kinds "summary" (digest) and "observation" (triage)
and keep the domain label in metadata.kind so week-over-week queries still work.
📝 WalkthroughWalkthroughTwo CRM reaction handlers refactor how knowledge events are persisted. Both move domain-specific labels from the ChangesKnowledge Event Classification Refactoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 Comment |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 `@examples/lobu-crm/inbound-triage.reaction.ts`:
- Around line 5-7: Header comment incorrectly claims an observation is persisted
"per run" even though the code returns early when data.notable is false or
recommended_actions is empty; update the comment to reflect the actual gate.
Edit the header above the reaction function to say that an observation
(metadata.kind: "lead_interaction") is only saved when the function reaches the
client.knowledge.save call (i.e., when data.notable is truthy and
recommended_actions is non-empty), and not on every invocation, and mention the
early return behavior that prevents saving.
🪄 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 Plus
Run ID: bbc65ed2-11ea-4310-8664-383a5329af38
📒 Files selected for processing (2)
examples/lobu-crm/funnel-digest.reaction.tsexamples/lobu-crm/inbound-triage.reaction.ts
| * GitHub/X/HN signals. Persists an `observation` event (tagged `metadata.kind: | ||
| * "lead_interaction"`) per run so the next digest can count them, and — when | ||
| * the run is notable — pushes the recommended |
There was a problem hiding this comment.
Header comment overstates when triage events are persisted.
The function returns before client.knowledge.save when data.notable is false or recommended_actions is empty, so it does not persist an observation “per run.” Reword this comment to match the actual gate; otherwise the next-digest counting semantics are misleading.
🤖 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 `@examples/lobu-crm/inbound-triage.reaction.ts` around lines 5 - 7, Header
comment incorrectly claims an observation is persisted "per run" even though the
code returns early when data.notable is false or recommended_actions is empty;
update the comment to reflect the actual gate. Edit the header above the
reaction function to say that an observation (metadata.kind: "lead_interaction")
is only saved when the function reaches the client.knowledge.save call (i.e.,
when data.notable is truthy and recommended_actions is non-empty), and not on
every invocation, and mention the early return behavior that prevents saving.
The lobu-crm
funnel-digestandinbound-triagereactions (shipped in #1064) callclient.knowledge.savewithsemantic_type: "funnel_digest"/"lead_interaction". Those aren't registered event kinds —knowledge.savevalidatessemantic_typeagainst the agent'sevent_kinds(built-ins: fact, note, todo, event, change, content, summary, decision, identity, preference, observation) and throwsScriptError: Invalid kind. Becauseknowledge.saveruns beforeclient.notifications.send, the reaction aborts and the digest never reaches #leads — the notify half of #1064 was never actually exercised end to end.Fix
funnel-digest:semantic_type"funnel_digest"→"summary"inbound-triage:semantic_type"lead_interaction"→"observation"metadata.kindso week-over-week queries still discriminate digest vs. triage events.E2E reproducer (prod, org_lobucrm)
Driven via
manage_watchers.complete_window(which runs the reaction in-process), against the deployed #1064 image:reaction_status: "failed",reaction_error: ScriptError: Invalid kind 'funnel_digest'. Valid kinds: fact, note, todo, ...(retried 3×, logged inwatcher_reactions).semantic_typeviaset_reaction_script→reaction_status: "success", anotification_sentreaction row (toolnotify), notification event "Weekly funnel digest — 2026-06-01" created, and zero bot-delivery failures on either app pod.The prod DB scripts for watchers 219/220 were already hot-fixed the same way; this PR makes the repo source match so the next
lobu applydoesn't revert it.🤖 Generated with Claude Code
Summary by CodeRabbit