Rockachopa
|
7647e9172a
|
feat(#446): add request_log instrumentation — Verify What Actually Happened
Architecture Lint / Linter Tests (pull_request) Successful in 23s
Smoke Test / smoke (pull_request) Failing after 19s
Validate Config / YAML Lint (pull_request) Failing after 14s
Validate Config / JSON Validate (pull_request) Successful in 15s
Validate Config / Python Syntax & Import Check (pull_request) Failing after 50s
Validate Config / Python Test Suite (pull_request) Has been skipped
Validate Config / Cron Syntax Check (pull_request) Successful in 11s
Validate Config / Deploy Script Dry Run (pull_request) Successful in 9s
Validate Config / Shell Script Lint (pull_request) Failing after 37s
Validate Config / Playbook Schema Validation (pull_request) Successful in 11s
Architecture Lint / Lint Repository (pull_request) Failing after 12s
PR Checklist / pr-checklist (pull_request) Successful in 4m40s
- Add bin/request_log.py instrumentation library
- log_inference(): write rows to request_log table
- query_requests(): query recent telemetry with filters (agent, provider, model, status, hours)
- did_agent_call_provider(): answer "did agent X call provider Y in last N hours?"
- get_recent_activity_summary(): aggregate stats by agent/provider/model
- ensure_db(): auto-create DB and schema if missing
- CLI interface: `python3 bin/request_log.py log|query|did-call`
- DB path: ~/.local/timmy/request_log.db (configurable via REQUEST_LOG_PATH)
- Add tests/test_request_log.py with 13 passing tests
- test_ensure_db_creates_schema: verifies table + indexes creation
- test_log_inference_inserts_row: full-field insert
- test_log_inference_minimal_fields: required fields only
- test_log_inference_error_status: error status with message
- test_query_requests_filters_by_agent: agent filter
- test_query_requests_filters_by_provider: provider filter
- test_query_requests_time_window: hours parameter
- test_did_agent_call_provider_positive/negative_wrong_agent/negative_wrong_provider
- test_did_agent_call_provider_min_success_count
- test_log_and_query_by_status: status filter
- test_get_recent_activity_summary: view aggregation
The request_log schema and ansible deployment already existed.
This commit adds the missing instrumentation that actually populates it.
Usage example for agents:
```python
from request_log import log_inference
log_inference(
agent_name="codex-agent",
provider="anthropic",
model="claude-sonnet-4-20250514",
endpoint="/v1/messages",
tokens_in=prompt_tokens,
tokens_out=completion_tokens,
latency_ms=int(latency_s * 1000),
status="success"
)
```
Query example:
```python
from request_log import did_agent_call_provider
if did_agent_call_provider("codex-agent", "anthropic", hours=1):
print("Agent successfully called Anthropic in the last hour")
```
Closes #446
|
2026-04-26 01:39:41 -04:00 |
|