Skip to content

Added feature to enable GEPA to see the full program trajectory, instead of just seeing the target predictor#15

Open
mango-panther wants to merge 2 commits into
swe-productivity:mainfrom
mango-panther:enable_full_trajectory_gepa
Open

Added feature to enable GEPA to see the full program trajectory, instead of just seeing the target predictor#15
mango-panther wants to merge 2 commits into
swe-productivity:mainfrom
mango-panther:enable_full_trajectory_gepa

Conversation

@mango-panther
Copy link
Copy Markdown

@mango-panther mango-panther commented Feb 2, 2026

This PR is related to feature implementation mentioned in #11
Implementation Details:

  • Changed trace_for_pred in feedback_fn_creator to pass the complete captured_trace instead of creating a single-element list
  • Updated documentation to reflect the new behavior and added example usage
  • Added tests to verify full trajectory access and backward compatibility
  • Fully backward compatible - existing metrics continue to work unchanged

@mango-panther mango-panther force-pushed the enable_full_trajectory_gepa branch from 9af967b to c7dfefd Compare February 2, 2026 18:47
@mango-panther
Copy link
Copy Markdown
Author

@TomeHirata Could you also review this one when you get time

Comment thread dspy/teleprompt/gepa/gepa.py Outdated
Comment thread dspy/teleprompt/gepa/gepa.py Outdated
Comment thread dspy/teleprompt/gepa/gepa.py Outdated
trace_for_pred = [(predictor, predictor_inputs, predictor_output)]
# Pass the full captured trace to enable trajectory-aware metrics
# For backward compatibility, metrics that only use pred_trace[-1] still work
trace_for_pred = captured_trace if captured_trace else [(predictor, predictor_inputs, predictor_output)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the intention of this change? metric_fn will receive duplicated information for captured_trace and trace_for_pred, which is not the intended behavior of gepa optimizer

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a change here. Now, it will search captured_trace to find the entry matching the current predictor call (using object identity of predictor_inputs and predictor_output) and then slices trace to include only entries up to and including that match. But, in case its not working then it will fallback to captured_trace. I am not sure what to do in case of fallback.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if that change is necessary. We can have the same logic in metric function if needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell then hoe excatly I should incorporate them? I am not getting how to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants