Exceptions
exceptions ¶
Exception hierarchy for gepa-adk.
This module defines the exception hierarchy following ADR-009 guidelines. All gepa-adk specific exceptions inherit from EvolutionError.
| ATTRIBUTE | DESCRIPTION |
|---|---|
EvolutionError | Base exception for all gepa-adk errors. TYPE: |
ConfigurationError | Raised when configuration validation fails. TYPE: |
EmptyProposalError | Raised when reflection returns an empty proposal after one retry; the engine records a skipped iteration. TYPE: |
ReflectionTimeoutError | Raised when the reflection agent exceeds its timeout; the engine records a skipped iteration. TYPE: |
IncompleteProposalError | Raised when the reflection output was cut off at the output-token limit or opens a reasoning tag it never closes; the engine records a skipped iteration. TYPE: |
ReflectionError | Raised when the reflection function raises; the engine skips the iteration when the error is retryable and aborts otherwise. TYPE: |
AdapterError | Raised when an adapter operation fails. TYPE: |
ConfigValidationError | Raised when config validation fails. TYPE: |
CriticOutputParseError | Raised when critic agent output cannot be parsed as valid JSON. TYPE: |
EvaluationError | Raised when batch evaluation fails. TYPE: |
InvalidScoreListError | Raised when score list is empty or contains non-finite values. TYPE: |
MissingScoreFieldError | Raised when score field is missing or null in parsed output. TYPE: |
MultiAgentValidationError | Raised when multi-agent configuration validation fails. TYPE: |
NoCandidateAvailableError | Raised when no candidates are available for selection. TYPE: |
OutputParseError | Raised when agent output cannot be parsed as valid JSON. TYPE: |
RestoreError | Raised when agent restoration fails after evaluation. TYPE: |
SchemaValidationError | Raised when output fails Pydantic schema validation. TYPE: |
ScoringError | Base exception for all scoring-related errors. TYPE: |
VideoValidationError | Raised when video file validation fails. TYPE: |
WorkflowEvolutionError | Raised when workflow evolution fails. TYPE: |
Examples:
Handling configuration errors:
from gepa_adk.domain.exceptions import ConfigurationError
try:
raise ConfigurationError(
"Invalid value", field="max_iterations", value=-1, constraint=">= 0"
)
except ConfigurationError as e:
print(f"Field: {e.field}, Value: {e.value}")
# Output: Field: max_iterations, Value: -1
Notes
The exception hierarchy provides structured error handling with contextual information for debugging and error recovery.
See Also
gepa_adk.domain.models: Domain models that raise these exceptions during validation.gepa_adk.ports.adapter: Adapter protocol whose implementations raise EvaluationError and AdapterError.
EvolutionError ¶
Bases: Exception
flowchart TD
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Base exception for all gepa-adk errors.
All custom exceptions in gepa-adk should inherit from this class to allow for unified exception handling.
| ATTRIBUTE | DESCRIPTION |
|---|---|
partial_result | Partial result the engine attaches when it aborts a run after the baseline was scored, built with TYPE: |
Examples:
Catching evolution errors:
from gepa_adk.domain.exceptions import EvolutionError
try:
raise EvolutionError("Evolution failed unexpectedly")
except EvolutionError as e:
print(f"Caught: {e}")
# Output: Caught: Evolution failed unexpectedly
Notes
Always use this base class or its subclasses for domain errors. Standard Python exceptions should still be raised for programming errors (e.g., TypeError, ValueError for developer mistakes).
Source code in src/gepa_adk/domain/exceptions.py
ConfigurationError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.ConfigurationError[ConfigurationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ConfigurationError
click gepa_adk.domain.exceptions.ConfigurationError href "" "gepa_adk.domain.exceptions.ConfigurationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when configuration validation fails.
This exception is raised during EvolutionConfig initialization when a parameter violates its validation constraints.
| ATTRIBUTE | DESCRIPTION |
|---|---|
field | The name of the configuration field that failed validation. TYPE: |
value | The invalid value that was provided. TYPE: |
constraint | Description of the validation constraint that was violated. TYPE: |
Examples:
Creating a configuration error with context:
from gepa_adk.domain.exceptions import ConfigurationError
error = ConfigurationError(
"max_iterations must be non-negative",
field="max_iterations",
value=-5,
constraint=">= 0",
)
print(error.field, error.value, error.constraint)
# Output: max_iterations -5 >= 0
Notes
Arises from user-provided invalid settings, not programming errors. Should be caught and reported with clear guidance on valid values.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
__init__(
message: str,
*,
field: str | None = None,
value: object = None,
constraint: str | None = None,
) -> None
Initialize ConfigurationError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
field | Name of the invalid configuration field. TYPE: |
value | The invalid value provided. TYPE: |
constraint | Description of the validation constraint. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string representation with context.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted error message including field and value context. |
Notes
Outputs formatted error message with field and value context when available, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
NoCandidateAvailableError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.NoCandidateAvailableError[NoCandidateAvailableError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.NoCandidateAvailableError
click gepa_adk.domain.exceptions.NoCandidateAvailableError href "" "gepa_adk.domain.exceptions.NoCandidateAvailableError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when no candidates are available for selection.
| ATTRIBUTE | DESCRIPTION |
|---|---|
cause | Original exception that caused this error. TYPE: |
context | Extra context (candidate_idx, frontier_type). TYPE: |
Examples:
Notes
Arises when candidate selector cannot find any valid candidates from the Pareto frontier, typically due to empty frontier or filtering constraints.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize NoCandidateAvailableError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
cause | Original exception that caused this error. TYPE: |
**context | Arbitrary key-value pairs stored as exception attributes for debugging context. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with context and cause details.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted error message including context and cause information. |
Notes
Outputs formatted error message with context dict and cause chain when available, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
EmptyProposalError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.EmptyProposalError[EmptyProposalError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.EmptyProposalError
click gepa_adk.domain.exceptions.EmptyProposalError href "" "gepa_adk.domain.exceptions.EmptyProposalError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when reflection returns an empty proposal after one retry.
The engine treats this error as a failed iteration rather than a fatal one: it records the iteration as skipped and continues the loop.
| ATTRIBUTE | DESCRIPTION |
|---|---|
component | Name of the component the reflection was proposing text for. TYPE: |
Examples:
Notes
Raised by the mutation proposer after the reflection function has returned an empty or whitespace-only string twice in a row.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize EmptyProposalError with the component name.
| PARAMETER | DESCRIPTION |
|---|---|
component | Name of the component whose reflection was empty. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
ReflectionTimeoutError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.ReflectionTimeoutError[ReflectionTimeoutError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ReflectionTimeoutError
click gepa_adk.domain.exceptions.ReflectionTimeoutError href "" "gepa_adk.domain.exceptions.ReflectionTimeoutError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when the reflection agent exceeds its timeout.
The engine treats this error as a skipped iteration rather than a fatal one: it records the iteration with skip_reason="reflection_timeout", counts it toward patience and continues the loop. The proposer does not retry a timed-out reflection.
| ATTRIBUTE | DESCRIPTION |
|---|---|
component | Name of the component the reflection was proposing text for. TYPE: |
timeout_seconds | Timeout the reflection ran under, or TYPE: |
Examples:
Notes
Raised by the ADK reflection function when the executor returns ExecutionStatus.TIMEOUT, as distinct from a failed run or an empty response.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize ReflectionTimeoutError with the component and timeout.
| PARAMETER | DESCRIPTION |
|---|---|
component | Name of the component whose reflection timed out. TYPE: |
timeout_seconds | Timeout the reflection ran under, or TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
IncompleteProposalError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.IncompleteProposalError[IncompleteProposalError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.IncompleteProposalError
click gepa_adk.domain.exceptions.IncompleteProposalError href "" "gepa_adk.domain.exceptions.IncompleteProposalError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when the reflection output is incomplete.
A proposal is incomplete when the last model response behind it reports a length stop (the output-token limit), or when its text opens a reasoning tag such as <think> that it never closes. The engine treats this error as a skipped iteration: it records the iteration with skip_reason="incomplete_proposal", keeps the raw text as the record's component_text, counts it toward patience and continues the loop without evaluating. The proposer does not retry it.
| ATTRIBUTE | DESCRIPTION |
|---|---|
component | Name of the component the reflection was proposing text for. TYPE: |
finish_reason | Why the proposal is incomplete: the finish reason name (for example TYPE: |
raw_text | The incomplete text the reflection produced. TYPE: |
output_length | Length of TYPE: |
Examples:
raise IncompleteProposalError(
"instruction", finish_reason="MAX_TOKENS", raw_text="Be concise and"
)
Notes
Raised by the ADK reflection function after a successful execution, before the empty-response handling, so a length stop with no text is still reported as incomplete.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize IncompleteProposalError with the incomplete output.
| PARAMETER | DESCRIPTION |
|---|---|
component | Name of the component whose proposal is incomplete. TYPE: |
finish_reason | Finish reason name or TYPE: |
raw_text | The incomplete text the reflection produced. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
ReflectionError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.ReflectionError[ReflectionError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ReflectionError
click gepa_adk.domain.exceptions.ReflectionError href "" "gepa_adk.domain.exceptions.ReflectionError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when the reflection function raises an unexpected exception.
The proposer wraps any non-EvolutionError exception from the reflection function in this error and classifies it. A retryable error (quota, availability or connection failure) is retried once; when the retry fails too, the engine records the iteration with skip_reason="reflection_error", counts it toward patience and continues the loop. A non-retryable error aborts the run.
| ATTRIBUTE | DESCRIPTION |
|---|---|
component | Name of the component the reflection was proposing text for. TYPE: |
cause | The exception the reflection function raised on the last attempt. TYPE: |
retryable | Whether the cause is a transient provider failure. TYPE: |
attempts | Number of reflection calls made before giving up. TYPE: |
Examples:
raise ReflectionError(
"instruction",
cause=RuntimeError("503 UNAVAILABLE"),
retryable=True,
attempts=2,
)
Notes
Raised by the mutation proposer. ReflectionTimeoutError and other EvolutionError subclasses from the reflection function pass through unwrapped.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize ReflectionError with the component and its cause.
| PARAMETER | DESCRIPTION |
|---|---|
component | Name of the component whose reflection failed. TYPE: |
cause | The exception the reflection function raised. TYPE: |
retryable | Whether the cause is a transient provider failure. TYPE: |
attempts | Number of reflection calls made before giving up. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
EvaluationError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.EvaluationError[EvaluationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.EvaluationError
click gepa_adk.domain.exceptions.EvaluationError href "" "gepa_adk.domain.exceptions.EvaluationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when batch evaluation fails.
This exception indicates failures during agent evaluation, such as agent execution errors, timeout, or malformed output.
| ATTRIBUTE | DESCRIPTION |
|---|---|
cause | Original exception that caused this error. TYPE: |
context | Additional context for debugging. TYPE: |
Examples:
Wrapping an ADK error:
from gepa_adk.domain.exceptions import EvaluationError
try:
result = await runner.run_async(...)
except ADKError as e:
raise EvaluationError(
"Agent execution failed",
cause=e,
agent_name="my_agent",
) from e
Notes
Always preserves the original cause for debugging while providing a consistent interface for error handling.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize EvaluationError with cause and context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
cause | Original exception that caused this error. TYPE: |
**context | Arbitrary key-value pairs stored as exception attributes for debugging context. TYPE: |
Notes
Context is passed via keyword arguments. Positional arguments after message are not allowed.
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with cause chain if present.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message with context and cause information. |
Notes
Outputs formatted error message with context dict and cause chain when available, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
AdapterError ¶
Bases: EvaluationError
flowchart TD
gepa_adk.domain.exceptions.AdapterError[AdapterError]
gepa_adk.domain.exceptions.EvaluationError[EvaluationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvaluationError --> gepa_adk.domain.exceptions.AdapterError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.EvaluationError
click gepa_adk.domain.exceptions.AdapterError href "" "gepa_adk.domain.exceptions.AdapterError"
click gepa_adk.domain.exceptions.EvaluationError href "" "gepa_adk.domain.exceptions.EvaluationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when an adapter operation fails.
This exception is used by adapter implementations (e.g., ADKAdapter) for adapter-specific failures such as session errors or configuration issues.
Examples:
Raising an adapter error:
from gepa_adk.domain.exceptions import AdapterError
if not self._session_service:
raise AdapterError(
"Session service unavailable",
adapter="ADKAdapter",
operation="evaluate",
)
Notes
AdapterError is a subclass of EvaluationError, so callers can catch either for different granularity of error handling.
Source code in src/gepa_adk/domain/exceptions.py
RestoreError ¶
Bases: AdapterError
flowchart TD
gepa_adk.domain.exceptions.RestoreError[RestoreError]
gepa_adk.domain.exceptions.AdapterError[AdapterError]
gepa_adk.domain.exceptions.EvaluationError[EvaluationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.AdapterError --> gepa_adk.domain.exceptions.RestoreError
gepa_adk.domain.exceptions.EvaluationError --> gepa_adk.domain.exceptions.AdapterError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.EvaluationError
click gepa_adk.domain.exceptions.RestoreError href "" "gepa_adk.domain.exceptions.RestoreError"
click gepa_adk.domain.exceptions.AdapterError href "" "gepa_adk.domain.exceptions.AdapterError"
click gepa_adk.domain.exceptions.EvaluationError href "" "gepa_adk.domain.exceptions.EvaluationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when agent restoration fails after evaluation.
This exception is raised when one or more agent components fail to restore to their original state after candidate evaluation. Uses best-effort restoration: all components are attempted even if some fail, then errors are aggregated into this exception.
| ATTRIBUTE | DESCRIPTION |
|---|---|
errors | List of (qualified_name, exception) pairs for each failed restoration. TYPE: |
Examples:
Handling partial restore failures:
from gepa_adk.domain.exceptions import RestoreError
try:
adapter._restore_agents(originals)
except RestoreError as e:
for qualified_name, error in e.errors:
print(f"Failed to restore {qualified_name}: {error}")
Aggregating restoration failures:
errors = []
for name, original in originals.items():
try:
handler.restore(agent, original)
except Exception as exc:
errors.append((name, exc))
if errors:
raise RestoreError(
f"Failed to restore {len(errors)} components",
errors=errors,
)
Notes
As a subclass of AdapterError, this exception indicates that the agent state may be corrupted and manual intervention may be required to reset agents to a known state.
Source code in src/gepa_adk/domain/exceptions.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
__init__ ¶
__init__(
message: str,
*,
errors: list[tuple[str, Exception]],
cause: Exception | None = None,
) -> None
Initialize RestoreError with aggregated failures.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error summary. TYPE: |
errors | List of (qualified_name, exception) pairs for each failed restoration. Must be non-empty when raising this exception. TYPE: |
cause | Optional underlying cause exception. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with failed component names.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message including list of failed qualified names. |
Notes
Outputs formatted error message with list of failed qualified names, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
ScoringError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.ScoringError[ScoringError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ScoringError
click gepa_adk.domain.exceptions.ScoringError href "" "gepa_adk.domain.exceptions.ScoringError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Base exception for all scoring-related errors.
All scoring exceptions inherit from this class to allow for unified exception handling in scoring operations.
| ATTRIBUTE | DESCRIPTION |
|---|---|
cause | Original exception that caused this error. TYPE: |
Examples:
Catching scoring errors:
from gepa_adk.domain.exceptions import ScoringError
try:
score, metadata = await scorer.async_score(...)
except ScoringError as e:
print(f"Scoring failed: {e}")
Notes
All scoring exceptions inherit from this base class. ScoringError extends EvolutionError, following ADR-009 exception hierarchy guidelines.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize ScoringError with message and optional cause.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
cause | Original exception that caused this error. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with cause chain if present.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message with cause information. |
Notes
Outputs formatted error message with cause chain when available, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
CriticOutputParseError ¶
Bases: ScoringError
flowchart TD
gepa_adk.domain.exceptions.CriticOutputParseError[CriticOutputParseError]
gepa_adk.domain.exceptions.ScoringError[ScoringError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.ScoringError --> gepa_adk.domain.exceptions.CriticOutputParseError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ScoringError
click gepa_adk.domain.exceptions.CriticOutputParseError href "" "gepa_adk.domain.exceptions.CriticOutputParseError"
click gepa_adk.domain.exceptions.ScoringError href "" "gepa_adk.domain.exceptions.ScoringError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when critic agent output cannot be parsed as valid JSON.
This exception indicates that the critic agent returned output that could not be parsed as JSON or did not conform to the expected schema.
| ATTRIBUTE | DESCRIPTION |
|---|---|
raw_output | The unparseable output from critic. TYPE: |
parse_error | Description of parsing failure. TYPE: |
Examples:
Handling parse errors:
from gepa_adk.domain.exceptions import CriticOutputParseError
try:
score, metadata = await scorer.async_score(...)
except CriticOutputParseError as e:
print(f"Invalid JSON: {e.raw_output}")
print(f"Error: {e.parse_error}")
Notes
Arises when critic agent output cannot be parsed as valid JSON. Typically occurs when LLM output doesn't follow structured format despite output_schema being set.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
__init__(
message: str,
*,
raw_output: str,
parse_error: str,
cause: Exception | None = None,
) -> None
Initialize CriticOutputParseError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
raw_output | The unparseable output string from critic. TYPE: |
parse_error | Description of the parsing failure. TYPE: |
cause | Original exception that caused this error. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with parse error details.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message including parse error and raw output preview. |
Notes
Outputs formatted error message with parse error and raw output preview (the first 100 chars followed by ... when longer), preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
OutputParseError ¶
Bases: ScoringError
flowchart TD
gepa_adk.domain.exceptions.OutputParseError[OutputParseError]
gepa_adk.domain.exceptions.ScoringError[ScoringError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.ScoringError --> gepa_adk.domain.exceptions.OutputParseError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ScoringError
click gepa_adk.domain.exceptions.OutputParseError href "" "gepa_adk.domain.exceptions.OutputParseError"
click gepa_adk.domain.exceptions.ScoringError href "" "gepa_adk.domain.exceptions.ScoringError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when agent output cannot be parsed as valid JSON.
This exception indicates that the agent returned output that could not be parsed as JSON.
| ATTRIBUTE | DESCRIPTION |
|---|---|
raw_output | The unparseable output from agent. TYPE: |
parse_error | Description of parsing failure. TYPE: |
Examples:
Handling parse errors:
from gepa_adk.domain.exceptions import OutputParseError
try:
score, metadata = scorer.score(input_text, output)
except OutputParseError as e:
print(f"Invalid JSON: {e.raw_output[:50]}")
print(f"Error: {e.parse_error}")
Notes
Arises when agent output cannot be parsed as valid JSON. Typically occurs when LLM output doesn't follow structured format.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
__init__(
message: str,
*,
raw_output: str,
parse_error: str,
cause: Exception | None = None,
) -> None
Initialize OutputParseError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
raw_output | The unparseable output string from agent. TYPE: |
parse_error | Description of the parsing failure. TYPE: |
cause | Original exception that caused this error. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with parse error details.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message including parse error and raw output preview. |
Notes
Outputs formatted error message with parse error and raw output preview (the first 100 chars followed by ... when longer), preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
SchemaValidationError ¶
Bases: ScoringError
flowchart TD
gepa_adk.domain.exceptions.SchemaValidationError[SchemaValidationError]
gepa_adk.domain.exceptions.ScoringError[ScoringError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.ScoringError --> gepa_adk.domain.exceptions.SchemaValidationError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ScoringError
click gepa_adk.domain.exceptions.SchemaValidationError href "" "gepa_adk.domain.exceptions.SchemaValidationError"
click gepa_adk.domain.exceptions.ScoringError href "" "gepa_adk.domain.exceptions.ScoringError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when output fails Pydantic schema validation.
This exception indicates that the agent output was valid JSON but did not conform to the expected Pydantic schema. Also used for schema text validation during output schema evolution.
| ATTRIBUTE | DESCRIPTION |
|---|---|
raw_output | The output that failed validation. TYPE: |
validation_error | Description of validation failure. TYPE: |
line_number | Line number where error occurred (for syntax errors). TYPE: |
validation_stage | Stage where validation failed ("syntax", "structure", or "execution"). TYPE: |
Examples:
Handling schema validation errors:
from gepa_adk.domain.exceptions import SchemaValidationError
try:
score, metadata = scorer.score(input_text, output)
except SchemaValidationError as e:
print(f"Schema mismatch: {e.validation_error}")
if e.line_number:
print(f"Error at line {e.line_number}")
Notes
Arises when output is valid JSON but doesn't match the schema. Typically occurs when field types are wrong or required fields have invalid values. For schema evolution, also raised when proposed schema text is syntactically invalid or structurally incorrect (e.g., missing BaseModel inheritance).
Source code in src/gepa_adk/domain/exceptions.py
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 | |
__init__ ¶
__init__(
message: str,
*,
raw_output: str,
validation_error: str,
cause: Exception | None = None,
line_number: int | None = None,
validation_stage: str | None = None,
) -> None
Initialize SchemaValidationError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
raw_output | The output string that failed validation. TYPE: |
validation_error | Description of the validation failure. TYPE: |
cause | Original exception that caused this error. TYPE: |
line_number | Line number where error occurred (for syntax errors). TYPE: |
validation_stage | Stage where validation failed. One of: - "syntax": Python syntax error - "structure": Missing BaseModel, has imports/functions - "execution": Error during exec() TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with validation error details.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message with the validation error, the line number and |
str | validation stage when known, and a raw output preview. |
Notes
Outputs formatted error message with validation error and raw output preview (the first 100 chars followed by ... when longer), preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
MissingScoreFieldError ¶
Bases: ScoringError
flowchart TD
gepa_adk.domain.exceptions.MissingScoreFieldError[MissingScoreFieldError]
gepa_adk.domain.exceptions.ScoringError[ScoringError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.ScoringError --> gepa_adk.domain.exceptions.MissingScoreFieldError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ScoringError
click gepa_adk.domain.exceptions.MissingScoreFieldError href "" "gepa_adk.domain.exceptions.MissingScoreFieldError"
click gepa_adk.domain.exceptions.ScoringError href "" "gepa_adk.domain.exceptions.ScoringError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when score field is missing or null in parsed output.
This exception indicates that the output was successfully parsed and validated, but the required score field is missing or null.
| ATTRIBUTE | DESCRIPTION |
|---|---|
parsed_output | The parsed output without valid score. TYPE: |
available_fields | Fields that were present. TYPE: |
Examples:
Handling missing score field:
from gepa_adk.domain.exceptions import MissingScoreFieldError
try:
score, metadata = await scorer.async_score(...)
except MissingScoreFieldError as e:
print(f"Missing score. Available fields: {e.available_fields}")
Notes
Applies when parsed output lacks a valid score value. The parsed_output may contain other valid fields that will be preserved in metadata if score is found.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize MissingScoreFieldError with parsed output.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
parsed_output | The parsed dict without valid score field. TYPE: |
cause | Original exception that caused this error. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with available fields.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message including list of available fields. |
Notes
Outputs formatted error message with list of available fields from parsed output, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
VideoValidationError ¶
Bases: ConfigurationError
flowchart TD
gepa_adk.domain.exceptions.VideoValidationError[VideoValidationError]
gepa_adk.domain.exceptions.ConfigurationError[ConfigurationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.ConfigurationError --> gepa_adk.domain.exceptions.VideoValidationError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ConfigurationError
click gepa_adk.domain.exceptions.VideoValidationError href "" "gepa_adk.domain.exceptions.VideoValidationError"
click gepa_adk.domain.exceptions.ConfigurationError href "" "gepa_adk.domain.exceptions.ConfigurationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when video file validation fails.
This exception is raised during video file processing when a video file does not exist, exceeds size limits, or has an invalid MIME type.
| ATTRIBUTE | DESCRIPTION |
|---|---|
video_path | The path to the video file that failed validation. TYPE: |
field | The configuration field name (default "video"). TYPE: |
constraint | Description of the validation constraint that was violated. TYPE: |
Examples:
Raising a video validation error:
from gepa_adk.domain.exceptions import VideoValidationError
raise VideoValidationError(
"Video file not found",
video_path="/path/to/missing.mp4",
constraint="file must exist",
)
Handling video validation errors:
from gepa_adk.domain.exceptions import VideoValidationError
try:
await video_service.prepare_video_parts(["/bad/path.mp4"])
except VideoValidationError as e:
print(f"Invalid video: {e.video_path}")
print(f"Constraint violated: {e.constraint}")
Notes
Arises from video file validation failures during multimodal input processing. File existence, size limits (2GB), and MIME type (video/*) are validated before loading video content.
Source code in src/gepa_adk/domain/exceptions.py
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | |
__init__ ¶
Initialize VideoValidationError with video file context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
video_path | The path to the video file that failed validation. TYPE: |
field | Name of the configuration field (default "video"). TYPE: |
constraint | Description of the validation constraint violated. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string representation with video path context.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted error message including video_path and constraint. |
Notes
Outputs formatted error message with video_path for easy identification of the problematic file in error logs.
Source code in src/gepa_adk/domain/exceptions.py
MultiAgentValidationError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.MultiAgentValidationError[MultiAgentValidationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.MultiAgentValidationError
click gepa_adk.domain.exceptions.MultiAgentValidationError href "" "gepa_adk.domain.exceptions.MultiAgentValidationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when multi-agent configuration validation fails.
This exception is raised during MultiAgentAdapter initialization when a parameter violates its validation constraints.
| ATTRIBUTE | DESCRIPTION |
|---|---|
field | The name of the configuration field that failed validation. TYPE: |
value | The invalid value that was provided. TYPE: |
constraint | Description of the validation constraint that was violated. TYPE: |
Examples:
Creating a multi-agent validation error:
from gepa_adk.domain.exceptions import MultiAgentValidationError
error = MultiAgentValidationError(
"agents list cannot be empty",
field="agents",
value=[],
constraint="len >= 1",
)
print(error.field, error.value) # agents []
Notes
Arises from user-provided invalid multi-agent settings, not programming errors. Should be caught and reported with clear guidance on valid values.
Source code in src/gepa_adk/domain/exceptions.py
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 | |
__init__ ¶
Initialize MultiAgentValidationError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
field | Name of the invalid configuration field. TYPE: |
value | The invalid value provided. TYPE: |
constraint | Description of the validation constraint. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string representation with context.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted error message including field and value context. |
Notes
Outputs formatted error message with field, value, and constraint context when available, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
WorkflowEvolutionError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.WorkflowEvolutionError[WorkflowEvolutionError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.WorkflowEvolutionError
click gepa_adk.domain.exceptions.WorkflowEvolutionError href "" "gepa_adk.domain.exceptions.WorkflowEvolutionError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when workflow evolution fails.
This exception is raised during workflow evolution when the workflow structure is invalid or no evolvable agents are found.
| ATTRIBUTE | DESCRIPTION |
|---|---|
workflow_name | Name of the workflow that failed. TYPE: |
cause | Original exception that caused this error. TYPE: |
Examples:
Handling workflow evolution errors:
from gepa_adk.domain.exceptions import WorkflowEvolutionError
try:
result = await evolve_workflow(workflow=empty_workflow, trainset=trainset)
except WorkflowEvolutionError as e:
print(f"Workflow '{e.workflow_name}' failed: {e}")
Notes
Arises when workflow contains no LlmAgents or evolution fails during execution. Follows ADR-009 exception hierarchy.
Source code in src/gepa_adk/domain/exceptions.py
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 | |
__init__ ¶
__init__(
message: str,
*,
workflow_name: str | None = None,
cause: Exception | None = None,
) -> None
Initialize WorkflowEvolutionError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
workflow_name | Name of the workflow that failed. TYPE: |
cause | Original exception that caused this error. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with cause chain if present.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message with workflow name and cause information. |
Notes
Outputs formatted error message including workflow context when available. Preserves cause chain for debugging nested exceptions.
Source code in src/gepa_adk/domain/exceptions.py
ConfigValidationError ¶
Bases: EvolutionError
flowchart TD
gepa_adk.domain.exceptions.ConfigValidationError[ConfigValidationError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ConfigValidationError
click gepa_adk.domain.exceptions.ConfigValidationError href "" "gepa_adk.domain.exceptions.ConfigValidationError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when config validation fails.
This exception is raised during generate_content_config evolution when a proposed config contains invalid parameter values or malformed YAML.
| ATTRIBUTE | DESCRIPTION |
|---|---|
message | Human-readable error message. TYPE: |
errors | List of individual validation errors. TYPE: |
Examples:
Creating a config validation error:
from gepa_adk.domain.exceptions import ConfigValidationError
error = ConfigValidationError(
"Config validation failed",
errors=["temperature must be 0.0-2.0, got 3.0"],
)
print(error.errors) # ["temperature must be 0.0-2.0, got 3.0"]
Notes
Arises when proposed config values violate parameter constraints or when YAML parsing fails. Should be caught and logged as a warning, with the original config preserved.
Source code in src/gepa_adk/domain/exceptions.py
__init__ ¶
Initialize ConfigValidationError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
errors | List of individual validation errors. TYPE: |
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string representation with errors.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted error message including list of validation errors. |
Notes
Outputs formatted error message with validation errors list when available, preserving base message structure.
Source code in src/gepa_adk/domain/exceptions.py
InvalidScoreListError ¶
Bases: ScoringError
flowchart TD
gepa_adk.domain.exceptions.InvalidScoreListError[InvalidScoreListError]
gepa_adk.domain.exceptions.ScoringError[ScoringError]
gepa_adk.domain.exceptions.EvolutionError[EvolutionError]
gepa_adk.domain.exceptions.ScoringError --> gepa_adk.domain.exceptions.InvalidScoreListError
gepa_adk.domain.exceptions.EvolutionError --> gepa_adk.domain.exceptions.ScoringError
click gepa_adk.domain.exceptions.InvalidScoreListError href "" "gepa_adk.domain.exceptions.InvalidScoreListError"
click gepa_adk.domain.exceptions.ScoringError href "" "gepa_adk.domain.exceptions.ScoringError"
click gepa_adk.domain.exceptions.EvolutionError href "" "gepa_adk.domain.exceptions.EvolutionError"
Raised when score list is empty or contains non-finite values.
This exception is raised during acceptance score aggregation when the evaluation batch scores are empty or contain NaN/inf values that would invalidate acceptance decisions.
| ATTRIBUTE | DESCRIPTION |
|---|---|
scores | The invalid score list that caused the error. TYPE: |
reason | Description of why the scores are invalid ("empty" or "non-finite"). TYPE: |
Examples:
Handling invalid score lists:
from gepa_adk.domain.exceptions import InvalidScoreListError
try:
acceptance_score = aggregate_scores(scores)
except InvalidScoreListError as e:
print(f"Invalid scores: {e.reason}, scores: {e.scores}")
Notes
Arises when evaluation batch scores cannot be aggregated for acceptance. Empty batches or non-finite values would corrupt evolution decisions.
Source code in src/gepa_adk/domain/exceptions.py
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |
__init__ ¶
__init__(
message: str,
*,
scores: list[float],
reason: str,
cause: Exception | None = None,
) -> None
Initialize InvalidScoreListError with context.
| PARAMETER | DESCRIPTION |
|---|---|
message | Human-readable error description. TYPE: |
scores | The invalid score list. TYPE: |
reason | Why the scores are invalid ("empty" or "non-finite"). TYPE: |
cause | Original exception that caused this error. TYPE: |
Notes
Context fields use keyword-only syntax to ensure explicit labeling.
Source code in src/gepa_adk/domain/exceptions.py
__str__ ¶
Return string with score list and reason.
| RETURNS | DESCRIPTION |
|---|---|
str | Formatted message including reason and score list preview. |
Notes
Outputs formatted error message with reason and score list preview (the first 5 scores followed by ... when there are more), preserving base message structure.