Add observability: token tracking, error logging, action audit trail#22
Open
Add observability: token tracking, error logging, action audit trail#22
Conversation
New modules: - logger.js: structured JSONL logger with cost estimation, used by all components - tools/logs.js: 3 tools (log_cost_summary, log_search, log_errors) so the agent can query its own usage and debug issues Wired into: - Brain: logs every API call (tokens, cost, advisor usage, duration) and every tool execution (name, args, result, duration, errors) - Kernel: logs auto-commits, rollbacks, verification pass/fail - Webchat: logs inbound messages Logs written to .state/logs/ as daily-rotated JSONL files. Cost estimation built in for Sonnet, Opus, and Haiku pricing. Closes #21 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per-tool logs: each tool execution writes to both the aggregate
tools log and a dedicated tools-{name} log (e.g. tools-execute_shell).
Enables isolated debugging per tool across time.
Reasoning traces: heartbeat and cron cycles now capture the entire
brain conversation (text, tool calls, tool results) to traces/ logs.
You can reconstruct exactly what the agent thought and did in each
autonomous cycle, including partial traces on failure.
75 tests passing (3 new trace/per-tool tests).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Every execution context (heartbeat cycle, cron job, conversation turn) gets a unique trace_id that flows through brain → API calls → tool calls. This enables: - log_cost_per_task: "heartbeat hb_1712880000_a cost $0.0234 (3 API calls)" - Correlate all API calls and tool executions to the task that triggered them - See exactly which heartbeat cycle was expensive and why Also adds costByTrace() to the logger for aggregating costs by trace. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
log_cost_summary,log_search,log_errors.state/logs/Why this is first
Every unconscious process we build after this will automatically have observability. The agent can check its own costs, debug errors, and understand what happened during the day.
Test plan
Closes #21
🤖 Generated with Claude Code