MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / try_append_agent_trace

Function try_append_agent_trace

atomic-agent/src/export.rs:451–472  ·  view source on GitHub ↗

Inner fallible implementation of [`append_agent_trace`].

(record: &TraceRecord, root: &Path)

Source from the content-addressed store, hash-verified

449
450/// Inner fallible implementation of [`append_agent_trace`].
451fn try_append_agent_trace(record: &TraceRecord, root: &Path) -> std::io::Result<()> {
452 use std::fs::{self, OpenOptions};
453 use std::io::Write;
454
455 let dir = root.join(".agent-trace");
456 fs::create_dir_all(&dir)?;
457
458 let path = dir.join("traces.jsonl");
459 let mut file = OpenOptions::new().create(true).append(true).open(&path)?;
460
461 let line = serde_json::to_string(record)
462 .map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e.to_string()))?;
463 writeln!(file, "{}", line)?;
464
465 log::debug!(
466 "agent-trace: appended record {} to {}",
467 record.id,
468 path.display()
469 );
470
471 Ok(())
472}
473
474// ---------------------------------------------------------------------------
475// Tests

Callers 1

append_agent_traceFunction · 0.85

Calls 3

openMethod · 0.45
appendMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected