Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val agent: Agent

The agent that this process is running. Many processes can run the same agent.

Link copied to clipboard
abstract val blackboard: Blackboard

The blackboard for this process. Implementations should delegate to it to implement the Blackboard interface for convenience, but explicitly separating it simplifies persistence.

Link copied to clipboard
abstract val blackboardId: String

Unique identifier of this blackboard. Blackboard doesn't extend StableIdentified to avoid conflict with implementations that are otherwise identified

Link copied to clipboard
abstract val failureInfo: Any?

If we failed, this may contain the reason for the failure.

Link copied to clipboard
open val finished: Boolean

Is the process finished, whether successfully or not?

Link copied to clipboard
abstract val goal: Goal?

Goal of this process. Utility processes may not have a goal.

Link copied to clipboard

History of actions taken by this process

Link copied to clipboard
abstract val id: String

Unique id of this process. Set on creation.

Link copied to clipboard

True if this is a root process (no parent).

Link copied to clipboard
abstract val lastWorldState: WorldState?

The last world state that was used to plan the next action Will be non-null if the process is running

Link copied to clipboard
Link copied to clipboard
abstract val objects: List<Any>

Entries in the order they were added. The default instance of any type is the last one Objects are immutable and may not be removed.

Link copied to clipboard
abstract val parentId: String?

ID of the parent AgentProcess, if any.

Link copied to clipboard
abstract val planner: Planner<*, *, *>

Get the planner for this process

Link copied to clipboard
Link copied to clipboard

Options this process was started with

Link copied to clipboard

How long this process has been running

Link copied to clipboard

Status of this operation

Link copied to clipboard
abstract val toolsStats: ToolsStats

Functions

Link copied to clipboard
open fun addAll(objects: List<Any>)
Link copied to clipboard
abstract fun addObject(value: Any): Bindable

Add to entries without binding to a variable name. Implementations must respect the order in which entities were added. This is equivalent to using the default binding name as the key. For example, if you add a Dog to the blackboard without a key, it will be bound to the default binding name "it" and will be the last entry in the list of objects. Equivalent:

Link copied to clipboard
abstract fun bind(key: String, value: Any): Bindable
Link copied to clipboard
open fun bindAll(bindings: Map<String, Any>)
Link copied to clipboard
abstract fun bindProtected(key: String, value: Any): Bindable

Bind a value to a name and mark it as protected. Protected bindings survive Blackboard.clear operations, which occur during state transitions. Use this for bindings that should persist across states, such as conversation history and user identity.

Link copied to clipboard
@ApiStatus.Internal
abstract fun clear()

Clear all entries from the blackboard. Not intended for use in user code.

Link copied to clipboard
open fun cost(): Double
Link copied to clipboard
open fun costInfoString(verbose: Boolean): String
Link copied to clipboard
open fun <T> count(clazz: Class<T>): Int
Link copied to clipboard
inline fun <T> Blackboard.count(): Int

Count entries of the given type

Link copied to clipboard
open fun embeddingCost(): Double
Link copied to clipboard
Link copied to clipboard

Total embedding call count. Default = own; overridable for subtree aggregation.

Link copied to clipboard
open fun embeddingModelsUsed(): List<<Error class: unknown class>>

Distinct list of embedding services used, sorted by name.

Link copied to clipboard
open fun embeddingUsage(): Usage

Aggregated token usage across all embedding calls. Embeddings have no completion tokens, so Usage.completionTokens is null.

Link copied to clipboard

Expose the model data for use in prompts Prefer more strongly typed usage patterns

Link copied to clipboard
abstract operator fun get(name: String): Any?

Return the value of a variable, if it is set by name. Does not limit return via type information.

Link copied to clipboard
abstract fun getCondition(key: String): Boolean?
Link copied to clipboard
abstract fun <V : Any> getOrPut(name: String, creator: () -> V): V

Threadsafe get or put

Link copied to clipboard
open fun getValue(variable: String, type: String): Any?

Get a variable value. Handles "it" default type specially, because it could be an "it" of different variables, defined as the most recently added entry.

open fun getValue(variable: String = IoBinding.DEFAULT_BINDING, type: String, dataDictionary: DataDictionary): Any?

Resolve the value of a variable, if it is set. Resolve superclasses For example, getValue("it", "Animal") will match a Dog if Dog extends Animal

Link copied to clipboard
open fun hasValue(variable: String = IoBinding.DEFAULT_BINDING, type: String, dataDictionary: DataDictionary): Boolean

Indicates whether this blackboard contains a variable.

Link copied to clipboard
abstract fun hide(what: Any)

Hide this object. Does not remove it from the blackboard but will prevent it being retrieved.

Link copied to clipboard
abstract fun kill(): ProcessKilledEvent?

