SuperPi.UI.Pending (super_pi v0.1.0)

Copy Markdown View Source

Hands a decision from before_tool to wrap_tool for the same tool call.

before_tool runs in the conversation machine, wrap_tool in the tool task, and the machine must not block on a human (it would stop answering cancel, steer, get_state and compact). So a plugin that wants an answer from a human lets the call through in before_tool, leaves a note here and asks in wrap_tool, which runs in the task. The note is keyed by conversation and tool call id. take/2 removes it. A note that nobody takes (a later plugin blocked the call) expires after ten minutes and is dropped on the next put/3.

Summary

Functions

Returns a specification to start this module under a supervisor.

Leaves a note for the tool call.

Removes and returns the note of the tool call, or nil.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

put(conversation_id, tool_call_id, note)

@spec put(integer(), term(), term()) :: :ok

Leaves a note for the tool call.

start_link(opts)

take(conversation_id, tool_call_id)

@spec take(integer(), term()) :: term() | nil

Removes and returns the note of the tool call, or nil.