pub async fn run_agent_loop_from_assistant(
context: AgentContext,
config: AgentLoopConfig,
emit: Arc<dyn AgentEmitter>,
stream_fn: StreamFn,
) -> Result<NewMessages, AgentError>Expand description
Continue a run whose last assistant message has not had its tools run.
This is the case a deferred (long-poll) provider creates: the turn’s assistant message arrives from a poll rather than from the loop, so it is already in the transcript while its tool calls are still unanswered. The next provider request would be rejected (every provider refuses an assistant message whose tool calls have no results), so the tools must run first — which is exactly what this entry point does before continuing the loop normally.
Errors when the last message is not an assistant message: there would be nothing to resume, and silently calling the provider instead would be wrong.