Kill this process and return an event describing the kill if we are successful

Link copied to clipboard
open fun <T> last(clazz: Class<T>): T?

Last entry of the given type, if there is one

Link copied to clipboard
inline fun <T> Blackboard.last(): T?

Last entry of the given type, if there is one

Link copied to clipboard
open override fun lastResult(): Any?

Last result, of any type, if there is one.

Link copied to clipboard

Total LLM call count. Default = own; overridable for subtree aggregation.

Link copied to clipboard
open fun modelsUsed(): List<<Error class: unknown class>>

Distinct list of LLMs used, sorted by name.

Link copied to clipboard
open fun <T> objectsOfType(clazz: Class<T>): List<T>

Return all objects of the given type

Link copied to clipboard
inline fun <T> Blackboard.objectsOfType(): List<T>

Return all entries of a specific type

Link copied to clipboard
open fun ownCost(): Double

Cost of this process's own LLM invocations, excluding any child processes. See cost for the LLM cost aggregate across the entire process subtree, and totalCost for the cost including embeddings.

Link copied to clipboard
open fun ownModelsUsed(): List<<Error class: unknown class>>

Distinct LLMs used by this process's own invocations, excluding any child processes. See modelsUsed for the aggregate across the entire process subtree.

Link copied to clipboard
open fun ownUsage(): Usage

Token usage of this process's own LLM invocations, excluding any child processes. See usage for the LLM usage aggregate across the entire process subtree, and totalUsage for the usage including embeddings.

Link copied to clipboard
abstract operator fun plusAssign(pair: <Error class: unknown class><String, Any>)
abstract operator fun plusAssign(value: Any)
open operator fun plusAssign(bindings: Map<String, Any>)
Link copied to clipboard

Record an embedding invocation against this process. Default implementation is a no-op for AgentProcess implementations that don't track embeddings; com.embabel.agent.core.support.AbstractAgentProcess provides a thread-safe storage.

Link copied to clipboard
abstract fun recordLlmInvocation(llmInvocation: LlmInvocation)
Link copied to clipboard
open fun <O> resultOfType(outputClass: Class<O>): O
Link copied to clipboard
inline fun <O> AgentProcess.resultOfType(): O

Convenience function to get the result of a specific type

Link copied to clipboard
abstract fun run(): AgentProcess

Run the process as far as we can. Might complete, fail, get stuck or hit a waiting state. This is a slow operation. We may wish to run this async. Events will be emitted as the process runs, so we can track progress.

Link copied to clipboard
abstract operator fun set(key: String, value: Any)

Bind a value to a name

Link copied to clipboard
abstract fun setCondition(key: String, value: Boolean): Blackboard

Explicitly set the condition value Used in planning.

Link copied to clipboard
abstract fun spawn(): Blackboard

Spawn an independent child blackboard based on the content of this

Link copied to clipboard

Return a serializable status report for this process.

Link copied to clipboard
abstract fun terminateAction(reason: String)

Request graceful termination of the current action only. The action will terminate at the next natural checkpoint (between tool calls), and the agent will continue with the next planned action.

Link copied to clipboard
abstract fun terminateAgent(reason: String)

Request graceful termination of the entire agent process. The agent will terminate at the next natural checkpoint (before next tick).

Link copied to clipboard
abstract fun tick(): AgentProcess

Perform the next step only. Return when an action has been completed and the process is ready to plan, regardless of the result of the action.

Link copied to clipboard
open fun totalCost(): Double

Total cost in dollars combining LLM and embedding invocations, including any child processes when the implementation supports subtree aggregation. Use this when you want the full cost of the process; use cost for LLM-only.

Link copied to clipboard
open fun totalCostInfoString(verbose: Boolean): String

Combined cost/usage info across LLM and embedding invocations. Use this for a full report; use costInfoString for LLM-only.

Link copied to clipboard
open fun totalModelsUsed(): List<<Error class: unknown class>>

Distinct models used (LLM and embedding), including any child processes when the implementation supports subtree aggregation. Use this when you want all models; use modelsUsed for LLM-only.

Link copied to clipboard
open fun totalUsage(): Usage

Total token usage combining LLM and embedding invocations, including any child processes when the implementation supports subtree aggregation. Use this when you want the full token usage; use usage for LLM-only.

Link copied to clipboard
open fun usage(): Usage

Note that this is not apples to apples: The usage may be across different LLMs, and the cost may be different. Cost will correctly reflect this. Look in the list for more details about what tokens were spent where.

Link copied to clipboard
inline fun <T> AgentProcess.withCurrent(block: () -> T): T

Execute a block with this AgentProcess as the current process for the thread. Properly saves and restores any previous value, ensuring cleanup even on exception.