ToolContext

org.llm4s.agent.graph.tool.ToolContext
See theToolContext companion object
final case class ToolContext

What a tool call knows: the run, the call's id, the call's IdempotencyKey, the thread state it may read, and whether the call has been approved. Built with ToolContext(...); a field added later gets a default there and a with* setter, so existing callers keep compiling.

A tool with an external side effect passes idempotencyKey to the system it calls (an Idempotency-Key header, a client token, a unique column), because the runtime may run the same call more than once: a retrying wrapper, recover after a failure, cancellation or crash, and an approval each run it again with the same key. A call can even run twice at once: a worker paused past its claim's lease may still be running it when another runtime takes the thread over and runs it too, with the same key. A system that can fence writers can refuse the stale worker: run.position.fencingToken is the run's claim token, which grows with every claim on the thread, so the system keeps the highest token it has seen and refuses a lower one.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def effectKey(operation: String, discriminator: String*): EffectKey

The key of one external effect of this phase of the call - operation, such as file.edit, on what discriminator names (a path) - for org.llm4s.agent.graph.ReplayGuard (design §4.24). In execute its base is idempotencyKey, so it is the same in every run of execute: a retrying wrapper, recover, and a re-run after approval. An answered resume is another phase of the call, keyed by the call, the phase that asked, the question and the answer: the same in every run of that resume (recover of a failed one included), different from execute and from every other resume of the call, a resume that asks again included.

The key of one external effect of this phase of the call - operation, such as file.edit, on what discriminator names (a path) - for org.llm4s.agent.graph.ReplayGuard (design §4.24). In execute its base is idempotencyKey, so it is the same in every run of execute: a retrying wrapper, recover, and a re-run after approval. An answered resume is another phase of the call, keyed by the call, the phase that asked, the question and the answer: the same in every run of that resume (recover of a failed one included), different from execute and from every other resume of the call, a resume that asks again included.

Attributes

def withApproved(a: Boolean): ToolContext

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product