What is an Agent?
An Agent is a declarative definition that describes a complete task workflow. The SDK helps you build valid definitions for submission to Platform Core.
Core Concept
An Agent Definition specifies:
- Task inputs and outputs
- Processing workflow (DAG of nodes)
- Required resources (prompts, tools, modules)
- Version and metadata
The SDK compiles Agent Definitions to YAML. Platform Core executes them.
Structure
Every Agent has these components:
agent = (
AgentBuilder("agent-name")
.version("1.0.0") # Required: Semantic version
.description("What it does") # Required: One-line description
.add_workflow(workflow) # Required: At least one workflow
.add_prompt(prompt) # Optional: LLM prompt templates
.add_tool(tool) # Optional: External service definitions
.add_module(module) # Optional: Reusable components
.build()
)Workflows
Define processing logic as directed acyclic graphs (DAGs):
workflow = (
WorkflowBuilder("process")
.description("Main processing workflow")
.add_node(node1)
.add_node(node2)
.entry_node("node1") # Required: Entry point
.build()
)Nodes
Individual processing steps:
node = (
NodeBuilder("extract-data")
.description("Extract data from input")
.uses_prompt("extraction-prompt") # References a prompt
.outputs("extracted_data")
.next_nodes("validate-data")
.build()
)Node types are determined by resource reference:
uses_prompt()- LLM-based processinguses_tool()- External service calluses_module()- Reusable component invocation
SDK Boundary
The SDK is a compiler, not a runtime:
| SDK Does | SDK Does NOT Do |
|---|---|
| Validate definition structure | Execute workflows |
| Check reference integrity | Make network requests |
| Generate YAML output | Calculate execution costs |
| Perform static analysis | Handle authentication |
| Catch cycles and unreachable nodes | Manage retries |
⚠️
Local compilation success does not guarantee platform execution. Platform Core applies additional validation and governance policies.
Execution Flow
- Developer builds Agent Definition using SDK
- SDK validates structure and exports YAML
- Developer submits YAML to Platform Core
- Platform reviews and approves definition
- Users invoke Agent through official clients
- Platform creates Execution instance
- Platform runs workflow and returns results
- Platform handles billing and payment
Agent Definition vs Execution
Key distinction:
# This creates a DEFINITION
agent = AgentBuilder("my-agent").build()
# This validates and exports the DEFINITION
validate(agent)
yaml = export_yaml(agent)
# Platform Core handles EXECUTION (not SDK)
# - User authentication
# - Resource allocation
# - Workflow execution
# - Result delivery
# - BillingRequired Fields
Agent Definition:
name- Matches pattern[a-z][a-z0-9-]*version- Semantic versioning (e.g., “1.0.0”)description- Human-readable summaryworkflows- At least one workflow
Workflow:
name- Matches pattern[a-z][a-z0-9-]*description- Workflow purposenodes- At least one nodeentry_node- Name of starting node
Node:
name- Matches pattern[a-z][a-z0-9-]*description- Node purposetype- One of: prompt, tool, modulereference- Name of referenced resource
Example: Email Extractor
from ainalyn import AgentBuilder, WorkflowBuilder, NodeBuilder, PromptBuilder
from ainalyn.api import validate, export_yaml
# Define prompt
extraction_prompt = (
PromptBuilder("extract-emails")
.description("Extract email addresses from text")
.template("Extract all email addresses from: {{text}}")
.variables("text")
.build()
)
# Define workflow
workflow = (
WorkflowBuilder("extract")
.description("Email extraction workflow")
.add_node(
NodeBuilder("parse-text")
.description("Parse input text")
.uses_prompt("extract-emails")
.outputs("email_list")
.build()
)
.entry_node("parse-text")
.build()
)
# Build agent
agent = (
AgentBuilder("email-extractor")
.version("1.0.0")
.description("Extract email addresses from documents")
.add_prompt(extraction_prompt)
.add_workflow(workflow)
.build()
)
# Validate
result = validate(agent)
if result.is_valid:
yaml_output = export_yaml(agent)
print(yaml_output)Validation
The SDK performs:
- Schema validation - Structural correctness
- Static analysis - Logical consistency
Checks include:
- Required fields present
- Names match pattern
[a-z][a-z0-9-]* - Versions follow semantic versioning
- All references resolve (no undefined resources)
- Workflows form valid DAGs (no cycles)
- All nodes reachable from entry node
- No duplicate names within scope
Output Format
Agents compile to YAML:
name: email-extractor
version: 1.0.0
description: Extract email addresses from documents
workflows:
- name: extract
description: Email extraction workflow
entry_node: parse-text
nodes:
- name: parse-text
description: Parse input text
type: prompt
reference: extract-emails
outputs:
- email_list
prompts:
- name: extract-emails
description: Extract email addresses from text
template: Extract all email addresses from: {{text}}
variables:
- textThis YAML is submitted to Platform Core for execution.
Next Steps
- How the SDK Works - Compilation process
- What You Control - SDK vs Platform responsibilities
- Building Your Agent - Design patterns