You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 1, 2026. It is now read-only.
llm_step(...) currently supports a parser, but Coevolved doesn’t have a first-class pattern for structured output validation + automatic repair/retry when parsing/validation fails.
We want an “Instructor-style” workflow: attempt to parse/validate, and if it fails, turn the failure into additional context/prompting and retry the LLM call (bounded by attempts).
Reference: Instructor project (for ideas on UX/patterns): https://github.com/instructor-ai/instructor
Goals
Add more sophisticated validation for LLM steps (Pydantic-first), with an extensible “repair” hook.
Keep core API surface clean: the retry/repair logic should live in a dedicated class under coevolved/core/.
Provide prebuilt helpers under coevolved/prebuilt/:
llm_retry(...): wraps an LLM step with validate→repair→retry behavior.
agent_retry(...): a higher-level retry step for agent workflows (either retry a planner step or a whole agent callable).
Proposed design (core)
Add a new class under coevolved/src/coevolved/core/ (name TBD; suggestions below):
LLMRepairPolicy
ValidatedLLMStep
LLMValidationRepair
It should accept a custom function that transforms failure output into new input for the next attempt:
Background
llm_step(...)currently supports aparser, but Coevolved doesn’t have a first-class pattern for structured output validation + automatic repair/retry when parsing/validation fails.We want an “Instructor-style” workflow: attempt to parse/validate, and if it fails, turn the failure into additional context/prompting and retry the LLM call (bounded by attempts).
Reference: Instructor project (for ideas on UX/patterns):
https://github.com/instructor-ai/instructorGoals
coevolved/core/.coevolved/prebuilt/:llm_retry(...): wraps an LLM step with validate→repair→retry behavior.agent_retry(...): a higher-level retry step for agent workflows (either retry a planner step or a whole agent callable).Proposed design (core)
Add a new class under
coevolved/src/coevolved/core/(name TBD; suggestions below):LLMRepairPolicyValidatedLLMStepLLMValidationRepairIt should accept a custom function that transforms failure output into new input for the next attempt:
failure_to_input(failure, *, state, prompt_payload, response, attempt) -> (new_state | new_prompt_payload | prompt_delta)Where “failure” is typically:
pydantic.ValidationError(schema mismatch)Also include:
max_attempts: intValidationError+ parsing errors)Proposed design (prebuilt)
Under
coevolved/src/coevolved/prebuilt/:llm_retry.pyllm_retry(step: Step, *, repair_policy: ..., max_attempts: int = ..., ...) -> Stepllm_step(...)but adds validation/repair hooks.agent_retry.py(orllm_retry.pywith both exports)should_retry(exc, state, attempt) -> boolScope / Tasks
coevolved/core/implementing:failure_to_input(...), update input, retryannotationsor add a dedicated event; keep this lightweight).llm_retry(...)agent_retry(...)Acceptance criteria
coevolved/core/that:failure_to_inputfunctionmax_attemptsllm_retry(...)andagent_retry(...)exist undercoevolved/prebuilt/and have docstrings + basic examples.Notes / Decisions needed
instructoras an optional dependency vs. implementing the pattern ourselves without additional deps.attemptmetadata.