A2UISchemaManager
autogen.agents.experimental.a2ui.schema_manager.A2UISchemaManager #
A2UISchemaManager(protocol_version='v0.9', custom_catalog=None, custom_catalog_rules=None, spec_dir=None)
Manages A2UI schema loading and system prompt generation.
Loads the vendored JSON schemas for a given protocol version and generates system prompt sections that instruct an LLM to produce valid A2UI output.
Supports custom catalogs that extend the basic catalog with additional components. Custom catalogs are loaded alongside the basic catalog and both are included in the system prompt.
Directory structure per version::
v0_9/
├── prompt_example.json # Our prompt example (version-specific)
├── prompt_message_types.md # Message type examples to help the LLM (version-specific)
└── spec/ # Copied directly from google/A2UI
├── server_to_client.json
├── basic_catalog.json
├── common_types.json
├── basic_catalog_rules.txt
└── ...
Initialize the schema manager.
| PARAMETER | DESCRIPTION |
|---|---|
protocol_version | The A2UI protocol version. Currently only "v0.9". TYPE: |
custom_catalog | A custom catalog that extends the basic catalog. Can be: - A file path (str or Path) to a JSON catalog file - A dict with the catalog schema directly Must include a |
custom_catalog_rules | Plain-text rules for the custom catalog components, appended to the basic catalog rules in the system prompt. TYPE: |
spec_dir | Override the spec file directory. |
Source code in autogen/agents/experimental/a2ui/schema_manager.py
get_component_schemas #
Get resolved schemas for all components, keyed by component type name.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, dict[str, Any]] | A dict mapping component type names (e.g. "Button") to their |
dict[str, dict[str, Any]] | JSON Schema definitions from the catalog |
Source code in autogen/agents/experimental/a2ui/schema_manager.py
build_schema_registry #
Build a jsonschema referencing Registry for cross-file $ref resolution.
The v0.9 server_to_client.json schema references catalog.json and common_types.json via relative $ref. This method creates a registry that maps those URIs to the loaded schemas so that jsonschema.validate() can resolve them locally.
When a custom catalog is provided, it is registered as catalog.json so that the envelope schema validates against the custom components.
| RETURNS | DESCRIPTION |
|---|---|
Any | A |
Source code in autogen/agents/experimental/a2ui/schema_manager.py
generate_prompt_section #
generate_prompt_section(include_schema=True, include_rules=True, response_delimiter=A2UI_DEFAULT_DELIMITER, actions=None)
Generate the A2UI portion of the system prompt.
| PARAMETER | DESCRIPTION |
|---|---|
include_schema | Whether to include the JSON schema for validation reference. TYPE: |
include_rules | Whether to include the plain-text catalog rules. TYPE: |
response_delimiter | The delimiter the LLM should use to separate text from A2UI JSON. TYPE: |
actions | List of |
| RETURNS | DESCRIPTION |
|---|---|
str | A string to append to the agent's system prompt. |
Source code in autogen/agents/experimental/a2ui/schema_manager.py
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 | |