Skip to content

refactor(agentic): generalize agentic predictors via DomainConfig#170

Closed
ethancjackson wants to merge 3 commits into
mainfrom
generalize-agentic-predictors
Closed

refactor(agentic): generalize agentic predictors via DomainConfig#170
ethancjackson wants to merge 3 commits into
mainfrom
generalize-agentic-predictors

Conversation

@ethancjackson

Copy link
Copy Markdown
Collaborator

Summary

Parameterization + promotion refactor that makes the agentic forecasting machinery domain-agnostic, so the forthcoming workshop_experiments/ package (S&P 500 workshop paper) can configure agents without touching oil code. Pure refactor — no new features, no behavior changes.

  • Promoted to aieng/forecasting/methods/agentic/: generic StrategyState (4-layer observations→hypotheses→corrections→narrative model, title/name as ClassVar params), build_skill_tools (import-time singletons removed), generic ScenarioCard/ScenarioAgentForecastOutput, compress_history.
  • New DomainConfig (methods/agentic/domain.py): frozen pydantic surface for persona, target series/units, fetch hints, context-retrieval instruction + recommended queries, strategy-skill naming, skill dirs, vol-regime bands, and tool bounds — with render_* instruction templates and generic build_analyst_config/build_adaptive_config.
  • Oil becomes a thin wrapper: OIL_DOMAIN instance + delegating build_wti_* factories; WtiStrategyState subclass pins title/name; oil scenario output pins wti_range_60d/point_estimate_60d field names.
  • Vol-regime bands in curriculum._vol_regime extracted to a parameter (defaults preserved).
  • Tests first: 20 new characterization tests (adaptive-skill store, SKILL.md render snapshot against the committed trained skill, all 5 mutation tools) written and green before the refactor.

Invariants verified

  • Oil agent.name / predictor_id strings byte-identical (committed prediction caches under data/predictions/ key on them) — verified against goldens and re-verified independently post-review.
  • All rendered oil instructions and task specs byte-identical to pre-refactor strings.
  • Committed wti-strategy-trained skill loads and SKILL.md renders byte-identically (snapshot test).
  • scripts/build_nb05.py/build_nb06.py import surfaces resolve unchanged.

Verification

  • pre-commit run --all-files: all hooks pass.
  • pytest -m "not integration_test" tests ../implementations/tests: 489 passed, 7 skipped.
  • mypy -p aieng: clean.

Note: the concierge catalog regeneration (forced by test_concierge_catalog indexing the new modules) swept up some pre-existing catalog drift, which accounts for the artifact-file churn under the concierge context.

Part of the workshop-paper plan (planning-docs/workshop-paper-plan.md on learn-day-content); PR 2 (workshop_experiments/) builds on this.

🤖 Generated with Claude Code

ethancjackson and others added 3 commits July 15, 2026 20:33
Pin the behaviour the domain-agnostic refactor must preserve:

- AdaptiveSkillStore save/load/render/backup contract and the
  confirmation_threshold store parameter (shared-lib test with a minimal
  concrete state).
- WtiStrategyState.build_markdown() renders the committed
  wti-strategy-trained artifact byte-identically (snapshot), plus the
  default oil skill name/title.
- The five strategy mutation tools' evidence governance: observation/
  hypothesis lifecycle, the graduation threshold guard, and the
  narrative-update rationale requirement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ainConfig

Promote the shared agentic engine so a new target series can be configured
without touching oil code, and drive the oil prompts/config from a single
`DomainConfig`. Pure refactor: no new features, no study driver.

Promoted to aieng/forecasting/methods/agentic/:
- strategy_state.py: generic `StrategyState` (+ Observation/Hypothesis/
  CalibrationCorrection/VersionEntry). Markdown title, default skill name, and
  frontmatter description are ClassVar params. Oil `WtiStrategyState` becomes a
  thin subclass pinning the WTI strings — committed SKILL.md renders identically.
- adaptive_skill_tools.py: `build_skill_tools(strategy_dir, state_type, ...)`
  generic over any StrategyState subclass. No import-time singletons. Oil
  skill_tools.py delegates and re-exports the sub-models; STORE/WTI_SKILL_TOOLS
  removed (unused outside docstrings).
- history.py: `compress_history` (was analyst_agent/agent.py); oil re-exports it.
- outputs.py: generic `ScenarioCard` / `ScenarioAgentForecastOutput` with the
  scenario-card numeric fields parameterized via `scenario_card_template_extra`.
  Oil `tasks.py` subclasses them, preserving `wti_range_60d`/`point_estimate_60d`
  and modality="discrete".
- domain.py: `DomainConfig` (identity, data/target, context-retrieval, strategy
  skill, skill dirs, vol-regime bands, tool bounds) plus render_* instruction
  templates and `build_analyst_config` / `build_adaptive_config`.

Oil implementation:
- energy_oil_forecasting/domain.py defines `OIL_DOMAIN`.
- analyst/adaptive/starter agent instructions now render from OIL_DOMAIN; the
  `build_wti_*` factories are thin delegating wrappers. Rendered oil prompts are
  byte-identical to the originals (verified against captured goldens).

Curriculum: `_vol_regime` vol bands extracted to a `bands` parameter with the
15/30/50 thresholds as `DEFAULT_VOL_REGIME_BANDS`.

Invariants held: oil agent.name / predictor_id strings unchanged; committed skill
artifacts render identically; nb05/nb06 import surfaces resolve. Regenerated the
concierge catalog/artifacts to index the new modules. __init__ re-exports the
promoted names; old oil import paths preserved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New PYSEC-2026 advisories against the locked versions fail CI's pip-audit
step on every branch (main last passed 2026-07-07, before publication).
Full test suite re-verified after the bump: 489 passed, 7 skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ethancjackson

Copy link
Copy Markdown
Collaborator Author

Closing in favor of continuing this work on the fork: https://github.com/VectorInstitute/agentic-forecasting-live (merged there as agentic-forecasting-live#1). The bootcamp repo stays stable through the build phase; the generalization work will be promoted back upstream as a fresh PR once the bootcamp wraps.

One standalone piece worth taking upstream sooner: commit fe137aa (chore(deps): bump mistune 3.3.3 / pillow 12.3.0) — new PYSEC-2026 advisories fail CI's pip-audit on every branch here as of this week, independent of this refactor.

🤖 Generated with Claude Code

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