Commit 0f831e2
feat: add date forecast type for timing questions (#5247)
## Summary
Adds a third forecast mode (`date`) alongside `binary` and `numeric`.
Date forecasts produce YYYY-MM-DD percentile estimates (p10–p90) for
"when will X happen?" questions, with prompts emphasizing delay bias and
status-quo anchoring. Output columns follow the same
`{output_field}_p{N}` naming as numeric, so `output_field` is required
and `units` is ignored.
## Changes
- **Engine** (`forecast.py`, `task_spec.py`, `agent_state.py`,
`operations.py`)
- New `DATE_FORECASTER_PROMPT` with delay bias / never-happen sentinel
(`2099-12-31`) guidance
- New `build_date_response_schema()` returning string-typed percentile
fields
- New `_combine_batched_date_results()` aggregating with **median
ordinals** (robust to the 2099 sentinel) instead of mean
- `forecast_type` literal extended to `"binary" | "numeric" | "date"`
across `DeepForecastPublicParams`, `DeepForecastFullParams`,
`ForecastBatchStateSerializable`, and `ForecastOperation`
- Date validation requires `output_field` and ignores `units`
- **OpenAPI / SDK / MCP**
- Regenerated OpenAPI types
- `forecast()` / `forecast_async()` SDK signatures and docstrings
updated
- MCP `ForecastInput` and `tools.py` mode_label updated
- **everyrow-cc frontend**
- `ColumnInfo.forecastType` extended; date branch added in
`extractColumnInfo`
- New `extractDatePercentiles()` and `DatePercentileRangeBar`
(timestamp-based scaling, compact "Jun '25" labels)
- `ResearcherStreamItem`, `ResearcherDetailPanel`,
`ResearcherStreamView` rendering branches added
- **everyrow-cc agent**
- System prompt updated to mention `forecast_type="date"` for timing
questions
## Design Notes
- **Median over mean** for date aggregation: dates aren't continuous in
the same way numerics are, and median gracefully handles the 2099-12-31
"never happens" sentinel that some forecasters may emit.
- **Schema**: percentile fields use `{"type": "string"}`, mapping to
`Nullable(String)` in ClickHouse via the existing `_JSON_TO_CH` mapping.
No CH schema changes needed.
- **Backward compatible**: all changes are additive — extending
`Literal` unions and adding `elif` branches. Binary/numeric forecasts
are unaffected.
## Test plan
- [ ] `cd cohort/engine && uv run pyright src` (passes locally — 0
errors)
- [ ] `cd cohort/engine && uv run ruff check` (passes locally)
- [ ] `cd cohort/everyrow-cc/frontend && pnpm run tsc` (passes locally)
- [ ] `cd cohort/everyrow-cc/frontend && pnpm run lint` (passes locally)
- [ ] Run a date forecast end-to-end via the SDK and verify percentile
output + visualization
- [ ] Verify a numeric/binary forecast still works (regression check)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sourced from commit a46ce2370326ec99497b3e869021b3ce4d83068d1 parent 5b47d70 commit 0f831e2
4 files changed
Lines changed: 31 additions & 14 deletions
File tree
- futuresearch-mcp/src/futuresearch_mcp
- src/futuresearch
- generated/models
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
420 | 422 | | |
421 | 423 | | |
422 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
| 650 | + | |
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| |||
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
660 | 665 | | |
661 | 666 | | |
662 | 667 | | |
| |||
695 | 700 | | |
696 | 701 | | |
697 | 702 | | |
698 | | - | |
699 | | - | |
700 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
701 | 709 | | |
702 | 710 | | |
703 | 711 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
821 | | - | |
| 821 | + | |
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
827 | | - | |
| 827 | + | |
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
837 | 842 | | |
838 | 843 | | |
839 | 844 | | |
| |||
848 | 853 | | |
849 | 854 | | |
850 | 855 | | |
851 | | - | |
852 | | - | |
853 | | - | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
854 | 859 | | |
855 | 860 | | |
856 | 861 | | |
| |||
890 | 895 | | |
891 | 896 | | |
892 | 897 | | |
893 | | - | |
| 898 | + | |
894 | 899 | | |
895 | 900 | | |
896 | 901 | | |
| |||
900 | 905 | | |
901 | 906 | | |
902 | 907 | | |
903 | | - | |
904 | | - | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
905 | 911 | | |
906 | 912 | | |
907 | 913 | | |
| |||
0 commit comments