Problem
There is zero structured logging of agent activity. Once a session ends there's no record of what tools the agent called, what decisions it made, or what it cost. We can't audit, replay, or measure agent performance.
Proposed approach
Emit structured events to /home/clide/.clide/logs/<session_id>/events.jsonl:
Event types
Session envelope:
{"event":"session_start","session_id":"clide-<ulid>","repo":"itscooleric/clem","model":"claude-opus-4-5","started_at":"...","schema_version":1}
{"event":"session_end","session_id":"clide-<ulid>","outcome":"success","total_turns":42,"total_tokens_in":15000,"total_tokens_out":8000,"estimated_cost_usd":0.35,"files_changed":["src/foo.py"],"schema_version":1}
Tool calls:
{"event":"tool_call","ts":"...","session_id":"clide-<ulid>","turn":7,"tool":"bash","input":{"command":"pytest tests/ -v"},"exit_code":0,"duration_ms":4211,"schema_version":1}
Reasoning checkpoints:
{"event":"reasoning","ts":"...","session_id":"clide-<ulid>","type":"plan","content":"...","schema_version":1}
Secret scrubbing (required — formerly C-5)
All tool inputs must be scrubbed before writing to disk:
- Redact values matching
[A-Z_]{3,}=\S+ heuristic (env var assignments)
- Explicit blocklist:
GH_TOKEN, ANTHROPIC_API_KEY, OPENAI_API_KEY, CLAUDE_CODE_OAUTH_TOKEN, TTYD_PASS
- Scrub before write, never after
Implementation approach
Prerequisite spike: Verify if Claude CLI supports --output-format stream-json or similar structured output flag. If yes (Option B), parse the stream directly. If no, write a thin Python shim that wraps the agent CLI and intercepts tool calls (Option A).
Must work for both Claude and Codex CLIs — the logging mechanism should be agent-agnostic or have pluggable adapters.
Schema
Include schema_version: 1 on every event from day one. This is non-negotiable — we'll regret changing the format without versioning.
Acceptance criteria
Size
M — this is the keystone of agent observability. Everything else in v4 depends on it.
Dependencies
- X-1: Session ID convention should be agreed before this starts (XS effort)
Source: workspace/notes/research/ai_agent_logging.md, final_observability_ticket_plan.md (C-3 + C-5)
Problem
There is zero structured logging of agent activity. Once a session ends there's no record of what tools the agent called, what decisions it made, or what it cost. We can't audit, replay, or measure agent performance.
Proposed approach
Emit structured events to
/home/clide/.clide/logs/<session_id>/events.jsonl:Event types
Session envelope:
{"event":"session_start","session_id":"clide-<ulid>","repo":"itscooleric/clem","model":"claude-opus-4-5","started_at":"...","schema_version":1}{"event":"session_end","session_id":"clide-<ulid>","outcome":"success","total_turns":42,"total_tokens_in":15000,"total_tokens_out":8000,"estimated_cost_usd":0.35,"files_changed":["src/foo.py"],"schema_version":1}Tool calls:
{"event":"tool_call","ts":"...","session_id":"clide-<ulid>","turn":7,"tool":"bash","input":{"command":"pytest tests/ -v"},"exit_code":0,"duration_ms":4211,"schema_version":1}Reasoning checkpoints:
{"event":"reasoning","ts":"...","session_id":"clide-<ulid>","type":"plan","content":"...","schema_version":1}Secret scrubbing (required — formerly C-5)
All tool inputs must be scrubbed before writing to disk:
[A-Z_]{3,}=\S+heuristic (env var assignments)GH_TOKEN,ANTHROPIC_API_KEY,OPENAI_API_KEY,CLAUDE_CODE_OAUTH_TOKEN,TTYD_PASSImplementation approach
Prerequisite spike: Verify if Claude CLI supports
--output-format stream-jsonor similar structured output flag. If yes (Option B), parse the stream directly. If no, write a thin Python shim that wraps the agent CLI and intercepts tool calls (Option A).Must work for both Claude and Codex CLIs — the logging mechanism should be agent-agnostic or have pluggable adapters.
Schema
Include
schema_version: 1on every event from day one. This is non-negotiable — we'll regret changing the format without versioning.Acceptance criteria
events.jsonlwritten per session with all event types aboveschema_versionfield on every eventSize
M — this is the keystone of agent observability. Everything else in v4 depends on it.
Dependencies
Source:
workspace/notes/research/ai_agent_logging.md,final_observability_ticket_plan.md(C-3 + C-5)