Repository navigation
Conversation
stream() aborted on a failed requirement with no recourse. Accepting a SamplingStrategy lets it repair and retry a failed attempt up to loop_budget, mirroring non-streaming sampling. A mid-stream "fail" repairs via a new stream_repair(); a failing final validate() repairs via repair(). Per-attempt history is recorded on Streamer.attempts, and strategy=None is unchanged. Assisted-by: Claude Code Signed-off-by: Alex Bozarth <[email protected]>
Assisted-by: Claude Code Signed-off-by: Alex Bozarth <[email protected]>
…requirements Assisted-by: Claude Code Signed-off-by: Alex Bozarth <[email protected]>
planetf1
left a comment
There was a problem hiding this comment.
The main ones are the requirement merge, abandoned streams counting as sampling failures, and the repair() signature change. The rest are smaller.
jakelorocco
left a comment
There was a problem hiding this comment.
Agree with Nigel's comments as well.
| class ModelFriendlyRepairStrategy(RepairTemplateStrategy): | ||
| """RepairTemplateStrategy with model-friendly feedback formatting. | ||
|
|
||
| Extends RepairTemplateStrategy to use ModelFriendlyFeedbackFormatter for | ||
| converting validation failures into actionable repair guidance. This typically | ||
| improves LLM performance on repair tasks compared to generic validation reasons. |
There was a problem hiding this comment.
Should we also override .stream_repair for this one so that it uses the repair strategy for mid-stream repairs?
There was a problem hiding this comment.
I dug into this and the short answer is no, primarily because this strategy is designed to work a specific set of requirements that all don't implement stream_validate and thus would never trigger stream_repair. and if a user gave a separate requirement outside those defaults it safely falls back to the default RepairTemplateStrategy.stream_repair
Assisted-by: Claude Code Signed-off-by: Alex Bozarth <[email protected]>
|
I should have review feedback fixes pushed tomorrow morning along with responses inline, I've just run out of time today to wrap it up |
|
@planetf1 @jakelorocco I believe I have responded to all your feedback, either addressing it or pushing back with a response or question. If you could re-review please |
BREAKING CHANGE: SamplingStrategy.repair()'s past_results parameter widens from list[ComputedModelOutputThunk] to list[ComputedModelOutputThunk | None]. Custom repair() overrides typed against the narrower signature must widen to match. No built-in strategy is affected -- they read past_actions[-1] / past_val[-1], never past_results. Assisted-by: Claude Code Signed-off-by: Alex Bozarth <[email protected]>
|
@jakelorocco do you want to take another look before I merge this? you haven't responded since I addressed your feedback |
242de10
Issue
Fixes #403
Description
stream()previously aborted on a failed requirement with no recourse. This adds the retry/repair behavior of non-streaming sampling to streaming by accepting aSamplingStrategy: a failed attempt is repaired and retried up toloop_budget, and the winning attempt is projected onto theStreamer's terminal state (full_text,mot,final_validations). Requirements set on the strategy are merged with those passed tostream(). Withstrategy=None, behavior is unchanged.Two triggers drive a retry:
"fail"cancels the attempt at the failing chunk and repairs via the newstream_repair();validate()fails repairs via the existingrepair().Per-attempt history is recorded on
Streamer.attempts(a newStreamAttemptdataclass), and aRetryEventis emitted before each re-attempt.CompletedEventgainsattempts_used.stream_repair()is a non-abstract method onBaseSamplingStrategythat raisesNotImplementedErrorby default (custom strategies stay instantiable; streaming repair is opt-in);RejectionSamplingStrategy,RepairTemplateStrategy, andMultiTurnStrategyimplement it.repair()/stream_repair()past_resultsis widened toSequence[ComputedModelOutputThunk | None]so streaming can pass its per-attempt results (Nonefor early-broken attempts) without narrowing existing callers.Testing
Attribution
Adding a new component, requirement, sampling strategy, or tool?
If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.
NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.