Class AbstractAgentProcess
-
- All Implemented Interfaces:
-
com.embabel.agent.core.AgentProcess,com.embabel.agent.core.Bindable,com.embabel.agent.core.Blackboard,com.embabel.agent.core.LlmInvocationHistory,com.embabel.agent.core.MayHaveLastResult,com.embabel.agent.core.OperationStatus,com.embabel.common.core.types.HasInfoString,com.embabel.common.core.types.Timed,com.embabel.common.core.types.Timestamped
public abstract class AbstractAgentProcess implements AgentProcess, Blackboard
Abstract implementation of AgentProcess that provides common functionality
-
-
Field Summary
Fields Modifier and Type Field Description private final ObjectfailureInfoprivate final WorldStatelastWorldStateprivate final Goalgoalprivate final ProcessContextprocessContextprivate final List<LlmInvocation>llmInvocationsprivate final AgentProcessStatusCodestatusprivate final List<ActionInvocation>historyprivate final ToolsStatstoolsStatsprivate final Stringidprivate final StringparentIdprivate final Agentagentprivate final ProcessOptionsprocessOptionsprivate final Blackboardblackboardprivate final Instanttimestampprivate final Planner<?, ?, ?>plannerprivate final Booleanfinishedprivate final DurationrunningTimeprivate final StringblackboardIdprivate final List<Object>objects
-
Constructor Summary
Constructors Constructor Description AbstractAgentProcess(String id, String parentId, Agent agent, ProcessOptions processOptions, Blackboard blackboard, PlatformServices platformServices, Instant timestamp)
-
Method Summary
Modifier and Type Method Description ObjectgetFailureInfo()If we failed, this may contain the reason for the failure. WorldStategetLastWorldState()The last world state that was used to plan the next action Will be non-null if the process is running GoalgetGoal()Goal of this process. ProcessContextgetProcessContext()List<LlmInvocation>getLlmInvocations()AgentProcessStatusCodegetStatus()List<ActionInvocation>getHistory()History of actions taken by this process ToolsStatsgetToolsStats()StringgetId()Unique id of this process. StringgetParentId()ID of the parent AgentProcess, if any. AgentgetAgent()The agent that this process is running. ProcessOptionsgetProcessOptions()Options this process was started with BlackboardgetBlackboard()The blackboard for this process. InstantgetTimestamp()UnitrecordLlmInvocation(LlmInvocation llmInvocation)ProcessKilledEventkill()Kill this process and return an event describing the kill if we are successful Bindablebind(String key, Object value)UnitplusAssign(Pair<String, Object> pair)UnitplusAssign(Object value)Unitset(String key, Object value)Bind a value to a name BindableaddObject(Object value)Add to entries without binding to a variable name. AgentProcessrun()Run the process as far as we can. AgentProcesstick()Perform the next step only. -
Methods inherited from class com.embabel.agent.core.AgentProcess
getFinished, getPlanner, getRunningTime, getValue, resultOfType, statusReport -
Methods inherited from class com.embabel.agent.core.Blackboard
clear, count, expressionEvaluationModel, get, getBlackboardId, getCondition, getObjects, getOrPut, getValue, hasValue, hide, last, lastResult, objectsOfType, setCondition, spawn -
Methods inherited from class com.embabel.agent.core.Bindable
addAll, bindAll, bindProtected, plusAssign -
Methods inherited from class com.embabel.common.core.types.HasInfoString
infoString -
Methods inherited from class com.embabel.common.core.types.Timestamped
isLaterThan -
Methods inherited from class com.embabel.agent.core.LlmInvocationHistory
cost, costInfoString, modelsUsed, usage -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AbstractAgentProcess
AbstractAgentProcess(String id, String parentId, Agent agent, ProcessOptions processOptions, Blackboard blackboard, PlatformServices platformServices, Instant timestamp)
-
-
Method Detail
-
getFailureInfo
Object getFailureInfo()
If we failed, this may contain the reason for the failure.
-
getLastWorldState
WorldState getLastWorldState()
The last world state that was used to plan the next action Will be non-null if the process is running
-
getProcessContext
ProcessContext getProcessContext()
-
getLlmInvocations
List<LlmInvocation> getLlmInvocations()
-
getStatus
AgentProcessStatusCode getStatus()
-
getHistory
List<ActionInvocation> getHistory()
History of actions taken by this process
-
getToolsStats
ToolsStats getToolsStats()
-
getParentId
String getParentId()
ID of the parent AgentProcess, if any.
-
getAgent
Agent getAgent()
The agent that this process is running. Many processes can run the same agent.
-
getProcessOptions
ProcessOptions getProcessOptions()
Options this process was started with
-
getBlackboard
Blackboard getBlackboard()
The blackboard for this process. Implementations should delegate to it to implement the Blackboard interface for convenience, but explicitly separating it simplifies persistence.
-
getTimestamp
Instant getTimestamp()
-
recordLlmInvocation
Unit recordLlmInvocation(LlmInvocation llmInvocation)
-
kill
ProcessKilledEvent kill()
Kill this process and return an event describing the kill if we are successful
-
plusAssign
Unit plusAssign(Pair<String, Object> pair)
-
plusAssign
Unit plusAssign(Object value)
-
addObject
Bindable addObject(Object value)
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:
blackboard["it"] = dog blackboard.addObject(dog)
-
run
AgentProcess run()
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.
- Returns:
status code of the process. Side effects may have occurred in Blackboard
-
tick
AgentProcess tick()
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.
- Returns:
status code of the action. Side effects may have occurred in Blackboard
-
-
-
-