MCPcopy Create free account
hub / github.com/AI45Lab/Code / gen_agent_event

Function gen_agent_event

core/tests/test_persisted_schema_roundtrip.rs:360–408  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

358/// and an old reader/writer mismatch around them is the live cross-version
359/// risk.
360fn 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
410fn gen_run_status(rng: &mut Rng) -> RunStatus {
411 match rng.below(7) {

Callers 1

gen_run_recordFunction · 0.85

Calls 10

gen_token_usageFunction · 0.85
belowMethod · 0.80
stringMethod · 0.80
usize_belowMethod · 0.80
i32_smallMethod · 0.80
booleanMethod · 0.80
json_value_non_nullMethod · 0.80
f64_finiteMethod · 0.80
opt_stringMethod · 0.80
opt_u64Method · 0.80

Tested by

no test coverage detected