agentsociety.agent.dispatcher

Module Contents

Classes

BlockDispatcher

Orchestrates task routing between registered processing blocks.

Data

API

agentsociety.agent.dispatcher.DISPATCHER_PROMPT = <Multiline-String>
class agentsociety.agent.dispatcher.BlockDispatcher(toolbox: agentsociety.agent.toolbox.AgentToolbox, agent_memory: agentsociety.memory.Memory, selection_prompt: str = DISPATCHER_PROMPT)

Orchestrates task routing between registered processing blocks.

Attributes: toolbox: AgentToolbox blocks: Registry of available processing blocks (name -> Block mapping) prompt: Formatted prompt template for LLM instructions

Initialization

Initialize dispatcher with LLM interface.

Args: llm: Language model for block selection decisions

register_dispatcher_prompt(dispatcher_prompt: str) → None

Register a dispatcher prompt.

Args: dispatcher_prompt: Dispatcher prompt

register_blocks(blocks: list[agentsociety.agent.block.Block]) → None

Register multiple processing blocks for dispatching.

Args: blocks: List of Block instances to register

_get_function_schema() → openai.types.chat.ChatCompletionToolParam

Generate LLM function calling schema describing available blocks.

  • Description:

    • Creates a schema for the LLM to select appropriate blocks or indicate no suitable block exists.

  • Returns:

    • ChatCompletionToolParam: Function schema dictionary compatible with OpenAI-style function calling

async dispatch(context: agentsociety.agent.context.DotDict) → agentsociety.agent.block.Block | None

Route a task step to the most appropriate processing block.

  • Description:

    • Uses LLM to select the best block for handling the given task intention.

    • Can return None if no suitable block is found.

  • Args:

    • intention (str): Intention of the task

  • Returns:

    • Block | None: Selected Block instance for handling the task, or None if no suitable block exists