Skip to content

Add observability across build_context/consolidate/search chains#13

Merged
Sunnylincc merged 1 commit intomainfrom
codex/add-observability-to-main-workflows
Mar 5, 2026
Merged

Add observability across build_context/consolidate/search chains#13
Sunnylincc merged 1 commit intomainfrom
codex/add-observability-to-main-workflows

Conversation

@Sunnylincc
Copy link
Owner

Motivation

  • Provide unified, structured observability for the three main flows (build_context, consolidate, search) so agent/session/request context and key metrics are consistently available.
  • Make telemetry pluggable with a safe default to allow easy integration with Prometheus/OpenTelemetry later while keeping tests simple.

Description

  • Add a JSON log formatter and configure_json_logger helper in hippocortex/observability.py that emits agent_id, session_id, and request_id as structured fields.
  • Introduce a telemetry abstraction in hippocortex/telemetry.py (Telemetry protocol) with NoOpTelemetry default and InMemoryTelemetry for tests, and wire it into the SDK via a telemetry field on HippoCortex.
  • Instrument hippocortex/hippo/episodic_store.py event writes to increment hippocortex.events.write and emit a structured event_written log entry, and instrument HippoCortex.consolidate and CortexAPI.search to observe hippocortex.consolidation.duration_ms, hippocortex.search.duration_ms, and hippocortex.search.hit_rate and emit structured logs.
  • Extend the router decision (RoutingDecision) with an explain payload containing matched keywords, scores, and budget allocation and log the router decision from build_context.
  • Add tests/test_observability.py to assert that router explain is present, structured logs include agent_id/session_id/request_id, and telemetry metrics are emitted via InMemoryTelemetry.

Testing

  • Ran the focused test set: pytest -q tests/test_observability.py tests/test_router_policy.py tests/test_working_memory.py tests/test_consolidation.py and verified all tests passed.
  • Ran the full test suite with pytest -q and confirmed 17 passed.
  • Tests specifically assert presence of structured log fields, RoutingDecision.explain contents, and that telemetry counters/observations include hippocortex.events.write, hippocortex.consolidation.duration_ms, hippocortex.search.duration_ms, and hippocortex.search.hit_rate.

Codex Task

@Sunnylincc Sunnylincc merged commit 6d05b08 into main Mar 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant