Skip to main content

Event

Struct Event 

Source
pub struct Event {
    pub v: SchemaVersion,
    pub seq: u64,
    pub run_id: RunId,
    pub timestamp: Option<OffsetDateTime>,
    pub span_id: SpanId,
    pub parent: Option<u64>,
    pub kind: EventKind,
    pub redactions: Vec<String>,
}
Expand description

Top-level event envelope. Every event — lifecycle, LLM, tool, memory, etc. — is wrapped in this struct. Spans are represented by two events sharing a span_id.

Fields§

§v: SchemaVersion§seq: u64§run_id: RunId§timestamp: Option<OffsetDateTime>§span_id: SpanId§parent: Option<u64>§kind: EventKind

Flattens type and payload fields into the envelope. Unknown types deserialize as EventKind::Unknown carrying the raw payload — a forward-compat contract.

§redactions: Vec<String>

Implementations§

Source§

impl Event

Source

pub fn new( seq: u64, run_id: RunId, span_id: impl Into<SpanId>, kind: EventKind, ) -> Self

Examples found in repository?
examples/gen_v1_fixture.rs (lines 28-38)
13fn main() {
14    let run_id = RunId::new();
15    let capabilities = LlmCapabilities {
16        streaming: true,
17        prompt_caching: true,
18        parallel_tool_use: true,
19        vision: true,
20        thinking: true,
21        structured_output: false,
22        max_context_tokens: 200_000,
23        max_output_tokens: 8192,
24    };
25    let task = Task::new("inspect the repo").with_id("smoke-1");
26
27    let events = vec![
28        Event::new(
29            0,
30            run_id,
31            "run-0",
32            EventKind::Meta(MetaPayload {
33                schema_version: SchemaVersion::CURRENT,
34                harness_version: "0.1.0".into(),
35                task_snapshot: task.clone(),
36                llm_capabilities: capabilities.clone(),
37            }),
38        ),
39        Event::new(
40            1,
41            run_id,
42            "run-0",
43            EventKind::RunStarted(RunStartedPayload {
44                extra: MetadataMap::new(),
45            }),
46        ),
47        Event::new(
48            2,
49            run_id,
50            "turn-0",
51            EventKind::TurnStarted(TurnPayload { turn_index: 0 }),
52        ),
53        Event::new(
54            3,
55            run_id,
56            "llm-0",
57            EventKind::LlmRequest(LlmRequestPayload {
58                request: CompletionRequest {
59                    messages: vec![Message::user_text("inspect the repo")],
60                    tools: vec![],
61                    system: Some("You are an agent.".into()),
62                    max_tokens: Some(1024),
63                    temperature: None,
64                    stop_sequences: vec![],
65                    cache_hints: Default::default(),
66                    extensions: MetadataMap::new(),
67                },
68                provider: Some("anthropic".into()),
69            }),
70        ),
71        Event::new(
72            4,
73            run_id,
74            "llm-0",
75            EventKind::LlmResponse(LlmResponsePayload {
76                response: CompletionResponse {
77                    id: "msg_01".into(),
78                    model: ModelId::new("claude-sonnet-4-5"),
79                    content: vec![
80                        Content::text("Let me check."),
81                        Content::ToolUse {
82                            id: "tu_1".into(),
83                            name: "fs_list".into(),
84                            input: serde_json::json!({"path": "."}),
85                        },
86                    ],
87                    stop_reason: StopReason::ToolUse,
88                    usage: Usage {
89                        tokens_input: 42,
90                        tokens_output: 18,
91                        ..Default::default()
92                    },
93                },
94            }),
95        ),
96        Event::new(
97            5,
98            run_id,
99            "tool-0",
100            EventKind::ToolCallStarted(ToolCallStartedPayload {
101                tool_name: "fs_list".into(),
102                tool_use_id: "tu_1".into(),
103                input: serde_json::json!({"path": "."}),
104            }),
105        ),
106        Event::new(
107            6,
108            run_id,
109            "tool-0",
110            EventKind::ToolCallFinished(ToolCallFinishedPayload {
111                tool_name: "fs_list".into(),
112                tool_use_id: "tu_1".into(),
113                output: serde_json::json!([{"type": "text", "text": "Cargo.toml\nsrc/"}]),
114                truncated: false,
115            }),
116        ),
117        Event::new(
118            7,
119            run_id,
120            "turn-0",
121            EventKind::TurnFinished(TurnFinishedPayload {
122                turn_index: 0,
123                stop_reason: StopReason::ToolUse,
124                usage: Usage {
125                    tokens_input: 42,
126                    tokens_output: 18,
127                    ..Default::default()
128                },
129                tool_calls: 1,
130            }),
131        ),
132        // Second turn: llm.failed path, for coverage.
133        Event::new(
134            8,
135            run_id,
136            "turn-1",
137            EventKind::TurnStarted(TurnPayload { turn_index: 1 }),
138        ),
139        Event::new(
140            9,
141            run_id,
142            "llm-1",
143            EventKind::LlmFailed(LlmFailedPayload {
144                reason: "rate limited".into(),
145            }),
146        ),
147        Event::new(
148            10,
149            run_id,
150            "run-0",
151            EventKind::RunFinished(RunFinishedPayload {
152                termination: "Completed { reason: EndTurn }".into(),
153                turns: 1,
154                tool_calls: 1,
155                extra: MetadataMap::new(),
156            }),
157        ),
158    ];
159
160    let path = "crates/oharness-core/testdata/trajectories/v1.0/smoke.jsonl";
161    let mut file = File::create(path).unwrap();
162    for event in events {
163        let line = serde_json::to_vec(&event).unwrap();
164        file.write_all(&line).unwrap();
165        file.write_all(b"\n").unwrap();
166    }
167    println!("wrote {path}");
168}
Source

pub fn with_parent(self, parent: u64) -> Self

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,