ReqManagedAgents.Consolidate (ReqManagedAgents v0.1.0)

Copy Markdown View Source

Pure helpers for reconnect-with-consolidation.

The event stream has no replay: on (re)connect a consumer lists past events and must (a) drop ones it already processed and (b) re-drive any tool call left unanswered across the disconnect, or the session deadlocks waiting on it. These functions are pure so the orchestration layer (e.g. ReqManagedAgents.Session) or any custom loop can call them.

Summary

Functions

Split events into the ones not in seen and return the grown seen-set.

Return the stop_reason map of the last requires_action idle event if it was never followed by another terminal idle (i.e. still pending), else nil.

Return agent.custom_tool_use events that have no matching user.custom_tool_result.

Functions

dedupe(events, seen)

@spec dedupe([map()], MapSet.t()) :: {[map()], MapSet.t()}

Split events into the ones not in seen and return the grown seen-set.

pending_requires_action(history)

@spec pending_requires_action([map()]) :: map() | nil

Return the stop_reason map of the last requires_action idle event if it was never followed by another terminal idle (i.e. still pending), else nil.

unanswered_tool_uses(history)

@spec unanswered_tool_uses([map()]) :: [map()]

Return agent.custom_tool_use events that have no matching user.custom_tool_result.