ant_ai.a2a.colony
Colony
pydantic-model
Bases: BaseModel
Class defining the Colony. It's the world for the agents that are part of the system.
Show JSON schema:
{
"description": "Class defining the Colony. It's the world for the agents that are part of the system.",
"properties": {
"db_url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Db Url"
}
},
"title": "Colony",
"type": "object"
}
Config:
arbitrary_types_allowed:True
Fields:
-
db_url(str | None)
Source code in src/ant_ai/a2a/colony.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
aclose
async
aclose() -> None
Dispose the async engine, returning all connections to the pool.
Source code in src/ant_ai/a2a/colony.py
47 48 49 50 | |
agent
Adds an agent to the colony.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the agent in the system. |
required |
agent
|
Agent
|
The agent to be registered. |
required |
workflow
|
Workflow
|
The agent's workflow that will guide the agent execution. |
required |
card
|
AgentCard
|
The A2A card for the agent. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the agent is already registered. |
Returns:
| Type | Description |
|---|---|
Colony
|
The Colony instance with the registered agent. |
Source code in src/ant_ai/a2a/colony.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
collab
collab(
source: str,
target: str,
*,
config: A2AConfig | None = None,
mutual: bool = False,
) -> Colony
Register collaboration edges.
- If config is omitted, a2a_defaults are used.
- If mutual=True, inserts both source->target and target->source.
- If the same edge is added twice, the last config wins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The agent that can call another. |
required |
target
|
str
|
The agent that becomes the tool to be called. |
required |
config
|
A2AConfig | None
|
Configuration to be used for the connection. If None, defaults will be used, which assume the target agent serves A2A at the root of its URL with default settings. Defaults to None. |
None
|
mutual
|
bool
|
If True then the ability to initiate the conversation is given to both. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Colony |
Colony
|
The Colony instance with the new collaboration defined. |
Source code in src/ant_ai/a2a/colony.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
asgi
asgi(
*, agent_name: str, use_fastapi: bool = True
) -> FastAPI | Starlette
Creates the A2A server, with the specified ASGI app for the given agent name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_name
|
str
|
The name of the agent to create a app for. |
required |
use_fastapi
|
bool
|
If True then FastAPI is used to create the app. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If the agent name is not registered in Colony. |
Returns:
| Type | Description |
|---|---|
FastAPI | Starlette
|
The ASGI app and server configured for the agent. |
Source code in src/ant_ai/a2a/colony.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
get_agent_host
get_agent_host(agent_name: str) -> tuple[str, int]
Get the base URL of the specified agent.
Source code in src/ant_ai/a2a/colony.py
211 212 213 214 215 216 | |
AgentSpec
pydantic-model
Bases: BaseModel
Specification of a remote agent.
Config:
arbitrary_types_allowed:True
Fields:
Source code in src/ant_ai/a2a/colony.py
219 220 221 222 223 224 225 226 227 228 229 230 | |