feat: comprehensive agent-readable state export in run_dir#333
Open
LakshyAAAgrawal wants to merge 6 commits into
Open
feat: comprehensive agent-readable state export in run_dir#333LakshyAAAgrawal wants to merge 6 commits into
LakshyAAAgrawal wants to merge 6 commits into
Conversation
When run_dir is provided, save() now writes `gepa_state.json` alongside the existing pickle and JSON files. This single file gives autonomous agents (e.g. Claude Code) the full optimization picture: - All candidates with their texts, parent lineage, and metric call cost - Per-candidate per-datapoint scores (prog_candidate_val_subscores) - Per-candidate multi-objective scores - Pareto frontier details (instance, objective, hybrid, cartesian) - Derived analytics: best candidate, hardest examples, frontier members - Full iteration log including evaluation side_info/trajectories Also capture proposal evaluation data (eval_before, eval_after with scores, outputs, and trajectories/side_info) into the iteration trace, so agents can see WHY proposals were accepted or rejected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Changed Files
|
- Serialize evaluation cache to gepa_state.json: per-candidate per-datapoint entries with score, output, and objective_scores (keyed by candidate idx and data id) - Add rejected_proposals section: each rejected proposal includes candidate text, parent ids, subsample data ids, before/after scores, and full eval_before/eval_after with trajectories/side_info - Move try_json_serialize to gepa_utils for shared use between engine and state export - Bump schema_version to 2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shangyint
reviewed
Apr 17, 2026
Shangyint
left a comment
Collaborator
There was a problem hiding this comment.
A note to ourselves: currently, the gepa_state JSON will be quite large, which is not agent-friendly. We can possibly build a directory that represents the same information but in different files.
Replaces the monolithic gepa_state.json export with a directory layout (candidates/, pareto/, iterations/, rejected_proposals/, eval_cache/) so agents can navigate run state without loading multi-MB blobs. Gated behind EngineConfig.write_agent_state / gepa.optimize(write_agent_state=), default off — when off, run_log.json / full_program_trace also stay lean (no per-iteration eval payloads or proposed_candidate copies). gepa_state.bin remains the single source of truth for resume; the tree is output-only.
… state When write_agent_state is enabled, valset evaluation now bypasses the eval cache and calls the adapter with capture_traces=True so trajectories come through. Each accepted candidate's outputs and trajectories are written to candidates/<idx>/outputs/<val_id>.json and candidates/<idx>/trajectories/<val_id>.json, covering both the seed and every reflective/merge acceptance. Drops the eval_cache/ export from the agent directory — the in-memory cache was not round-tripping trajectories and adds little over the other per-candidate files. Adds ValsetEvaluation.trajectories_by_val_id as the optional handoff channel from eval path to writer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
run_diris provided, GEPA now writesgepa_state.json— a comprehensive, agent-readable export of the full optimization state. This is designed for consumption by autonomous agents (e.g. Claude Code) that need the complete picture to propose better candidates.What's in
gepa_state.jsonSide-info capture
Proposal evaluation data (
eval_before,eval_after) is now recorded in the iteration trace with:This gives agents the feedback needed to understand WHY proposals succeeded or failed.
What's still missing (future work)
capture_traces=Falsefor performance, so only scores are available per-candidate per-datapoint, not outputs or side_infoprogram_candidates; rejected proposals are now in the iteration log but weren't beforeEvaluationCacheis in the pickle but not JSON-exportedTest plan
🤖 Generated with Claude Code