gepa-adk 0.2.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.
Files changed (34) hide show
  1. gepa_adk-0.2.0/PKG-INFO +179 -0
  2. gepa_adk-0.2.0/README.md +147 -0
  3. gepa_adk-0.2.0/pyproject.toml +211 -0
  4. gepa_adk-0.2.0/src/gepa_adk/__init__.py +157 -0
  5. gepa_adk-0.2.0/src/gepa_adk/adapters/__init__.py +72 -0
  6. gepa_adk-0.2.0/src/gepa_adk/adapters/adk_adapter.py +1073 -0
  7. gepa_adk-0.2.0/src/gepa_adk/adapters/candidate_selector.py +230 -0
  8. gepa_adk-0.2.0/src/gepa_adk/adapters/component_selector.py +202 -0
  9. gepa_adk-0.2.0/src/gepa_adk/adapters/critic_scorer.py +632 -0
  10. gepa_adk-0.2.0/src/gepa_adk/adapters/evaluation_policy.py +328 -0
  11. gepa_adk-0.2.0/src/gepa_adk/adapters/multi_agent.py +1099 -0
  12. gepa_adk-0.2.0/src/gepa_adk/adapters/workflow.py +204 -0
  13. gepa_adk-0.2.0/src/gepa_adk/api.py +1184 -0
  14. gepa_adk-0.2.0/src/gepa_adk/domain/__init__.py +110 -0
  15. gepa_adk-0.2.0/src/gepa_adk/domain/exceptions.py +870 -0
  16. gepa_adk-0.2.0/src/gepa_adk/domain/models.py +489 -0
  17. gepa_adk-0.2.0/src/gepa_adk/domain/state.py +593 -0
  18. gepa_adk-0.2.0/src/gepa_adk/domain/trajectory.py +151 -0
  19. gepa_adk-0.2.0/src/gepa_adk/domain/types.py +324 -0
  20. gepa_adk-0.2.0/src/gepa_adk/engine/__init__.py +62 -0
  21. gepa_adk-0.2.0/src/gepa_adk/engine/adk_reflection.py +371 -0
  22. gepa_adk-0.2.0/src/gepa_adk/engine/async_engine.py +986 -0
  23. gepa_adk-0.2.0/src/gepa_adk/engine/genealogy.py +404 -0
  24. gepa_adk-0.2.0/src/gepa_adk/engine/merge_proposer.py +343 -0
  25. gepa_adk-0.2.0/src/gepa_adk/engine/proposer.py +398 -0
  26. gepa_adk-0.2.0/src/gepa_adk/ports/__init__.py +86 -0
  27. gepa_adk-0.2.0/src/gepa_adk/ports/adapter.py +200 -0
  28. gepa_adk-0.2.0/src/gepa_adk/ports/agent_provider.py +189 -0
  29. gepa_adk-0.2.0/src/gepa_adk/ports/proposer.py +118 -0
  30. gepa_adk-0.2.0/src/gepa_adk/ports/scorer.py +197 -0
  31. gepa_adk-0.2.0/src/gepa_adk/ports/selector.py +202 -0
  32. gepa_adk-0.2.0/src/gepa_adk/utils/__init__.py +52 -0
  33. gepa_adk-0.2.0/src/gepa_adk/utils/events.py +737 -0
  34. gepa_adk-0.2.0/src/gepa_adk/utils/state_guard.py +247 -0
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.3
2
+ Name: gepa-adk
3
+ Version: 0.2.0
4
+ Summary: Evolutionary optimization for Google ADK agents
5
+ Keywords: ai,agents,evolution,optimization,genetic-algorithm,prompt-engineering,adk,llm
6
+ Author: Alberto-Codes
7
+ Author-email: Alberto-Codes <alberto.codes.dev@gmail.com>
8
+ License: Apache-2.0
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Typing :: Typed
19
+ Requires-Dist: google-adk>=1.22.0
20
+ Requires-Dist: litellm>=1.80.13
21
+ Requires-Dist: nest-asyncio>=1.6.0
22
+ Requires-Dist: structlog>=25.5.0
23
+ Maintainer: Alberto-Codes
24
+ Maintainer-email: Alberto-Codes <alberto.codes.dev@gmail.com>
25
+ Requires-Python: >=3.12, <3.13
26
+ Project-URL: Homepage, https://github.com/Alberto-Codes/gepa-adk
27
+ Project-URL: Documentation, https://alberto-codes.github.io/gepa-adk/
28
+ Project-URL: Repository, https://github.com/Alberto-Codes/gepa-adk
29
+ Project-URL: Issues, https://github.com/Alberto-Codes/gepa-adk/issues
30
+ Project-URL: Changelog, https://github.com/Alberto-Codes/gepa-adk/releases
31
+ Description-Content-Type: text/markdown
32
+
33
+ # gepa-adk
34
+
35
+ Evolutionary optimization for Google ADK agents.
36
+
37
+ ## What is this?
38
+
39
+ `gepa-adk` makes your AI agents better automatically. It takes an agent, runs it against examples, gets feedback, and evolves the agent's instructions until performance improves.
40
+
41
+ Think of it as natural selection for AI prompts—the best instructions survive and improve.
42
+
43
+ ## Who is this for?
44
+
45
+ Teams building AI agents with Google's Agent Development Kit (ADK) who want to:
46
+
47
+ - Improve agent performance without manual prompt tweaking
48
+ - Use structured feedback (not just pass/fail) to guide improvements
49
+ - Evolve multiple agents working together
50
+ - Get 3-5x faster optimization through parallel evaluation
51
+
52
+ ## Installation
53
+
54
+ ### Prerequisites
55
+
56
+ Before installing gepa-adk, you need:
57
+
58
+ 1. **Python 3.12+**
59
+ 2. **Ollama** with the `gpt-oss:20b` model:
60
+ ```bash
61
+ # Install Ollama (if not already installed)
62
+ # Visit https://ollama.ai for installation instructions
63
+
64
+ # Pull the required model
65
+ ollama pull gpt-oss:20b
66
+ ```
67
+ 3. **Set environment variable**:
68
+ ```bash
69
+ export OLLAMA_API_BASE=http://localhost:11434
70
+ ```
71
+
72
+ **Why gpt-oss:20b?** The evolutionary optimization engine uses this model internally to generate improved agent instructions. Without it, evolution will fail.
73
+
74
+ **Why local models?** Evolutionary optimization makes many LLM calls per run (evaluating multiple candidates across iterations). We recommend Ollama with open-source models to avoid API costs and rate limits. However, gepa-adk works with any Google ADK-supported model (including Gemini) - just be aware of potential costs.
75
+
76
+ ### Install gepa-adk
77
+
78
+ ```bash
79
+ pip install gepa-adk
80
+ ```
81
+
82
+ **For development or if using uv:**
83
+
84
+ ```bash
85
+ uv add gepa-adk
86
+ ```
87
+
88
+ ## Quick Start
89
+
90
+ ```python
91
+ from pydantic import BaseModel, Field
92
+ from google.adk.agents import LlmAgent
93
+ from gepa_adk import evolve_sync
94
+
95
+ class Output(BaseModel):
96
+ answer: str
97
+ score: float = Field(ge=0.0, le=1.0)
98
+
99
+ agent = LlmAgent(name="assistant", model="gemini-2.0-flash",
100
+ instruction="You are a helpful assistant.", output_schema=Output)
101
+ trainset = [{"input": "What is 2+2?", "expected": "4"}]
102
+ result = evolve_sync(agent, trainset)
103
+ print(f"Evolved: {result.evolved_instruction}")
104
+ ```
105
+
106
+ ## Examples
107
+
108
+ Complete working examples are available in the `examples/` directory:
109
+
110
+ - **[basic_evolution.py](examples/basic_evolution.py)** — Simple greeting agent evolution with critic scoring
111
+ - **[critic_agent.py](examples/critic_agent.py)** — Story generation with dedicated critic agent for evaluation
112
+ - **[basic_evolution_adk_reflection.py](examples/basic_evolution_adk_reflection.py)** — Evolution using an ADK LlmAgent as the reflection agent
113
+
114
+ All examples require Ollama with `gpt-oss:20b` model (see Prerequisites above).
115
+
116
+ Run an example:
117
+ ```bash
118
+ python examples/basic_evolution.py
119
+ ```
120
+
121
+ ## Documentation
122
+
123
+ - [Getting Started Guide](https://alberto-codes.github.io/gepa-adk/getting-started/) — Step-by-step walkthrough from installation to first evolution
124
+ - [Use Case Guides](https://alberto-codes.github.io/gepa-adk/guides/) — Patterns for single-agent, critic agents, multi-agent, and workflows
125
+ - [API Reference](https://alberto-codes.github.io/gepa-adk/reference/) — Complete documentation for all public functions and classes
126
+
127
+ ## Troubleshooting
128
+
129
+ ### "Model not found" or "Connection refused" errors
130
+
131
+ Ensure Ollama is running and the model is pulled:
132
+
133
+ ```bash
134
+ # Check Ollama is running
135
+ curl http://localhost:11434/api/tags
136
+
137
+ # Pull the model if not present
138
+ ollama pull gpt-oss:20b
139
+
140
+ # Verify the model is available
141
+ ollama list | grep gpt-oss
142
+ ```
143
+
144
+ ### Evolution is slow or uses too many iterations
145
+
146
+ Adjust the `EvolutionConfig` parameters:
147
+
148
+ ```python
149
+ from gepa_adk import EvolutionConfig
150
+
151
+ config = EvolutionConfig(
152
+ max_iterations=3, # Reduce iterations
153
+ patience=2, # Stop early if no improvement
154
+ )
155
+
156
+ result = evolve_sync(agent, trainset, config=config)
157
+ ```
158
+
159
+ ### Want to use a different model?
160
+
161
+ **For your agents:** You can use any model supported by Google ADK (Gemini, Ollama models, etc.). The examples use `ollama_chat/gpt-oss:20b` but you can change this to `gemini-2.0-flash` or other ADK-supported models.
162
+
163
+ **For the evolution engine:** Currently, the reflection model is hardcoded to `ollama_chat/gpt-oss:20b`. Future versions will support custom model configuration. For now, ensure this model is available in your Ollama instance.
164
+
165
+ **Cost warning:** Using cloud APIs like Gemini for agents during evolution can result in high costs due to the many evaluation calls required.
166
+
167
+ ## Status
168
+
169
+ **In Development** — Not yet ready for production use.
170
+
171
+ See [docs/proposals/](docs/proposals/) for technical design and roadmap.
172
+
173
+ ## Credits
174
+
175
+ This project implements concepts from [GEPA](https://github.com/gepa-ai/gepa) (Genetic-Pareto optimization) and integrates with [Google ADK](https://github.com/google/adk-python).
176
+
177
+ ## License
178
+
179
+ Apache License 2.0 - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,147 @@
1
+ # gepa-adk
2
+
3
+ Evolutionary optimization for Google ADK agents.
4
+
5
+ ## What is this?
6
+
7
+ `gepa-adk` makes your AI agents better automatically. It takes an agent, runs it against examples, gets feedback, and evolves the agent's instructions until performance improves.
8
+
9
+ Think of it as natural selection for AI prompts—the best instructions survive and improve.
10
+
11
+ ## Who is this for?
12
+
13
+ Teams building AI agents with Google's Agent Development Kit (ADK) who want to:
14
+
15
+ - Improve agent performance without manual prompt tweaking
16
+ - Use structured feedback (not just pass/fail) to guide improvements
17
+ - Evolve multiple agents working together
18
+ - Get 3-5x faster optimization through parallel evaluation
19
+
20
+ ## Installation
21
+
22
+ ### Prerequisites
23
+
24
+ Before installing gepa-adk, you need:
25
+
26
+ 1. **Python 3.12+**
27
+ 2. **Ollama** with the `gpt-oss:20b` model:
28
+ ```bash
29
+ # Install Ollama (if not already installed)
30
+ # Visit https://ollama.ai for installation instructions
31
+
32
+ # Pull the required model
33
+ ollama pull gpt-oss:20b
34
+ ```
35
+ 3. **Set environment variable**:
36
+ ```bash
37
+ export OLLAMA_API_BASE=http://localhost:11434
38
+ ```
39
+
40
+ **Why gpt-oss:20b?** The evolutionary optimization engine uses this model internally to generate improved agent instructions. Without it, evolution will fail.
41
+
42
+ **Why local models?** Evolutionary optimization makes many LLM calls per run (evaluating multiple candidates across iterations). We recommend Ollama with open-source models to avoid API costs and rate limits. However, gepa-adk works with any Google ADK-supported model (including Gemini) - just be aware of potential costs.
43
+
44
+ ### Install gepa-adk
45
+
46
+ ```bash
47
+ pip install gepa-adk
48
+ ```
49
+
50
+ **For development or if using uv:**
51
+
52
+ ```bash
53
+ uv add gepa-adk
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ ```python
59
+ from pydantic import BaseModel, Field
60
+ from google.adk.agents import LlmAgent
61
+ from gepa_adk import evolve_sync
62
+
63
+ class Output(BaseModel):
64
+ answer: str
65
+ score: float = Field(ge=0.0, le=1.0)
66
+
67
+ agent = LlmAgent(name="assistant", model="gemini-2.0-flash",
68
+ instruction="You are a helpful assistant.", output_schema=Output)
69
+ trainset = [{"input": "What is 2+2?", "expected": "4"}]
70
+ result = evolve_sync(agent, trainset)
71
+ print(f"Evolved: {result.evolved_instruction}")
72
+ ```
73
+
74
+ ## Examples
75
+
76
+ Complete working examples are available in the `examples/` directory:
77
+
78
+ - **[basic_evolution.py](examples/basic_evolution.py)** — Simple greeting agent evolution with critic scoring
79
+ - **[critic_agent.py](examples/critic_agent.py)** — Story generation with dedicated critic agent for evaluation
80
+ - **[basic_evolution_adk_reflection.py](examples/basic_evolution_adk_reflection.py)** — Evolution using an ADK LlmAgent as the reflection agent
81
+
82
+ All examples require Ollama with `gpt-oss:20b` model (see Prerequisites above).
83
+
84
+ Run an example:
85
+ ```bash
86
+ python examples/basic_evolution.py
87
+ ```
88
+
89
+ ## Documentation
90
+
91
+ - [Getting Started Guide](https://alberto-codes.github.io/gepa-adk/getting-started/) — Step-by-step walkthrough from installation to first evolution
92
+ - [Use Case Guides](https://alberto-codes.github.io/gepa-adk/guides/) — Patterns for single-agent, critic agents, multi-agent, and workflows
93
+ - [API Reference](https://alberto-codes.github.io/gepa-adk/reference/) — Complete documentation for all public functions and classes
94
+
95
+ ## Troubleshooting
96
+
97
+ ### "Model not found" or "Connection refused" errors
98
+
99
+ Ensure Ollama is running and the model is pulled:
100
+
101
+ ```bash
102
+ # Check Ollama is running
103
+ curl http://localhost:11434/api/tags
104
+
105
+ # Pull the model if not present
106
+ ollama pull gpt-oss:20b
107
+
108
+ # Verify the model is available
109
+ ollama list | grep gpt-oss
110
+ ```
111
+
112
+ ### Evolution is slow or uses too many iterations
113
+
114
+ Adjust the `EvolutionConfig` parameters:
115
+
116
+ ```python
117
+ from gepa_adk import EvolutionConfig
118
+
119
+ config = EvolutionConfig(
120
+ max_iterations=3, # Reduce iterations
121
+ patience=2, # Stop early if no improvement
122
+ )
123
+
124
+ result = evolve_sync(agent, trainset, config=config)
125
+ ```
126
+
127
+ ### Want to use a different model?
128
+
129
+ **For your agents:** You can use any model supported by Google ADK (Gemini, Ollama models, etc.). The examples use `ollama_chat/gpt-oss:20b` but you can change this to `gemini-2.0-flash` or other ADK-supported models.
130
+
131
+ **For the evolution engine:** Currently, the reflection model is hardcoded to `ollama_chat/gpt-oss:20b`. Future versions will support custom model configuration. For now, ensure this model is available in your Ollama instance.
132
+
133
+ **Cost warning:** Using cloud APIs like Gemini for agents during evolution can result in high costs due to the many evaluation calls required.
134
+
135
+ ## Status
136
+
137
+ **In Development** — Not yet ready for production use.
138
+
139
+ See [docs/proposals/](docs/proposals/) for technical design and roadmap.
140
+
141
+ ## Credits
142
+
143
+ This project implements concepts from [GEPA](https://github.com/gepa-ai/gepa) (Genetic-Pareto optimization) and integrates with [Google ADK](https://github.com/google/adk-python).
144
+
145
+ ## License
146
+
147
+ Apache License 2.0 - see [LICENSE](LICENSE) for details.
@@ -0,0 +1,211 @@
1
+ [project]
2
+ name = "gepa-adk"
3
+ version = "0.2.0"
4
+ description = "Evolutionary optimization for Google ADK agents"
5
+ readme = "README.md"
6
+ license = { text = "Apache-2.0" }
7
+ authors = [
8
+ { name = "Alberto-Codes", email = "alberto.codes.dev@gmail.com" }
9
+ ]
10
+ maintainers = [
11
+ { name = "Alberto-Codes", email = "alberto.codes.dev@gmail.com" }
12
+ ]
13
+ requires-python = ">=3.12,<3.13"
14
+ dependencies = [
15
+ "google-adk>=1.22.0",
16
+ "litellm>=1.80.13",
17
+ "nest-asyncio>=1.6.0",
18
+ "structlog>=25.5.0",
19
+ ]
20
+ keywords = [
21
+ "ai",
22
+ "agents",
23
+ "evolution",
24
+ "optimization",
25
+ "genetic-algorithm",
26
+ "prompt-engineering",
27
+ "adk",
28
+ "llm",
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 3 - Alpha",
32
+ "Intended Audience :: Developers",
33
+ "Intended Audience :: Science/Research",
34
+ "License :: OSI Approved :: Apache Software License",
35
+ "Operating System :: OS Independent",
36
+ "Programming Language :: Python :: 3",
37
+ "Programming Language :: Python :: 3.12",
38
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
39
+ "Topic :: Software Development :: Libraries :: Python Modules",
40
+ "Typing :: Typed",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/Alberto-Codes/gepa-adk"
45
+ Documentation = "https://alberto-codes.github.io/gepa-adk/"
46
+ Repository = "https://github.com/Alberto-Codes/gepa-adk"
47
+ Issues = "https://github.com/Alberto-Codes/gepa-adk/issues"
48
+ Changelog = "https://github.com/Alberto-Codes/gepa-adk/releases"
49
+
50
+ [project.scripts]
51
+ gepa-adk = "gepa_adk:main"
52
+
53
+ [build-system]
54
+ requires = ["uv_build>=0.9.22,<0.10.0"]
55
+ build-backend = "uv_build"
56
+
57
+ # TestPyPI publishing index (for `uv publish --index testpypi`)
58
+ [[tool.uv.index]]
59
+ name = "testpypi"
60
+ url = "https://test.pypi.org/simple/"
61
+ publish-url = "https://test.pypi.org/legacy/"
62
+ explicit = true
63
+
64
+ [tool.ruff]
65
+ line-length = 88 # Formatter target
66
+ target-version = "py312"
67
+ exclude = [".uv-cache", ".venv", "__pycache__", "*.egg-info"]
68
+
69
+ [tool.ruff.lint]
70
+ # I = isort (import sorting), D = pydocstyle (docstrings), E501 = line length
71
+ extend-select = ["E501", "I", "D"]
72
+
73
+ [tool.ruff.lint.pycodestyle]
74
+ max-line-length = 100 # Linter threshold (allow some flexibility)
75
+
76
+ [tool.ruff.lint.pydocstyle]
77
+ convention = "google"
78
+
79
+ [tool.ruff.lint.per-file-ignores]
80
+ "tests/*.py" = ["S101"]
81
+
82
+ [tool.ruff.lint.isort]
83
+ known-first-party = ["agent_workflow_suite"]
84
+
85
+ [tool.ruff.format]
86
+ quote-style = "double"
87
+ docstring-code-format = true
88
+ docstring-code-line-length = "dynamic"
89
+
90
+ [tool.interrogate]
91
+ verbose = 1
92
+ fail-under = 95
93
+ ignore-init-method = true
94
+ ignore-init-module = true
95
+ ignore-magic = true
96
+ ignore-private = true
97
+ exclude = ["tests", "scripts"]
98
+
99
+ # Ty type checker configuration
100
+ # ty is pre-release (0.0.1a33) with known limitations:
101
+ # - SQLModel/SQLAlchemy Session.exec() not fully typed (shows Unknown | Session)
102
+ # - pytest.MonkeyPatch.context() classmethod detection bug (false missing-argument errors)
103
+ # These are false positives confirmed by 700+ passing tests
104
+ [tool.ty.src]
105
+ exclude = [
106
+ "scripts/", # Utility scripts - not production code
107
+ ]
108
+
109
+ # Override for test files - still type check but ignore pytest.MonkeyPatch.context() bug
110
+ [[tool.ty.overrides]]
111
+ include = ["tests/**"]
112
+
113
+ [tool.ty.overrides.rules]
114
+ # pytest.MonkeyPatch.context() is a classmethod but ty thinks it needs `cls` argument
115
+ # This is a ty bug with pytest type stubs - all 88 errors are this same false positive
116
+ missing-argument = "ignore"
117
+
118
+ [tool.hatch.envs.default.scripts]
119
+
120
+ [dependency-groups]
121
+ dev = [
122
+ "pytest>=8.4.2",
123
+ "pytest-asyncio>=1.2.0",
124
+ "ty>=0.0.1a20",
125
+ "ruff>=0.13.0",
126
+ "pytest-xdist>=3.8.0",
127
+ "python-dotenv>=1.1.1",
128
+ "pytest-cov>=7.0.0",
129
+ "arize-phoenix-client",
130
+ "pytest-timeout>=2.4.0",
131
+ "pytest-profiling>=1.8.1",
132
+ "pytest-mock>=3.15.1",
133
+ "mkdocs-material>=9.7.1",
134
+ "mkdocstrings>=1.0.0",
135
+ "mkdocstrings-python>=2.0.1",
136
+ "mkdocs-gen-files>=0.5.0",
137
+ "mkdocs-literate-nav>=0.6.1",
138
+ "mkdocs-section-index>=0.3.9",
139
+ "mkdocs-git-revision-date-localized-plugin>=1.4.7",
140
+ "mkdocs-minify-plugin>=0.8.0",
141
+ "mkdocs-redirects>=1.2.1",
142
+ "mkdocs-glightbox>=0.4.0",
143
+ "mkdocs-macros-plugin>=1.3.7",
144
+ "pillow>=11.0.0",
145
+ "cairosvg>=2.7.1",
146
+ "interrogate>=1.7.0",
147
+ "griffe-warnings-deprecated>=1.1.0",
148
+ "griffe-inherited-docstrings>=1.1.2",
149
+ "mkdocs-ezglossary-plugin>=2.1.0",
150
+ "gepa>=0.0.24",
151
+ # Pin requests to avoid buggy 2.32.5 version (missing JSONDecodeError/Mapping in compat.py)
152
+ # See: https://github.com/psf/requests/issues/issues
153
+ "requests>=2.32.0,!=2.32.5",
154
+ ]
155
+
156
+ [tool.pytest.ini_options]
157
+ markers = [
158
+ "unit: Unit tests - fast, isolated",
159
+ "contract: Contract tests verifying interface compliance",
160
+ "integration: Integration tests with real databases",
161
+ "slow: Slow-running tests (execution, API calls)",
162
+ "api: Tests that make real API calls to external services (Gemini, Ollama, etc.) - excluded by default",
163
+ "requires_ollama: Tests requiring local Ollama service",
164
+ "requires_gemini: Tests requiring Gemini API (video, native planning)",
165
+ ]
166
+ # Exclude API tests by default to avoid accidental quota usage
167
+ addopts = "-m 'not api'"
168
+ asyncio_mode = "auto"
169
+ asyncio_default_fixture_loop_scope = "function"
170
+ testpaths = ["tests"]
171
+ # Deprecation warning strategy: treat all warnings as errors, explicitly ignore third-party issues.
172
+ # Each ignored warning MUST have a tracking issue. See CONTRIBUTING.md for the full process.
173
+ # Pattern: "ignore:message_regex:WarningClass:module_regex"
174
+ filterwarnings = [
175
+ # Treat all warnings as errors by default - new warnings will fail CI
176
+ "error",
177
+ #
178
+ # === Third-party warning ignores (each with tracking issue) ===
179
+ #
180
+ # Pydantic v2 deprecation warnings from LiteLLM/ADK - Issue #118
181
+ # Upstream uses Pydantic v1 patterns; remove when they migrate to v2
182
+ "ignore:.*PydanticDeprecatedSince20.*:DeprecationWarning",
183
+ "ignore:.*Pydantic.*serialization.*:UserWarning",
184
+ "ignore:.*Pydantic.*serializer.*:UserWarning",
185
+ "ignore::UserWarning:pydantic.*",
186
+ "ignore:.*Pydantic.*:UserWarning",
187
+ "ignore:^deprecated$:DeprecationWarning:pydantic.*", # Generic "deprecated" from pydantic internals
188
+ "ignore:^deprecated$:DeprecationWarning:google.adk.*", # Pydantic deprecated field in ADK RunConfig - Issue #125
189
+ #
190
+ # Google genai SDK aiohttp subclassing - Issue #118 (bundled with Pydantic/ADK issues)
191
+ # google.genai._api_client subclasses aiohttp.ClientSession which is deprecated
192
+ "ignore:Inheritance class.*from ClientSession is discouraged:DeprecationWarning",
193
+ #
194
+ # ADK experimental feature warnings - Issue #119
195
+ # We intentionally use experimental ADK features (ADR-014); these are informational
196
+ "ignore:.*adk.*\\[EXPERIMENTAL\\].*:UserWarning",
197
+ "ignore:.*adk.*experimental.*:UserWarning",
198
+ #
199
+ # LiteLLM async cleanup warnings - Issue #120
200
+ # Known upstream bugs: https://github.com/BerriAI/litellm/issues/8831, #14276
201
+ "ignore:coroutine.*was never awaited:RuntimeWarning",
202
+ #
203
+ # Async test cleanup warnings (unclosed sockets/event loops) - Issue #120
204
+ # Common with async tests using LiteLLM/ADK; not actionable in test code
205
+ "ignore::ResourceWarning",
206
+ "ignore::pytest.PytestUnraisableExceptionWarning",
207
+ #
208
+ # Misc third-party async cleanup warnings - Issue #120
209
+ "ignore:.*tracemalloc.*:UserWarning",
210
+ "ignore:enable_cleanup_closed.*:DeprecationWarning",
211
+ ]
@@ -0,0 +1,157 @@
1
+ """GEPA-ADK: Async-first evolution engine for agentic development.
2
+
3
+ This package provides domain models and utilities for evolving agent
4
+ instructions using the GEPA (Generalized Evolutionary Prompt-programming
5
+ Architecture) approach.
6
+
7
+ Attributes:
8
+ __version__ (str): Package version from pyproject.toml.
9
+ EvolutionConfig (class): Configuration parameters for evolution runs.
10
+ EvolutionResult (class): Outcome of a completed evolution run.
11
+ Candidate (class): Instruction candidate being evolved.
12
+ IterationRecord (class): Metrics for a single evolution iteration.
13
+ Score (type): Type alias for normalized scores.
14
+ ComponentName (type): Type alias for component identifiers.
15
+ ModelName (type): Type alias for model identifiers.
16
+ TrajectoryConfig (class): Configuration for trajectory extraction.
17
+ EvolutionError (class): Base exception for all gepa-adk errors.
18
+ ConfigurationError (class): Raised when configuration validation fails.
19
+ AsyncGEPAAdapter (protocol): Async adapter protocol for evaluation.
20
+ EvaluationBatch (class): Evaluation results container for adapters.
21
+ DataInst (type): Type variable for adapter input instances.
22
+ Trajectory (type): Type variable for adapter traces.
23
+ RolloutOutput (type): Type variable for adapter outputs.
24
+
25
+ Examples:
26
+ Basic usage with configuration and candidates:
27
+
28
+ ```python
29
+ from gepa_adk import EvolutionConfig, Candidate
30
+
31
+ config = EvolutionConfig(max_iterations=10, patience=3)
32
+ candidate = Candidate(components={"instruction": "Be helpful"})
33
+ ```
34
+
35
+ Configuring trajectory extraction:
36
+
37
+ ```python
38
+ from gepa_adk import TrajectoryConfig
39
+
40
+ trajectory_config = TrajectoryConfig(
41
+ redact_sensitive=True,
42
+ max_string_length=5000,
43
+ )
44
+ ```
45
+
46
+ See Also:
47
+ - [`gepa_adk.domain`][gepa_adk.domain]: Core domain layer with models and types.
48
+ - [`gepa_adk.domain.models`][gepa_adk.domain.models]: Detailed model implementations.
49
+ - [`gepa_adk.domain.exceptions`][gepa_adk.domain.exceptions]: Exception hierarchy.
50
+
51
+ Note:
52
+ This is the main entry point for the gepa-adk package. Domain models
53
+ are re-exported here for convenient top-level access.
54
+ """
55
+
56
+ # Suppress Pydantic serializer warnings from ADK/LiteLLM dependencies
57
+ # These are upstream issues (GH #81) and don't affect functionality
58
+ import warnings
59
+
60
+ warnings.filterwarnings(
61
+ "ignore",
62
+ message=".*Pydantic.*serializer.*",
63
+ category=UserWarning,
64
+ )
65
+ warnings.filterwarnings(
66
+ "ignore",
67
+ message=".*Pydantic.*serialization.*",
68
+ category=UserWarning,
69
+ )
70
+
71
+ # Version is read from installed package metadata
72
+ try:
73
+ from importlib.metadata import version as _get_version
74
+
75
+ __version__ = _get_version("gepa-adk")
76
+ except Exception:
77
+ # Fallback for development environments where package isn't installed
78
+ __version__ = "0.0.0.dev"
79
+
80
+ from gepa_adk.adapters.component_selector import ( # noqa: E402
81
+ AllComponentSelector,
82
+ RoundRobinComponentSelector,
83
+ create_component_selector,
84
+ )
85
+ from gepa_adk.api import ( # noqa: E402
86
+ evolve,
87
+ evolve_group,
88
+ evolve_sync,
89
+ evolve_workflow,
90
+ )
91
+ from gepa_adk.domain import ( # noqa: E402
92
+ Candidate,
93
+ ComponentName,
94
+ ConfigurationError,
95
+ EvolutionConfig,
96
+ EvolutionError,
97
+ EvolutionResult,
98
+ FrontierType,
99
+ IterationRecord,
100
+ ModelName,
101
+ MultiAgentEvolutionResult,
102
+ Score,
103
+ TrajectoryConfig,
104
+ )
105
+ from gepa_adk.engine import AsyncGEPAEngine, MergeProposer # noqa: E402
106
+ from gepa_adk.ports import ( # noqa: E402
107
+ AsyncGEPAAdapter,
108
+ DataInst,
109
+ EvaluationBatch,
110
+ RolloutOutput,
111
+ Trajectory,
112
+ )
113
+ from gepa_adk.ports.selector import ComponentSelectorProtocol # noqa: E402
114
+
115
+ __all__ = [
116
+ # Version
117
+ "__version__",
118
+ # Models
119
+ "EvolutionConfig",
120
+ "EvolutionResult",
121
+ "MultiAgentEvolutionResult",
122
+ "Candidate",
123
+ "IterationRecord",
124
+ # Types
125
+ "Score",
126
+ "ComponentName",
127
+ "ModelName",
128
+ "FrontierType",
129
+ "TrajectoryConfig",
130
+ # Exceptions
131
+ "EvolutionError",
132
+ "ConfigurationError",
133
+ # Engine
134
+ "AsyncGEPAEngine",
135
+ "MergeProposer",
136
+ # Ports
137
+ "AsyncGEPAAdapter",
138
+ "EvaluationBatch",
139
+ "DataInst",
140
+ "Trajectory",
141
+ "RolloutOutput",
142
+ # Selectors
143
+ "ComponentSelectorProtocol",
144
+ "RoundRobinComponentSelector",
145
+ "AllComponentSelector",
146
+ "create_component_selector",
147
+ # API
148
+ "evolve",
149
+ "evolve_sync",
150
+ "evolve_group",
151
+ "evolve_workflow",
152
+ ]
153
+
154
+
155
+ def main() -> None:
156
+ """Entry point for CLI invocation."""
157
+ print("Hello from gepa-adk!")