e52f144671
Add structured INFO-level logging to the key code paths so agent.log
captures actionable debugging data:
API calls (run_agent.py):
- Model, provider, input/output tokens, total tokens, latency
- Cache hit rate (cache_read_tokens / prompt_tokens percentage)
- Logged after each successful API call with usage data
Tool execution (run_agent.py):
- Tool name, duration, result size for successful calls
- Tool name, duration, error preview for failures
- Both sequential and concurrent execution paths instrumented
Session lifecycle (run_agent.py):
- Conversation turn start: session ID, model, provider, platform,
history size, message preview
- Context compression: before (message count, token estimate) and
after (compressed count, post-compression tokens)
Credential pool (agent/credential_pool.py):
- Pool exhaustion: which credential was marked exhausted and why
- Rotation: which credential was selected next
- Empty pool: when all credentials are exhausted
Example agent.log output after this change:
INFO run_agent: conversation turn: session=20260405_223500_abc model=claude-opus provider=openrouter platform=cli history=12 msg='Fix the logging...'
INFO run_agent: tool terminal completed (2.34s, 1847 chars)
INFO run_agent: tool read_file completed (0.01s, 3204 chars)
INFO run_agent: API call #3: model=claude-opus provider=openrouter in=45231 out=892 total=46123 latency=4.2s cache=38102/45231 (84%)