Cheap-to-construct, representative `AgentEvent`s — including the three variants added in 3.3.0 (`BudgetThresholdHit`, `PassivationRequested`, `PeerInvocation`), since these are persisted inside `RunRecord.events` and an old reader/writer mismatch around them is the live cross-version risk.
(rng: &mut Rng)
| 358 | /// and an old reader/writer mismatch around them is the live cross-version |
| 359 | /// risk. |
| 360 | fn gen_agent_event(rng: &mut Rng) -> AgentEvent { |
| 361 | match rng.below(9) { |
| 362 | 0 => AgentEvent::Start { |
| 363 | prompt: rng.string(), |
| 364 | }, |
| 365 | 1 => AgentEvent::TurnStart { |
| 366 | turn: rng.usize_below(100), |
| 367 | }, |
| 368 | 2 => AgentEvent::ToolStart { |
| 369 | id: rng.string(), |
| 370 | name: rng.string(), |
| 371 | }, |
| 372 | 3 => AgentEvent::ToolEnd { |
| 373 | id: rng.string(), |
| 374 | name: rng.string(), |
| 375 | output: rng.string(), |
| 376 | exit_code: rng.i32_small(), |
| 377 | metadata: if rng.boolean() { |
| 378 | Some(rng.json_value_non_null(2)) |
| 379 | } else { |
| 380 | None |
| 381 | }, |
| 382 | error_kind: None, |
| 383 | }, |
| 384 | 4 => AgentEvent::Error { |
| 385 | message: rng.string(), |
| 386 | }, |
| 387 | 5 => AgentEvent::TurnEnd { |
| 388 | turn: rng.usize_below(100), |
| 389 | usage: gen_token_usage(rng), |
| 390 | }, |
| 391 | 6 => AgentEvent::BudgetThresholdHit { |
| 392 | resource: rng.string(), |
| 393 | kind: rng.string(), |
| 394 | consumed: rng.f64_finite(), |
| 395 | limit: rng.f64_finite(), |
| 396 | message: rng.opt_string(), |
| 397 | }, |
| 398 | 7 => AgentEvent::PassivationRequested { |
| 399 | reason: rng.string(), |
| 400 | deadline_ms: rng.opt_u64(), |
| 401 | }, |
| 402 | _ => AgentEvent::PeerInvocation { |
| 403 | from_session_id: rng.string(), |
| 404 | from_tenant_id: rng.opt_string(), |
| 405 | correlation_id: rng.opt_string(), |
| 406 | }, |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | fn gen_run_status(rng: &mut Rng) -> RunStatus { |
| 411 | match rng.below(7) { |
no test coverage detected