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

Function try_append_agent_trace

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

Inner fallible implementation of [`append_agent_trace`].

(record: &TraceRecord, root: &Path)

Source from the content-addressed store, hash-verified

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

Callers 1

append_agent_traceFunction · 0.85

Calls 2

openMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected