pyagent-blueprint API Reference¶
pyagent_blueprint
¶
PyAgent Blueprint — declarative YAML specs for multi-agent LLM systems.
BlueprintCompiler
¶
Compile a BlueprintSpec into a RuntimeGraph.
Steps: 1. Resolve provider bindings → LLMCallable instances 2. Instantiate agents with resolved LLMs 3. Look up pattern class from registry 4. Wire agents into pattern constructor kwargs 5. Return RuntimeGraph
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_registry
|
Any
|
Optional |
None
|
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/compiler.py
23 24 25 26 27 28 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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
compile(spec)
¶
Compile a blueprint spec into a runnable RuntimeGraph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BlueprintSpec
|
Validated |
required |
Returns:
| Type | Description |
|---|---|
RuntimeGraph
|
|
Raises:
| Type | Description |
|---|---|
CompilationError
|
If the spec references unknown patterns or agents. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/compiler.py
CompilationError
¶
BlueprintDiffer
¶
Compute semantic diff between two blueprint specs.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/differ.py
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 | |
diff(old, new)
¶
Diff two blueprint specs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
BlueprintSpec
|
Previous version. |
required |
new
|
BlueprintSpec
|
Updated version. |
required |
Returns:
| Type | Description |
|---|---|
list[Change]
|
List of |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/differ.py
summary(changes)
¶
Human-readable summary of changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
changes
|
list[Change]
|
List from |
required |
Returns:
| Type | Description |
|---|---|
str
|
Multi-line summary string. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/differ.py
Change
dataclass
¶
A single semantic change between two blueprint versions.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
Dotted path to the changed field. |
change_type |
ChangeType
|
Added, removed, or modified. |
old_value |
Any
|
Previous value (None for added). |
new_value |
Any
|
New value (None for removed). |
severity |
ChangeSeverity
|
Impact level. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/differ.py
BlueprintGenerator
¶
Generate scaffold blueprint YAML from a pattern name and agent list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_provider_model
|
str
|
Model to use in the default provider binding. |
'gpt-4.1-mini'
|
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/generator.py
generate(pattern, agents, *, name='my-blueprint', version='0.1.0', description='')
¶
Generate a blueprint YAML string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
str
|
Pattern registry name (e.g., |
required |
agents
|
list[str]
|
List of agent names. |
required |
name
|
str
|
Blueprint name. |
'my-blueprint'
|
version
|
str
|
Blueprint version. |
'0.1.0'
|
description
|
str
|
Blueprint description. |
''
|
Returns:
| Type | Description |
|---|---|
str
|
YAML string. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the pattern is not registered. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/generator.py
BlueprintLoadError
¶
BlueprintRenderer
¶
Render a BlueprintSpec as Mermaid diagrams or Markdown docs.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/renderer.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 | |
to_mermaid(spec)
¶
Render the blueprint as a Mermaid flowchart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BlueprintSpec
|
Blueprint specification. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Mermaid diagram string. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/renderer.py
to_markdown(spec)
¶
Render the blueprint as Markdown documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BlueprintSpec
|
Blueprint specification. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Markdown string. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/renderer.py
RuntimeGraph
¶
Executable graph of compiled workflows.
Each workflow is a fully wired Pattern instance ready to run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflows
|
dict[str, Pattern]
|
Mapping of workflow name → compiled Pattern. |
required |
agents
|
dict[str, Agent] | None
|
Mapping of agent name → Agent instance. |
None
|
metadata
|
dict[str, Any] | None
|
Blueprint metadata dict. |
None
|
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 | |
wire_trace(bus)
¶
Set trace_bus on all patterns and their agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bus
|
Any
|
A |
required |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
wire_context(ledger)
¶
Set context ledger on all agents in all workflows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ledger
|
Any
|
A |
required |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
wire_compressor(compressor)
¶
Set compressor on all agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compressor
|
Any
|
A |
required |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
wire_cost_tracker(tracker)
¶
Set cost tracker on all agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracker
|
Any
|
A |
required |
run(workflow, task)
async
¶
Run a workflow by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workflow
|
str
|
Workflow name from the blueprint. |
required |
task
|
str
|
Input task string. |
required |
Returns:
| Type | Description |
|---|---|
Result
|
Pattern |
Raises:
| Type | Description |
|---|---|
KeyError
|
If workflow name doesn't exist. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
stream(workflow, task)
async
¶
Stream results from a workflow.
Falls back to run() and yields the full output if the pattern
doesn't support native streaming.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
describe()
¶
Introspect the runtime graph.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with metadata and workflow descriptions. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/runtime.py
AgentSpec
¶
Bases: BaseModel
Specification of a single agent.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/agents.py
BlueprintSpec
¶
Bases: BaseModel
Root specification for a declarative agent system.
This is the top-level Pydantic model that represents a complete blueprint YAML/JSON document.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/spec.py
ContextConfigSpec
¶
Bases: BaseModel
Context configuration for a blueprint.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/context.py
ContractSpec
¶
Bases: BaseModel
Input/output contract for a workflow.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/contracts.py
MetadataSpec
¶
Bases: BaseModel
Blueprint metadata.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/metadata.py
ObservabilitySpec
¶
Bases: BaseModel
Observability configuration for a blueprint.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/observability.py
ProviderBindingSpec
¶
Bases: BaseModel
Binding of a logical provider name to a model + backend.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/providers.py
WorkflowSpec
¶
Bases: BaseModel
Specification of a workflow: pattern + agent wiring.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/schema/workflows.py
BlueprintTester
¶
Run conformance tests for blueprint contracts using MockLLM.
Compiles the blueprint with mock providers and verifies that: - Workflows produce output - Output type matches contract expectations - SLA constraints are within bounds (basic checks)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
compiler
|
BlueprintCompiler | None
|
Optional compiler instance. Creates one if not provided. |
None
|
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/tester.py
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 | |
test(spec, test_inputs=None)
async
¶
Run contract conformance tests for all workflows with contracts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BlueprintSpec
|
Blueprint spec to test. |
required |
test_inputs
|
dict[str, str] | None
|
Optional mapping of workflow name → test input. If not provided, uses a default test string. |
None
|
Returns:
| Type | Description |
|---|---|
list[TestResult]
|
List of |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/tester.py
summary(results)
¶
Human-readable summary of test results.
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/tester.py
TestResult
dataclass
¶
Result of a single contract test.
Attributes:
| Name | Type | Description |
|---|---|---|
workflow |
str
|
Workflow name tested. |
passed |
bool
|
Whether the test passed. |
output |
str
|
The actual output from the workflow. |
checks |
dict[str, bool]
|
Dict of check name → pass/fail. |
error |
str | None
|
Error message if the test failed with an exception. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/tester.py
BlueprintValidator
¶
Run static checks on a BlueprintSpec.
Checks: - All agent refs in workflows exist in agents dict - All provider refs in agents exist in providers dict - Pattern names are registered - No cyclic workflow dependencies - SLA values are realistic - Security: no hardcoded API keys in prompts
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/validator.py
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 | |
validate(spec)
¶
Run all validation checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
BlueprintSpec
|
The blueprint spec to validate. |
required |
Returns:
| Type | Description |
|---|---|
list[ValidationIssue]
|
List of issues found (may be empty). |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/validator.py
ValidationIssue
dataclass
¶
A single validation finding.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
Dotted path to the problematic field. |
message |
str
|
Human-readable description. |
severity |
IssueSeverity
|
Error, warning, or info. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/validator.py
load_blueprint(path)
¶
Load a blueprint from a YAML or JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a |
required |
Returns:
| Type | Description |
|---|---|
BlueprintSpec
|
Validated |
Raises:
| Type | Description |
|---|---|
BlueprintLoadError
|
If the file is missing, unreadable, or invalid. |
Source code in packages/pyagent-blueprint/src/pyagent_blueprint/loader.py
load_blueprint_from_str(text, fmt='yaml')
¶
Load a blueprint from a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
YAML or JSON text. |
required |
fmt
|
str
|
|
'yaml'
|
Returns:
| Type | Description |
|---|---|
BlueprintSpec
|
Validated |