Audit Log of Tool Calls
Log every call with arguments and outcome so an agent's actions can be reconstructed
Use when: the server can change state or reach anything outside its own directory
Avoid when: the server is read-only over public content and no audit is required
Procedure
- Decide the log destination: stderr, a file or both, never stdout
- Log timestamp, tool name, argument names and outcome
- Redact argument values that are credentials
- Log the failure reason for refused and errored calls
- Rotate or cap the log so it cannot fill the disk
- Verify a session can be reconstructed from the log alone
Signals
- each call appears exactly once in the log
- argument values that are secrets are redacted
- refusals and errors are logged with reasons
- the log never appears on stdout
Patterns
1. Structured line
{"ts":...,"tool":"get_skill","args":["slug"],"ok":true}
2. Redaction
args values logged as [redacted] when the key matches token|key|secret
3. Log size cap
rotate at 10 MB, keep three files
Pitfalls
- Logging whole argument objects including credentials
- Writing the audit log to stdout and breaking the protocol
- Logging failures without the reason, making the entry useless
Done when
- a session can be reconstructed from the log
- no credential value appears in any log line