pub struct AgentExecutor { /* private fields */ }Expand description
An Executor that runs an SupportsAgentRun over the incoming conversation and
appends the agent’s reply. Rust analogue of AgentExecutor.
Implementations§
Source§impl AgentExecutor
impl AgentExecutor
Sourcepub fn new(
id: impl Into<String>,
agent: Arc<dyn SupportsAgentRun>,
) -> AgentExecutor
pub fn new( id: impl Into<String>, agent: Arc<dyn SupportsAgentRun>, ) -> AgentExecutor
Wrap agent as an executor with the given id.
Sourcepub fn with_chain_only_responses(self, chain_only: bool) -> AgentExecutor
pub fn with_chain_only_responses(self, chain_only: bool) -> AgentExecutor
Send downstream only this agent’s response, not the whole
conversation (upstream WithChainOnlyAgentResponses). Its workflow
output, when it yields one, is still the whole conversation.
Sourcepub fn with_reassign_other_agents_as_users(
self,
reassign: bool,
) -> AgentExecutor
pub fn with_reassign_other_agents_as_users( self, reassign: bool, ) -> AgentExecutor
Present other agents’ assistant messages to this agent as user
messages (upstream AIAgentHostOptions.ReassignOtherAgentsAsUsers), so
it answers them rather than treating them as its own earlier turns.
Messages keep their author name.
Sourcepub fn with_trailing_user_turn(self, ensure: bool) -> AgentExecutor
pub fn with_trailing_user_turn(self, ensure: bool) -> AgentExecutor
When set, a conversation ending on an assistant message is run with a
synthetic user continuation turn appended, for providers that answer
such a prompt with empty text. The turn is invocation-only: it is
never added to the conversation passed on. Off by default. See
SequentialBuilder::ensure_trailing_user_turn.
Sourcepub fn with_output(self, emit_output: bool) -> AgentExecutor
pub fn with_output(self, emit_output: bool) -> AgentExecutor
When set, the executor yields the running conversation as a workflow
output. Unless Self::with_also_send is also set, this replaces
forwarding the conversation downstream (the pre-designation default:
a pipeline’s terminal executor only yields, it has nothing downstream
to send to).
Sourcepub fn with_also_send(self, also_send: bool) -> AgentExecutor
pub fn with_also_send(self, also_send: bool) -> AgentExecutor
When set, the executor forwards the conversation downstream via
WorkflowContext::send_message even if Self::with_output is
also set (rather than the exclusive-or default). Needed whenever an
interior (non-terminal) participant is designated as an output or
intermediate-output source and must still hand the conversation to
the next stage / the fan-in barrier.
Trait Implementations§
Source§impl Executor for AgentExecutor
impl Executor for AgentExecutor
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
message: Value,
ctx: WorkflowContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
AgentExecutor: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
message: Value,
ctx: WorkflowContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
AgentExecutor: 'async_trait,
Source§fn snapshot_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn snapshot_state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn restore_state<'life0, 'async_trait>(
&'life0 self,
_state: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn restore_state<'life0, 'async_trait>(
&'life0 self,
_state: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Executor::snapshot_state. Read moreSource§fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
IResettableExecutor):
an executor instance is shared by every run of its workflow, so one
that keeps per-run state clears it here. Called on every executor at
the start of a run (not on a resume from a checkpoint). The default
does nothing.Source§fn describe_protocol(&self) -> ProtocolDescriptor
fn describe_protocol(&self) -> ProtocolDescriptor
DescribeProtocol). Payloads here are JSON, so types are names the
workflow’s author chooses (or JSON type names). The default accepts
anything and declares nothing.Source§fn request_port(&self) -> Option<RequestPortInfo>
fn request_port(&self) -> Option<RequestPortInfo>
None for other executors.