1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Run and step identifiers used by the engine to correlate
//! [`crate::StreamChunk`]s and [`crate::ChatMiddleware`] hooks.
use fmt;
use Uuid;
/// Unique identifier for a single run of the engine.
///
/// Carried on every [`crate::StreamChunk`] variant the engine emits and on
/// every [`crate::ChatMiddleware`] hook so observability code can correlate
/// events across concurrent runs. The engine mints a fresh
/// [`Uuid::new_v4`] when [`crate::RunConfig::run_id`] is `None`; callers
/// pass an existing `RunId` when an outer system already has its own
/// trace identifier to bind to.
;
/// Unique identifier for one provider turn (one model call) within a
/// run.
///
/// A run is composed of one or more steps: each step is a
/// `chat_stream` call plus any tool execution that follows. The engine
/// mints a fresh `StepId` at the start of every step and surfaces it on
/// [`crate::StreamChunk::StepStarted`] / [`crate::StreamChunk::StepFinished`]
/// so middlewares can scope per-step state (e.g. token counts, retries)
/// without tracking iteration numbers themselves.
;