Skip to content

Feature: Time to First Result (TTFR) estimator integrated into agent pipeline#86

Open
rajnisk wants to merge 5 commits intoINCF:mainfrom
rajnisk:feature/ttfr-foundation
Open

Feature: Time to First Result (TTFR) estimator integrated into agent pipeline#86
rajnisk wants to merge 5 commits intoINCF:mainfrom
rajnisk:feature/ttfr-foundation

Conversation

@rajnisk
Copy link

@rajnisk rajnisk commented Mar 12, 2026

Relates to #26.

Summary

Integrates the TTFR (Time to First Result) estimator into the agent pipeline and exposes estimated retrieval time in chat response metadata. Tests are located under tests/ as requested.

Changes

  • TTFR module (backend/ttfr_estimator.py): Core estimation logic with datasource defaults, modality inference, and three-phase breakdown (access, preprocessing, first output). Code-quality fixes applied (docstrings, rounding/singular forms, optional types).
  • Tests (tests/test_ttfr_estimator.py): 39 unit tests; run with pytest tests/ -v from repo root. Pytest configured in pyproject.toml (pythonpath, testpaths); pytest remains a dev dependency only.
  • Pipeline integration (backend/agents.py): TTFR computed per fused result in fuse_results; ttfr_estimates (id, title, ttfr_summary) stored per session and exposed via get_last_response_metadata(session_id).
  • API (backend/main.py): Chat response metadata includes ttfr_estimates for the returned results.
  • Retrieval (backend/retrieval.py): VertexRetriever.is_enabled implemented as a property for ABC compatibility (Python 3.14).
  • Docker (backend/Dockerfile, backend/service-account.json.example): Build works without a real GCP key file by using an example placeholder.
  • Script (scripts/verify_ttfr_m1_m2.sh): Local verification for M1 and M2 without GCP.

Verification

  • cd backend && python3 -c "from ttfr_estimator import estimate_ttfr; print(estimate_ttfr(datasource_id='scr_005031_openneuro'))" and python3 demo_ttfr.py
  • pytest tests/ -v (from repo root)
  • POST /api/chat with a search query returns metadata.ttfr_estimates in the JSON response.

Checklist

  • TTFR integrated into agent pipeline
  • Estimated retrieval time included in chat response metadata
  • Tests moved to tests/ directory
  • No breaking changes to existing API
  • Branch updated with upstream main

rajnisk and others added 5 commits January 12, 2026 01:55
- Compute TTFR per fused result; expose ttfr_estimates in chat response metadata
- VertexRetriever: implement is_enabled as property for ABC compatibility (Python 3.14)
- Dockerfile: use service-account.json.example when key file absent
- Add verification script for TTFR milestones

Made-with: Cursor
@rajnisk
Copy link
Author

rajnisk commented Mar 12, 2026

@QuantumByte-01 Would love your feedback when you have a moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant