summaryrefslogtreecommitdiff
path: root/libpanto/src/agent.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-12 10:38:28 -0600
committert <t@tjp.lol>2026-06-12 11:06:18 -0600
commit7343898524f9f692620f4cb276f56cfde30f6269 (patch)
tree8cf0621d33c4ae7f292c95f4684e1e9590175ae8 /libpanto/src/agent.zig
parentaf8ba87475bfae9c1b4fa70c88fb4c59630a5670 (diff)
fuzzy selectors for models and reasoning levels
Diffstat (limited to 'libpanto/src/agent.zig')
-rw-r--r--libpanto/src/agent.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/libpanto/src/agent.zig b/libpanto/src/agent.zig
index 0252af6..24bc2cf 100644
--- a/libpanto/src/agent.zig
+++ b/libpanto/src/agent.zig
@@ -1162,6 +1162,25 @@ pub const Stream = struct {
};
}
+ /// Reset a `.failed` stream back to `.turn_start` so the caller can resume
+ /// `next()` after changing the agent config (e.g. an embedder that catches
+ /// a terminal `ProviderBadRequest`, rewrites the provider config, and
+ /// wants to retry the SAME turn without re-appending the user message).
+ ///
+ /// Safe only at the OPEN boundary: a failed open never mutates the
+ /// conversation, so the already-committed user prompt at `_start` stays
+ /// intact and the re-open re-reads the (now-swapped) config snapshot.
+ /// Returns `error.StreamNotFailed` if the stream is not in `.failed`.
+ pub fn reopen(self: *Stream) !void {
+ if (self.state != .failed) return error.StreamNotFailed;
+ if (self._response) |ps| {
+ ps.deinit();
+ self._response = null;
+ }
+ self._pending_error = null;
+ self.state = .turn_start;
+ }
+
/// Pull the next event, or null past the terminal. See the contract
/// above.
pub fn next(self: *Stream) !?Event {