Skip to content

antikythera_agents ¤

Classes¤

Agent ¤

Agent()

Base class for all Antikythera agents.

An agent is responsible for executing tasks of a specific type. Each agent can have multiple tools (methods) that handle different operations.

Notes

Override this method to set up connections, load models, etc.

Functions¤

__enter__ ¤
__enter__()

Support for context manager usage.

__exit__ ¤
__exit__(exc_type, exc_val, exc_tb)

Clean up when used as context manager.

can_claim_task ¤
can_claim_task(task: Task) -> bool

Check if this agent can handle the given task.

Parameters:

  • task (Task) –

    The task to check

Returns:

  • bool

    True if the agent can handle the task, False otherwise

dispose ¤
dispose()

Clean up resources and perform shutdown operations.

Notes

Override this method to close connections, save state, etc.

execute_task ¤
execute_task(task: Task, context: ExecutionContext | None = None) -> dict[str, Any]

Execute a task using the appropriate tool.

Parameters:

  • task (Task) –

    The task to execute

  • context (ExecutionContext, default: None ) –

    The runtime context for the execution

Returns:

  • dict

    Dictionary of outputs from the tool execution

Raises:

has_tool ¤
has_tool(tool_name: str) -> bool

Check if this agent has a specific tool.

Parameters:

  • tool_name (str) –

    Name of the tool to check for

Returns:

  • bool

    True if the tool exists, False otherwise

list_tools ¤
list_tools() -> dict[str, str]

List all available tools for this agent.

Returns:

  • dict

    Dictionary mapping tool names to their method names

managed_execution ¤
managed_execution()

Context manager for safe agent execution with proper resource management.

Functions¤

agent ¤

agent(type: str)

Decorator to register an agent class with a specific type.

Parameters:

  • type (str) –

    The agent type identifier (e.g., "system", "user_interaction")

Examples:

>>> @agent(type="system")
... class SystemAgent(Agent):
...     pass

get_agent_class ¤

get_agent_class(agent_type: str) -> type | None

Get the agent class for a given type.

Parameters:

  • agent_type (str) –

    The agent type identifier

Returns:

  • type or None

    The agent class if found, None otherwise

list_registered_agents ¤

list_registered_agents() -> dict[str, type]

List all registered agent types and their classes.

Returns:

  • dict

    Dictionary mapping agent type strings to their classes

tool ¤

tool(name: str | None = None)

Decorator to mark a method as a tool within an agent.

Parameters:

  • name (str, default: None ) –

    Optional tool name. If not provided, uses the method name.

Examples:

>>> @tool(name="start_process")
... def start(self, task: Task) -> dict:
...     return {"result": "started"}