Skip to content

fix: filter non-handler packets before fan-out#956

Merged
chubes4 merged 1 commit intomainfrom
fix/filter-fanout-packets
Mar 24, 2026
Merged

fix: filter non-handler packets before fan-out#956
chubes4 merged 1 commit intomainfrom
fix/filter-fanout-packets

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 24, 2026

Summary

Filter DataPackets before fan-out to only include ai_handler_complete packets. Non-handler packets (tool_result, ai_response) are dropped before child job creation since no downstream step can use them.

Root Cause

When the AI step calls both a handler tool (upsert_event) AND a non-handler tool (daily_memory), it produces 2+ DataPackets. The engine fanned ALL packets into child jobs, but only the ai_handler_complete packet carries data the UpdateStep needs. The tool_result packet created a child job guaranteed to fail.

BEFORE:
AI produces 2 packets → fan-out → 2 child jobs
  Child A (handler result) → UpdateStep succeeds ✅
  Child B (tool_result)    → UpdateStep fails ❌ (no handler data)

AFTER:
AI produces 2 packets → filter → 1 handler packet → inline continuation
  Same job continues → UpdateStep succeeds ✅
  No dead child created

Changes

In ExecuteStepAbility::routeAfterExecution(), before the fanOut() call:

  1. Filter packets to only ai_handler_complete source type
  2. If no handler packets found, keep originals (safety fallback)
  3. If filtering reduces to ≤1 packet, use inline continuation instead of fan-out

Impact

  • Eliminates ~1,300 dead grandchild jobs/day at the source
  • Reduces fan-out overhead — fewer child jobs = fewer Action Scheduler entries = less DB churn
  • The UpdateStep bandaid from PR fix: silence fan-out grandchild handler-miss noise #954 is kept as a safety net but should no longer trigger

…hildren

When the AI step calls both a handler tool (upsert_event) and a
non-handler tool (daily_memory), it produces 2+ DataPackets. The
engine fanned ALL of them into child jobs, but only the
ai_handler_complete packet carries data the UpdateStep needs.
Non-handler packets (tool_result, ai_response) created child jobs
guaranteed to fail with 'required_handler_tool_not_called'.

Fix: before fan-out, filter to only ai_handler_complete packets.
If filtering reduces to ≤1 packet, use inline continuation instead
of fan-out. The UpdateStep bandaid (PR #954) is kept as a safety
net but should no longer trigger.

Result: eliminates ~1,300 dead grandchild jobs/day at the source
instead of silencing them downstream.
@chubes4 chubes4 merged commit 14977d0 into main Mar 24, 2026
1 check failed
@chubes4 chubes4 deleted the fix/filter-fanout-packets branch March 24, 2026 15:40
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.

1 participant