Skip to content

Add workflow metrics endpoint for workflow-stage and agent-action analytics#160

Closed
akgohain wants to merge 1 commit intomainfrom
codex/add-metrics-endpoint-for-workflows-l33ri3
Closed

Add workflow metrics endpoint for workflow-stage and agent-action analytics#160
akgohain wants to merge 1 commit intomainfrom
codex/add-metrics-endpoint-for-workflows-l33ri3

Conversation

@akgohain
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a backend analytics endpoint to surface workflow-stage transitions and agent approval/rejection activity for observability and reporting.
  • Compute stable metrics even when event streams are sparse or empty so callers receive predictable schema and safe defaults.

Description

  • Add Pydantic models in server_api/workflow/models.py for WorkflowEvent and the WorkflowMetricsResponse schema.
  • Implement metrics aggregation in server_api/workflow/service.py with compute_metrics that calculates event counts by type, approvals/rejections counts and rates, stage transition counts, and first/last event timestamps.
  • Add a small in-memory event store in server_api/workflow/store.py with get_events, set_events, and clear_events to support seeding and retrieval for the endpoint and tests.
  • Expose an APIRouter in server_api/workflow/router.py that provides GET /api/workflows/{workflow_id}/metrics (router is available as server_api.workflow.router and can be mounted into the main app).
  • Add endpoint-focused tests in tests/test_workflow_metrics.py that validate safe defaults for empty workflows and correctness against seeded events.

Testing

  • Ran PYTHONPATH=. pytest -q tests/test_workflow_metrics.py which succeeded: 2 passed (the test module mounts the router directly for isolation).
  • Attempted uv run pytest -q tests/test_workflow_metrics.py which failed in this environment due to package metadata issues for an unrelated editable dependency (pytorch_connectomics), not due to the new workflow tests.

Codex Task

@akgohain
Copy link
Copy Markdown
Collaborator Author

Consolidated into draft PR #165 (feat/codex-wave-integration). Closing this source draft to keep review in one place.

@akgohain akgohain closed this Apr 13, 2026
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