agui_agent
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AGUIAgent llmling_agent.agent.agui_agent MessageNode that wraps a remote AG-UI protocol server. |
||
| AGUISessionState llmling_agent.agent.agui_agent Track state for an active AG-UI session. |
||
| ChatMessage llmling_agent.messaging.messages Common message format for all UI types. |
||
| MessageNode llmling_agent.messaging.messagenode Base class for all message processing nodes. |
||
| MessageStats llmling_agent.talk.stats Statistics for a single connection. |
||
| StreamCompleteEvent llmling_agent.agent.events Event indicating streaming is complete with final message. |
🛈 DocStrings¶
AG-UI remote agent implementation.
This module provides a MessageNode adapter that connects to remote AG-UI protocol servers, enabling remote agent execution with streaming support.
AGUIAgent
¶
Bases: MessageNode[TDeps, str]
MessageNode that wraps a remote AG-UI protocol server.
Connects to AG-UI compatible endpoints via HTTP/SSE and provides the same interface as native agents, enabling composition with other nodes via connections, teams, etc.
The agent manages: - HTTP client lifecycle (create on enter, close on exit) - AG-UI protocol communication via SSE streams - Event conversion to native llmling-agent events - Message accumulation and final response generation
Supports both blocking run() and streaming run_stream() execution modes.
Example
async with AGUIAgent(
endpoint="http://localhost:8000/agent/run",
name="remote-agent"
) as agent:
result = await agent.run("Hello, world!")
async for event in agent.run_stream("Tell me a story"):
print(event)
Source code in src/llmling_agent/agent/agui_agent.py
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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
__aenter__
async
¶
__aenter__() -> Self
Enter async context - initialize client and base resources.
Source code in src/llmling_agent/agent/agui_agent.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Exit async context - cleanup client and base resources.
Source code in src/llmling_agent/agent/agui_agent.py
164 165 166 167 168 169 170 171 172 173 174 175 176 | |
__init__
¶
__init__(
endpoint: str,
*,
name: str = "agui-agent",
description: str | None = None,
display_name: str | None = None,
timeout: float = 60.0,
headers: dict[str, str] | None = None,
mcp_servers: Sequence[str | MCPServerConfig] | None = None,
agent_pool: AgentPool[Any] | None = None,
enable_logging: bool = True,
event_configs: Sequence[EventConfig] | None = None
) -> None
Initialize AG-UI agent client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
HTTP endpoint for the AG-UI agent |
required |
name
|
str
|
Agent name for identification |
'agui-agent'
|
description
|
str | None
|
Agent description |
None
|
display_name
|
str | None
|
Human-readable display name |
None
|
timeout
|
float
|
Request timeout in seconds |
60.0
|
headers
|
dict[str, str] | None
|
Additional HTTP headers |
None
|
mcp_servers
|
Sequence[str | MCPServerConfig] | None
|
MCP servers to connect |
None
|
agent_pool
|
AgentPool[Any] | None
|
Agent pool for multi-agent coordination |
None
|
enable_logging
|
bool
|
Whether to enable database logging |
True
|
event_configs
|
Sequence[EventConfig] | None
|
Event trigger configurations |
None
|
Source code in src/llmling_agent/agent/agui_agent.py
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 | |
get_stats
async
¶
get_stats() -> MessageStats
Get message statistics for this node.
Source code in src/llmling_agent/agent/agui_agent.py
390 391 392 | |
run
async
¶
run(*prompts: PromptCompatible, message_id: str | None = None, **kwargs: Any) -> ChatMessage[str]
Execute prompt against AG-UI agent.
Sends the prompt to the AG-UI server and waits for completion. Events are collected and the final text content is returned as a ChatMessage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts
|
PromptCompatible
|
Prompts to send (will be joined with spaces) |
()
|
message_id
|
str | None
|
Optional message id for the returned message |
None
|
**kwargs
|
Any
|
Additional arguments (ignored for compatibility) |
{}
|
Returns:
| Type | Description |
|---|---|
ChatMessage[str]
|
ChatMessage containing the agent's aggregated text response |
Source code in src/llmling_agent/agent/agui_agent.py
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 217 218 219 220 221 222 223 224 225 | |
run_iter
async
¶
run_iter(
*prompt_groups: Sequence[PromptCompatible], message_id: str | None = None, **kwargs: Any
) -> AsyncIterator[ChatMessage[str]]
Execute multiple prompt groups sequentially.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_groups
|
Sequence[PromptCompatible]
|
Groups of prompts to execute |
()
|
message_id
|
str | None
|
Optional message ID base |
None
|
**kwargs
|
Any
|
Additional arguments (ignored for compatibility) |
{}
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[ChatMessage[str]]
|
ChatMessage for each completed prompt group |
Source code in src/llmling_agent/agent/agui_agent.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | |
run_stream
async
¶
run_stream(
*prompts: PromptCompatible, message_id: str | None = None, **kwargs: Any
) -> AsyncIterator[RichAgentStreamEvent[str]]
Execute prompt with streaming events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts
|
PromptCompatible
|
Prompts to send |
()
|
message_id
|
str | None
|
Optional message ID |
None
|
**kwargs
|
Any
|
Additional arguments (ignored for compatibility) |
{}
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[RichAgentStreamEvent[str]]
|
Native streaming events converted from AG-UI protocol |
Source code in src/llmling_agent/agent/agui_agent.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
to_tool
¶
to_tool(description: str | None = None) -> Callable[[str], Any]
Convert agent to a callable tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str | None
|
Tool description |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[str], Any]
|
Async function that can be used as a tool |
Source code in src/llmling_agent/agent/agui_agent.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
AGUISessionState
dataclass
¶
Track state for an active AG-UI session.
Source code in src/llmling_agent/agent/agui_agent.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
is_complete
class-attribute
instance-attribute
¶
is_complete: bool = False
Whether the current run is complete.
text_chunks
class-attribute
instance-attribute
¶
Accumulated text chunks.
thought_chunks
class-attribute
instance-attribute
¶
Accumulated thought chunks.
tool_calls
class-attribute
instance-attribute
¶
tool_calls: dict[str, dict[str, Any]] = field(default_factory=dict)
Active tool calls by ID.
main
async
¶
main() -> None
Example usage.
Source code in src/llmling_agent/agent/agui_agent.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |