LemonRouter.ToolStatusCoalescer (lemon_router v0.1.0)

View Source

Coalesce tool/action lifecycle events into a single editable "Tool calls" message.

This is intentionally separate from StreamCoalescer (answer streaming). Tool actions can run without producing output deltas, so we want a dedicated status surface.

Channel-specific presentation is handled by LemonChannels.Dispatcher.

Summary

Functions

Attach subsequent tool status updates to the latest assistant text chunk.

Returns a specification to start this module under a supervisor.

Finalize the current tool-status segment without marking running actions complete.

Finalize the tool status for a run by marking any still-running actions as completed.

Force flush the tool status message for a session/channel.

Ingest an action event into the tool status coalescer.

Functions

anchor_segment(session_key, channel_id, run_id, prefix_text, opts \\ [])

Attach subsequent tool status updates to the latest assistant text chunk.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

commit_segment(session_key, channel_id, run_id, opts \\ [])

Finalize the current tool-status segment without marking running actions complete.

finalize_run(session_key, channel_id, run_id, ok?, opts \\ [])

Finalize the tool status for a run by marking any still-running actions as completed.

flush(session_key, channel_id, opts \\ [])

Force flush the tool status message for a session/channel.

ingest_action(session_key, channel_id, run_id, action_event, opts \\ [])

Ingest an action event into the tool status coalescer.

Options:

  • :meta - semantic delivery metadata (for example :user_msg_id)
  • :surface - semantic presentation surface, defaults to :status

ingest_projected_child_action(session_key, channel_id, parent_run_id, surface, projected_event, opts \\ [])

Ingest a projected child action into a parent-owned task surface.

This is a narrow wrapper over normal action ingestion so callers can be explicit that the event originated from a bridged child run rather than the parent run's native engine event stream.

start_link(opts)