pub enum ReplayStrategy {
Fifo,
ByToolName,
Exact,
}Expand description
回放策略:决定并发/乱序场景下一条请求取哪条录播。
Variants§
Fifo
并发 FIFO:按录制顺序弹出,原子 pop 无 UB,但“哪条请求拿到哪条响应“不确定。
适合串行/顺序稳定的链;并行场景配顺序无关断言(只断言回放全部耗尽、 各响应结构非空),不断言“第 N 条是工具 A 的响应“。
ByToolName
按工具名路由:绑定工具时携带名字(bind_tools),回放时从队列里挑
工具名匹配的第一条录播(请求侧 exchange.tools 或响应侧 tool_calls)。
覆盖“不同工具响应不同、需要精确对应“的并行场景——每个并行分支各绑 各的工具,拿到各自正确的响应。比“整段消息签名匹配“弱但可复现。
Exact
按请求消息完整签名精确匹配:请求 messages 与录播 exchange.messages
逐条完全相等(Message 的 PartialEq 全字段,含 content /
message_type / name / additional_kwargs / tool_calls 等)才命中。
并行乱序下每个请求精确取到自己的响应;录播中无匹配 → 返回明确
TestkitError::ReplayNoMatch,不做静默 FIFO 兜底(避免“拿错响应“
伪装成成功)。适合“同一消息序列必定复现同一响应“的确定性重放——录播
与请求在任意字段上不一致(如运行时给 id 赋了每次不同的值)都会视为
不匹配,fixture 需保证这些字段稳定。
Trait Implementations§
Source§impl Clone for ReplayStrategy
impl Clone for ReplayStrategy
Source§fn clone(&self) -> ReplayStrategy
fn clone(&self) -> ReplayStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ReplayStrategy
Source§impl Debug for ReplayStrategy
impl Debug for ReplayStrategy
Source§impl Default for ReplayStrategy
impl Default for ReplayStrategy
Source§fn default() -> ReplayStrategy
fn default() -> ReplayStrategy
Returns the “default value” for a type. Read more
impl Eq for ReplayStrategy
Source§impl PartialEq for ReplayStrategy
impl PartialEq for ReplayStrategy
impl StructuralPartialEq for ReplayStrategy
Auto Trait Implementations§
impl Freeze for ReplayStrategy
impl RefUnwindSafe for ReplayStrategy
impl Send for ReplayStrategy
impl Sync for ReplayStrategy
impl Unpin for ReplayStrategy
impl UnsafeUnpin for ReplayStrategy
impl UnwindSafe for ReplayStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.