agentbreeder-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ *.egg
7
+ dist/
8
+ build/
9
+ .eggs/
10
+ *.whl
11
+
12
+ # Virtual environments
13
+ venv/
14
+ .venv/
15
+ env/
16
+
17
+ # IDE
18
+ .idea/
19
+ .vscode/
20
+ *.swp
21
+ *.swo
22
+ *~
23
+
24
+ # Environment
25
+ .env
26
+ .env.local
27
+ .env.production
28
+
29
+ # Testing & Coverage
30
+ .coverage
31
+ htmlcov/
32
+ .pytest_cache/
33
+ .mypy_cache/
34
+ .ruff_cache/
35
+
36
+ # OS
37
+ .DS_Store
38
+ Thumbs.db
39
+
40
+ # Docker
41
+ *.log
42
+
43
+ # AgentBreeder local state
44
+ .agentbreeder/
45
+
46
+ # Node (dashboard)
47
+ node_modules/
48
+ dashboard/dist/
49
+ dashboard/.env
50
+ dashboard/test-results/
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentbreeder-sdk
3
+ Version: 0.1.0
4
+ Summary: AgentBreeder Python SDK — define, validate, and deploy AI agents programmatically.
5
+ Project-URL: Homepage, https://github.com/open-agent-garden/agentbreeder
6
+ Project-URL: Repository, https://github.com/open-agent-garden/agentbreeder
7
+ Project-URL: Documentation, https://open-agent-garden.github.io/agentbreeder
8
+ Author: AgentBreeder Contributors
9
+ License-Expression: Apache-2.0
10
+ Keywords: agentbreeder,agents,ai,sdk
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.11
18
+ Requires-Dist: pyyaml>=6.0
19
+ Provides-Extra: mcp
20
+ Requires-Dist: mcp>=1.0.0; extra == 'mcp'
21
+ Description-Content-Type: text/markdown
22
+
23
+ # agentbreeder-sdk
24
+
25
+ The official Python SDK for [AgentBreeder](https://github.com/open-agent-garden/agentbreeder) — define, validate, and deploy AI agents programmatically.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install agentbreeder-sdk
31
+ ```
32
+
33
+ For MCP server authoring support:
34
+
35
+ ```bash
36
+ pip install "agentbreeder-sdk[mcp]"
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ from agenthub import Agent, Tool, Model, Memory
43
+
44
+ # Define an agent
45
+ agent = (
46
+ Agent("customer-support", version="1.0.0", team="customer-success")
47
+ .with_model(primary="claude-sonnet-4", fallback="gpt-4o")
48
+ .with_prompt(system="You are a helpful customer support agent.")
49
+ .with_tool(ref="tools/zendesk-mcp")
50
+ .with_tool(ref="tools/order-lookup")
51
+ .with_deploy(cloud="aws", region="us-east-1")
52
+ )
53
+
54
+ # Validate and export to agent.yaml
55
+ agent.validate()
56
+ agent.to_yaml("agent.yaml")
57
+ ```
58
+
59
+ ## Multi-Agent Orchestration
60
+
61
+ ```python
62
+ from agenthub import Orchestration, KeywordRouter
63
+
64
+ pipeline = (
65
+ Orchestration("support-router", strategy="router", team="customer-success")
66
+ .add_agent("triage", ref="agents/triage-agent")
67
+ .add_agent("billing", ref="agents/billing-agent")
68
+ .add_agent("returns", ref="agents/returns-agent")
69
+ .with_route("triage", condition="billing", target="billing")
70
+ .with_route("triage", condition="return", target="returns")
71
+ )
72
+
73
+ pipeline.to_yaml("orchestration.yaml")
74
+ ```
75
+
76
+ ## Key Classes
77
+
78
+ | Class | Description |
79
+ |-------|-------------|
80
+ | `Agent` | Define an individual AI agent |
81
+ | `Tool` | Define or reference a tool |
82
+ | `Model` | Configure a model (primary + fallback) |
83
+ | `Memory` | Configure agent memory |
84
+ | `Orchestration` | Define multi-agent orchestration |
85
+ | `Pipeline` | Sequential agent pipeline |
86
+ | `FanOut` | Parallel fan-out orchestration |
87
+ | `Supervisor` | Supervisor + worker orchestration |
88
+
89
+ All classes serialize to the same `agent.yaml` / `orchestration.yaml` format consumed by `agentbreeder deploy`.
90
+
91
+ ## Tier Mobility
92
+
93
+ The SDK is the **Full Code** tier of AgentBreeder. You can eject from a YAML config to SDK code at any time:
94
+
95
+ ```bash
96
+ agentbreeder eject agent.yaml --output agent_sdk.py
97
+ ```
98
+
99
+ ## Links
100
+
101
+ - [Documentation](https://open-agent-garden.github.io/agentbreeder)
102
+ - [GitHub](https://github.com/open-agent-garden/agentbreeder)
103
+ - [agent.yaml reference](https://open-agent-garden.github.io/agentbreeder/agent-yaml)
@@ -0,0 +1,81 @@
1
+ # agentbreeder-sdk
2
+
3
+ The official Python SDK for [AgentBreeder](https://github.com/open-agent-garden/agentbreeder) — define, validate, and deploy AI agents programmatically.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install agentbreeder-sdk
9
+ ```
10
+
11
+ For MCP server authoring support:
12
+
13
+ ```bash
14
+ pip install "agentbreeder-sdk[mcp]"
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```python
20
+ from agenthub import Agent, Tool, Model, Memory
21
+
22
+ # Define an agent
23
+ agent = (
24
+ Agent("customer-support", version="1.0.0", team="customer-success")
25
+ .with_model(primary="claude-sonnet-4", fallback="gpt-4o")
26
+ .with_prompt(system="You are a helpful customer support agent.")
27
+ .with_tool(ref="tools/zendesk-mcp")
28
+ .with_tool(ref="tools/order-lookup")
29
+ .with_deploy(cloud="aws", region="us-east-1")
30
+ )
31
+
32
+ # Validate and export to agent.yaml
33
+ agent.validate()
34
+ agent.to_yaml("agent.yaml")
35
+ ```
36
+
37
+ ## Multi-Agent Orchestration
38
+
39
+ ```python
40
+ from agenthub import Orchestration, KeywordRouter
41
+
42
+ pipeline = (
43
+ Orchestration("support-router", strategy="router", team="customer-success")
44
+ .add_agent("triage", ref="agents/triage-agent")
45
+ .add_agent("billing", ref="agents/billing-agent")
46
+ .add_agent("returns", ref="agents/returns-agent")
47
+ .with_route("triage", condition="billing", target="billing")
48
+ .with_route("triage", condition="return", target="returns")
49
+ )
50
+
51
+ pipeline.to_yaml("orchestration.yaml")
52
+ ```
53
+
54
+ ## Key Classes
55
+
56
+ | Class | Description |
57
+ |-------|-------------|
58
+ | `Agent` | Define an individual AI agent |
59
+ | `Tool` | Define or reference a tool |
60
+ | `Model` | Configure a model (primary + fallback) |
61
+ | `Memory` | Configure agent memory |
62
+ | `Orchestration` | Define multi-agent orchestration |
63
+ | `Pipeline` | Sequential agent pipeline |
64
+ | `FanOut` | Parallel fan-out orchestration |
65
+ | `Supervisor` | Supervisor + worker orchestration |
66
+
67
+ All classes serialize to the same `agent.yaml` / `orchestration.yaml` format consumed by `agentbreeder deploy`.
68
+
69
+ ## Tier Mobility
70
+
71
+ The SDK is the **Full Code** tier of AgentBreeder. You can eject from a YAML config to SDK code at any time:
72
+
73
+ ```bash
74
+ agentbreeder eject agent.yaml --output agent_sdk.py
75
+ ```
76
+
77
+ ## Links
78
+
79
+ - [Documentation](https://open-agent-garden.github.io/agentbreeder)
80
+ - [GitHub](https://github.com/open-agent-garden/agentbreeder)
81
+ - [agent.yaml reference](https://open-agent-garden.github.io/agentbreeder/agent-yaml)
File without changes
@@ -0,0 +1,81 @@
1
+ """AgentBreeder Python SDK — Full Code tier.
2
+
3
+ Define, validate, serialize, and deploy agents and orchestrations programmatically.
4
+
5
+ Usage::
6
+
7
+ from agenthub import Agent, Tool, Model, Memory
8
+ from agenthub import Orchestration, Pipeline, FanOut, Supervisor
9
+ from agenthub import KeywordRouter, IntentRouter, RoundRobinRouter, ClassifierRouter
10
+
11
+ agent = (
12
+ Agent("my-agent", version="1.0.0", team="eng")
13
+ .with_model(primary="claude-sonnet-4")
14
+ .with_prompt(system="You are helpful.")
15
+ .with_deploy(cloud="aws")
16
+ )
17
+
18
+ pipeline = (
19
+ Orchestration("support", strategy="router", team="eng")
20
+ .add_agent("triage", ref="agents/triage")
21
+ .add_agent("billing", ref="agents/billing")
22
+ .with_route("triage", condition="billing", target="billing")
23
+ )
24
+ """
25
+
26
+ from .agent import Agent, AgentConfig
27
+ from .deploy import DeployConfig, PromptConfig
28
+ from .memory import Memory, MemoryConfig
29
+ from .model import Model, ModelConfig
30
+ from .orchestration import (
31
+ AgentEntry,
32
+ ClassifierRouter,
33
+ FanOut,
34
+ IntentRouter,
35
+ KeywordRouter,
36
+ Orchestration,
37
+ OrchestrationConfig,
38
+ OrchestrationDeployConfig,
39
+ Pipeline,
40
+ RoundRobinRouter,
41
+ Router,
42
+ RouteRule,
43
+ SharedStateConfig,
44
+ Supervisor,
45
+ SupervisorConfig,
46
+ )
47
+ from .tool import Tool, ToolConfig
48
+
49
+ __version__ = "0.1.0"
50
+
51
+ __all__ = [
52
+ # Agent
53
+ "Agent",
54
+ "AgentConfig",
55
+ "DeployConfig",
56
+ "Memory",
57
+ "MemoryConfig",
58
+ "Model",
59
+ "ModelConfig",
60
+ "PromptConfig",
61
+ "Tool",
62
+ "ToolConfig",
63
+ # Orchestration — builders
64
+ "Orchestration",
65
+ "Pipeline",
66
+ "FanOut",
67
+ "Supervisor",
68
+ # Orchestration — routers
69
+ "Router",
70
+ "KeywordRouter",
71
+ "IntentRouter",
72
+ "RoundRobinRouter",
73
+ "ClassifierRouter",
74
+ # Orchestration — data types
75
+ "OrchestrationConfig",
76
+ "OrchestrationDeployConfig",
77
+ "AgentEntry",
78
+ "RouteRule",
79
+ "SharedStateConfig",
80
+ "SupervisorConfig",
81
+ ]
@@ -0,0 +1,215 @@
1
+ """Core Agent class for the AgentBreeder Full Code Python SDK.
2
+
3
+ Provides a builder-pattern API for defining agents programmatically.
4
+ The resulting agent config can be serialized to valid agent.yaml,
5
+ loaded from YAML, and deployed via the standard pipeline.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import logging
11
+ from collections.abc import Callable
12
+ from dataclasses import dataclass, field
13
+ from pathlib import Path
14
+ from typing import Any
15
+
16
+ from .deploy import DeployConfig, PromptConfig
17
+ from .memory import MemoryConfig
18
+ from .model import ModelConfig
19
+ from .tool import Tool, ToolConfig
20
+
21
+ logger = logging.getLogger(__name__)
22
+
23
+
24
+ @dataclass
25
+ class AgentConfig:
26
+ """Configuration for an AgentBreeder agent."""
27
+
28
+ name: str
29
+ version: str = "1.0.0"
30
+ description: str = ""
31
+ team: str = "default"
32
+ owner: str = ""
33
+ framework: str = "custom"
34
+ model: ModelConfig | None = None
35
+ tools: list[ToolConfig] = field(default_factory=list)
36
+ prompts: PromptConfig | None = None
37
+ memory: MemoryConfig | None = None
38
+ guardrails: list[str] = field(default_factory=list)
39
+ deploy: DeployConfig | None = None
40
+ tags: list[str] = field(default_factory=list)
41
+ knowledge_bases: list[str] = field(default_factory=list)
42
+ subagents: list[dict[str, str]] = field(default_factory=list)
43
+ mcp_servers: list[dict[str, str]] = field(default_factory=list)
44
+
45
+
46
+ class Agent:
47
+ """Full Code SDK entry point for defining agents programmatically.
48
+
49
+ Supports a fluent builder pattern::
50
+
51
+ agent = (
52
+ Agent("my-agent", version="1.0.0", team="eng")
53
+ .with_model(primary="claude-sonnet-4")
54
+ .with_prompt(system="You are helpful.")
55
+ .with_deploy(cloud="aws")
56
+ )
57
+ """
58
+
59
+ def __init__(self, name: str, **kwargs: Any) -> None:
60
+ self.config = AgentConfig(name=name, **kwargs)
61
+ self._tools: list[Tool] = []
62
+ self._middleware: list[Callable[..., Any]] = []
63
+ self._hooks: dict[str, list[Callable[..., Any]]] = {}
64
+ self._state: dict[str, Any] = {}
65
+
66
+ # -----------------------------------------------------------------
67
+ # Builder pattern methods (all return self for chaining)
68
+ # -----------------------------------------------------------------
69
+
70
+ def with_model(
71
+ self,
72
+ primary: str,
73
+ fallback: str | None = None,
74
+ **kwargs: Any,
75
+ ) -> Agent:
76
+ """Configure the LLM model."""
77
+ self.config.model = ModelConfig(primary=primary, fallback=fallback, **kwargs)
78
+ return self
79
+
80
+ def with_tool(self, tool: Tool) -> Agent:
81
+ """Add a tool to this agent."""
82
+ self._tools.append(tool)
83
+ self.config.tools.append(tool.to_config())
84
+ return self
85
+
86
+ def with_prompt(self, system: str, **kwargs: Any) -> Agent:
87
+ """Set the system prompt (inline text or registry ref)."""
88
+ self.config.prompts = PromptConfig(system=system, **kwargs)
89
+ return self
90
+
91
+ def with_memory(self, backend: str = "in_memory", **kwargs: Any) -> Agent:
92
+ """Configure conversation memory."""
93
+ self.config.memory = MemoryConfig(backend=backend, **kwargs)
94
+ return self
95
+
96
+ def with_guardrail(self, name: str) -> Agent:
97
+ """Add a guardrail by name."""
98
+ self.config.guardrails.append(name)
99
+ return self
100
+
101
+ def with_subagent(
102
+ self,
103
+ ref: str,
104
+ name: str | None = None,
105
+ description: str | None = None,
106
+ ) -> Agent:
107
+ """Add a subagent reference for A2A communication."""
108
+ entry: dict[str, str] = {"ref": ref}
109
+ if name:
110
+ entry["name"] = name
111
+ if description:
112
+ entry["description"] = description
113
+ self.config.subagents.append(entry)
114
+ return self
115
+
116
+ def with_mcp_server(self, ref: str, transport: str = "stdio") -> Agent:
117
+ """Attach an MCP server as a sidecar."""
118
+ self.config.mcp_servers.append({"ref": ref, "transport": transport})
119
+ return self
120
+
121
+ def with_deploy(self, cloud: str = "local", **kwargs: Any) -> Agent:
122
+ """Configure deployment target."""
123
+ self.config.deploy = DeployConfig(cloud=cloud, **kwargs)
124
+ return self
125
+
126
+ def tag(self, *tags: str) -> Agent:
127
+ """Add discovery tags."""
128
+ self.config.tags.extend(tags)
129
+ return self
130
+
131
+ # -----------------------------------------------------------------
132
+ # Advanced features
133
+ # -----------------------------------------------------------------
134
+
135
+ def use(self, middleware: Callable[..., Any]) -> Agent:
136
+ """Add middleware (pre/post processing on every turn)."""
137
+ self._middleware.append(middleware)
138
+ return self
139
+
140
+ def on(self, event: str, handler: Callable[..., Any]) -> Agent:
141
+ """Register event hook (tool_call, turn_start, turn_end, error)."""
142
+ self._hooks.setdefault(event, []).append(handler)
143
+ return self
144
+
145
+ @property
146
+ def state(self) -> dict[str, Any]:
147
+ """Typed state persisted across turns."""
148
+ return self._state
149
+
150
+ def route(self, message: str, context: dict[str, Any]) -> str | None:
151
+ """Override for custom routing logic. Return tool/agent name or None."""
152
+ return None
153
+
154
+ def select_tools(self, message: str) -> list[Tool]:
155
+ """Override for dynamic tool selection based on input."""
156
+ return list(self._tools)
157
+
158
+ # -----------------------------------------------------------------
159
+ # Serialization
160
+ # -----------------------------------------------------------------
161
+
162
+ def to_yaml(self) -> str:
163
+ """Serialize to valid agent.yaml content."""
164
+ from .yaml_utils import agent_to_yaml
165
+
166
+ return agent_to_yaml(self)
167
+
168
+ @classmethod
169
+ def from_yaml(cls, yaml_content: str) -> Agent:
170
+ """Load agent from YAML string."""
171
+ from .yaml_utils import yaml_to_agent
172
+
173
+ return yaml_to_agent(yaml_content)
174
+
175
+ @classmethod
176
+ def from_file(cls, path: str) -> Agent:
177
+ """Load agent from YAML file path."""
178
+ content = Path(path).read_text(encoding="utf-8")
179
+ return cls.from_yaml(content)
180
+
181
+ def save(self, path: str) -> None:
182
+ """Save agent.yaml to disk."""
183
+ Path(path).write_text(self.to_yaml(), encoding="utf-8")
184
+ logger.info("Saved agent config to %s", path)
185
+
186
+ # -----------------------------------------------------------------
187
+ # Deployment
188
+ # -----------------------------------------------------------------
189
+
190
+ def deploy(self, target: str = "local") -> dict[str, Any]:
191
+ """Deploy this agent (wraps agentbreeder deploy).
192
+
193
+ Returns deploy info dict. Currently a placeholder that saves the
194
+ YAML and returns metadata; the real implementation delegates to
195
+ the engine.DeployEngine pipeline.
196
+ """
197
+ logger.info("Deploying agent '%s' to target '%s'", self.config.name, target)
198
+ return {
199
+ "agent": self.config.name,
200
+ "version": self.config.version,
201
+ "target": target,
202
+ "status": "pending",
203
+ }
204
+
205
+ def validate(self) -> list[str]:
206
+ """Validate the agent config. Returns list of error messages (empty = valid)."""
207
+ from .validation import validate_agent
208
+
209
+ return validate_agent(self)
210
+
211
+ def __repr__(self) -> str:
212
+ return (
213
+ f"Agent(name={self.config.name!r}, version={self.config.version!r}, "
214
+ f"framework={self.config.framework!r})"
215
+ )
@@ -0,0 +1,47 @@
1
+ """Deploy and prompt configuration dataclasses for AgentBreeder agents."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from typing import Any
7
+
8
+
9
+ @dataclass
10
+ class DeployConfig:
11
+ """Deployment target configuration."""
12
+
13
+ cloud: str = "local"
14
+ runtime: str | None = None
15
+ region: str | None = None
16
+ scaling: dict[str, Any] | None = None
17
+ resources: dict[str, str] | None = None
18
+ env_vars: dict[str, str] = field(default_factory=dict)
19
+ secrets: list[str] = field(default_factory=list)
20
+
21
+ def to_dict(self) -> dict:
22
+ """Serialize to a dict suitable for YAML output."""
23
+ d: dict = {"cloud": self.cloud}
24
+ if self.runtime is not None:
25
+ d["runtime"] = self.runtime
26
+ if self.region is not None:
27
+ d["region"] = self.region
28
+ if self.scaling is not None:
29
+ d["scaling"] = self.scaling
30
+ if self.resources is not None:
31
+ d["resources"] = self.resources
32
+ if self.env_vars:
33
+ d["env_vars"] = self.env_vars
34
+ if self.secrets:
35
+ d["secrets"] = self.secrets
36
+ return d
37
+
38
+
39
+ @dataclass
40
+ class PromptConfig:
41
+ """Prompt configuration for an agent."""
42
+
43
+ system: str
44
+
45
+ def to_dict(self) -> dict:
46
+ """Serialize to a dict suitable for YAML output."""
47
+ return {"system": self.system}