aw_agents.base

Base classes and protocols for AW agents.

This module provides the foundation for building AI agents that can be deployed to multiple chatbot platforms (Claude, ChatGPT, etc.).

Functions

create_json_schema(properties[, required])

Helper to create JSON schema for tool parameters.

Classes

AgentBase()

Base class for all AW agents.

ToolExecutionResult(success[, data, ...])

Standard result format for tool execution.

class aw_agents.base.AgentBase[source]

Bases: ABC

Base class for all AW agents.

Agents should inherit from this and implement the core methods. Adapters (MCP, OpenAPI) will wrap these agents for deployment.

abstractmethod execute_tool(name, arguments)[source]

Execute a tool with given arguments.

Parameters:
  • name (str) – Tool name

  • arguments (Dict[str, Any]) – Tool arguments

Returns:

  • success: bool

  • data: Any

  • message: Optional[str]

  • warnings: Optional[list[str]]

Return type:

Dict[str, Any]

get_metadata()[source]

Get agent metadata.

Return type:

Dict[str, Any]

Returns:

Metadata including name, version, description

abstractmethod get_tools()[source]

Return tool definitions for this agent.

Each tool should have:

  • name: str

  • description: str

  • parameters: dict (JSON schema)

Return type:

list[Dict[str, Any]]

Returns:

List of tool definitions

class aw_agents.base.ToolExecutionResult(success, data=None, message=None, warnings=None, metadata=None)[source]

Bases: object

Standard result format for tool execution.

classmethod error_result(message, data=None, **kwargs)[source]

Create an error result.

Return type:

ToolExecutionResult

classmethod success_result(data, message=None, **kwargs)[source]

Create a success result.

Return type:

ToolExecutionResult

to_dict()[source]

Convert to dictionary format.

Return type:

Dict[str, Any]

aw_agents.base.create_json_schema(properties, required=None, **kwargs)[source]

Helper to create JSON schema for tool parameters.

>>> schema = create_json_schema(
...     properties={
...         'url': {'type': 'string', 'description': 'URL to process'},
...         'context': {'type': 'string', 'description': 'Context info'}
...     },
...     required=['url']
... )
>>> schema['type']
'object'
>>> 'url' in schema['required']
True
Return type:

Dict[str, Any]