Skip to content

AwaitResponseDecision

Base classes

Name Children Inherits
Decision
llmling_agent.delegation.router
Base class for all routing decisions.

⋔ Inheritance diagram

graph TD
  94350421464752["router.AwaitResponseDecision"]
  94350422920384["router.Decision"]
  94350366564672["main.BaseModel"]
  140709601677504["builtins.object"]
  94350422920384 --> 94350421464752
  94350366564672 --> 94350422920384
  140709601677504 --> 94350366564672

🛈 DocStrings

Bases: Decision

Forward message and wait for response.

Source code in src/llmling_agent/delegation/router.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class AwaitResponseDecision(Decision):
    """Forward message and wait for response."""

    type: Literal["await_response"] = Field("await_response", init=False)
    """Type discriminator for await decisions."""

    target_agent: str
    """Name of the agent to forward the message to."""

    talk_back: bool = False
    """Whether to send response back to original agent."""

    async def execute(
        self,
        message: ChatMessage[Any],
        source_agent: AnyAgent[Any, Any],
        pool: AgentPool,
    ):
        """Forward message and wait for response."""
        target = pool.get_agent(self.target_agent)
        response = await target.run(str(message))
        if self.talk_back:
            source_agent.outbox.emit(response, None)

talk_back class-attribute instance-attribute

talk_back: bool = False

Whether to send response back to original agent.

target_agent instance-attribute

target_agent: str

Name of the agent to forward the message to.

type class-attribute instance-attribute

type: Literal['await_response'] = Field('await_response', init=False)

Type discriminator for await decisions.

execute async

execute(message: ChatMessage[Any], source_agent: AnyAgent[Any, Any], pool: AgentPool)

Forward message and wait for response.

Source code in src/llmling_agent/delegation/router.py
76
77
78
79
80
81
82
83
84
85
86
async def execute(
    self,
    message: ChatMessage[Any],
    source_agent: AnyAgent[Any, Any],
    pool: AgentPool,
):
    """Forward message and wait for response."""
    target = pool.get_agent(self.target_agent)
    response = await target.run(str(message))
    if self.talk_back:
        source_agent.outbox.emit(response, None)

Show source on GitHub