AgentRun
A running agent turn, from Agent.start: cancel it, or await its AgentResult. The turn runs on its own thread, owned by the runtime, whether or not anyone awaits it.
Attributes
- Source
- AgentRun.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Blocks until the turn ends, then returns its result - Suspended included - or the error it failed with; the outcome is retained, so every call made once the turn has ended returns the same value. A call whose awaiting thread is interrupted before then returns Left(CancelledError) instead, with the interrupt flag still set, and the turn keeps running: a later call returns its outcome, and only cancel stops it (Agent.run, Agent.recover and Agent.resume cancel it, then await its end). With tracing, the turn's trace is complete when a call returns the turn's outcome.
Blocks until the turn ends, then returns its result - Suspended included - or the error it failed with; the outcome is retained, so every call made once the turn has ended returns the same value. A call whose awaiting thread is interrupted before then returns Left(CancelledError) instead, with the interrupt flag still set, and the turn keeps running: a later call returns its outcome, and only cancel stops it (Agent.run, Agent.recover and Agent.resume cancel it, then await its end). With tracing, the turn's trace is complete when a call returns the turn's outcome.
With a listener - from Agent.stream, Agent.streamResume, Agent.streamRecover or subscribe - a call that returns the outcome returns only once each listener has returned from the turn's last event (its terminal event, a Disconnected, or, for a turn that ended without a terminal event, its last delivered one), waiting at most 5 seconds in all; past that it logs a WARN and returns. A call made from a listener does not wait for that listener. For a turn that lost its claim, the turn's last event is the last one it delivered before it ended; a write it abandoned that lands later is not the turn's (see subscribe).
Attributes
- Source
- AgentRun.scala
Cancels the turn; see org.llm4s.agent.graph.RunHandle.cancel. The thread is left for recover, as it is after a turn that lost its claim (GraphError.ClaimLost) once the thread is free: recover is refused with ThreadBusy while another runtime holds it.
Cancels the turn; see org.llm4s.agent.graph.RunHandle.cancel. The thread is left for recover, as it is after a turn that lost its claim (GraphError.ClaimLost) once the thread is free: recover is refused with ThreadBusy while another runtime holds it.
Attributes
- Source
- AgentRun.scala
Attributes
- Source
- AgentRun.scala
Non-blocking: Running until the turn ends, then how it ended.
Subscribes listener to this turn's events: its durable events replayed from the turn's start, then live; its live events from now on (a live event sent before this call is missed - use Agent.stream to receive every one). Run-scoped: nothing of another run on the thread is delivered - so the cross-runtime ordering caveat of org.llm4s.agent.graph.GraphRuntime.subscribe does not arise here: another runtime's commits are not part of this turn - and the subscription ends itself after the turn's terminal event, or after a Disconnected - which reaches the listener only if it fell behind (Lagging), threw (ListenerFailed), or the replay could not read the thread's log (ReplayFailed). A turn that ends without a terminal event (a crash, or a failed commit) ends the subscription as soon as it has delivered the turn's last event - also when it subscribed after the turn ended - and cancelling the returned subscription ends it at once. await returns only once listener has returned from the turn's last event (or the subscription was cancelled), waiting at most 5 seconds. A turn that lost its claim (GraphError.ClaimLost) ends its subscription at its end, which never waits on a hung store: a Durability.Async write it abandoned may land afterwards, and is then not one of the turn's events
Subscribes listener to this turn's events: its durable events replayed from the turn's start, then live; its live events from now on (a live event sent before this call is missed - use Agent.stream to receive every one). Run-scoped: nothing of another run on the thread is delivered - so the cross-runtime ordering caveat of org.llm4s.agent.graph.GraphRuntime.subscribe does not arise here: another runtime's commits are not part of this turn - and the subscription ends itself after the turn's terminal event, or after a Disconnected - which reaches the listener only if it fell behind (Lagging), threw (ListenerFailed), or the replay could not read the thread's log (ReplayFailed). A turn that ends without a terminal event (a crash, or a failed commit) ends the subscription as soon as it has delivered the turn's last event - also when it subscribed after the turn ended - and cancelling the returned subscription ends it at once. await returns only once listener has returned from the turn's last event (or the subscription was cancelled), waiting at most 5 seconds. A turn that lost its claim (GraphError.ClaimLost) ends its subscription at its end, which never waits on a hung store: a Durability.Async write it abandoned may land afterwards, and is then not one of the turn's events
- it is never delivered here, even by a replay - but is visible only in the thread's log (org.llm4s.agent.graph.GraphRuntime.subscribe).
With nested, it also receives every event of each child the turn delegates to after this call, as StreamEvent.Nested (design 4.47; see Agent.stream).
Attributes
- Source
- AgentRun.scala
Attributes
- Source
- AgentRun.scala
