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 AgentProcessStatusCodestatusprivate final List<ActionInvocation>historyprivate final ToolsStatstoolsStatsprivate final Stringidprivate final StringparentIdprivate final Agentagentprivate final Instanttimestampprivate final Planner<?, ?, ?>plannerprivate final Booleanfinishedprivate final DurationrunningTimeprivate final StringblackboardIdprivate final List<Object>objectsprivate final List<LlmInvocation>llmInvocations
-
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()AgentProcessStatusCodegetStatus()List<ActionInvocation>getHistory()ToolsStatsgetToolsStats()StringgetId()Unique id of this process StringgetParentId()AgentgetAgent()The agent that this process is running. InstantgetTimestamp()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, recordLlmInvocation, resultOfType, statusReport -
Methods inherited from class com.embabel.agent.core.Blackboard
count, expressionEvaluationModel, get, getBlackboardId, getCondition, getObjects, getOrPut, getValue, hasValue, hide, last, lastResult, objectsOfType, setCondition, spawn -
Methods inherited from class com.embabel.agent.core.LlmInvocationHistory
cost, costInfoString, getLlmInvocations, modelsUsed, usage -
Methods inherited from class com.embabel.agent.core.Bindable
addAll, bindAll, plusAssign -
Methods inherited from class com.embabel.common.core.types.HasInfoString
infoString -
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()
-
getStatus
AgentProcessStatusCode getStatus()
-
getHistory
List<ActionInvocation> getHistory()
-
getToolsStats
ToolsStats getToolsStats()
-
getParentId
String getParentId()
-
getAgent
Agent getAgent()
The agent that this process is running. Many processes can run the same agent.
-
getTimestamp
Instant getTimestamp()
-
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
-
-
-
-