runAsync

abstract fun runAsync(userId: String, sessionId: String, invocationId: String? = null, newMessage: Content? = null, stateDelta: Map<String, Any>? = null, runConfig: RunConfig? = null): Flow<Event>

Main entry method to run the agent in this runner asynchronously.

Stopping early, for example with first(), still runs the afterRun plugin callbacks. If buffer() or flowOn(<dispatcher>) runs the flow in another coroutine, stopping early cancels the run instead, which skips them.

Return

The events generated by the agent.

Parameters

userId

The user ID of the session.

sessionId

The session ID, fetched (or created, if the runner creates missing sessions) when collection starts.

invocationId

The invocation ID of the session, set this to resume an interrupted invocation.

newMessage

A new message to append to the session.

stateDelta

Optional state changes to apply to the session.

runConfig

The run config for the agent.

Throws

from the flow if the session does not exist and the runner does not create missing sessions.