Phase C: Contagion, Timeline Events, and Merged Pass Reasoning#65
Merged
DeveshParagiri merged 13 commits intomainfrom Feb 16, 2026
Merged
Phase C: Contagion, Timeline Events, and Merged Pass Reasoning#65DeveshParagiri merged 13 commits intomainfrom
DeveshParagiri merged 13 commits intomainfrom
Conversation
Replace incompatible JSON Schema patterns in build_household_config_schema():
- Tuple-style array items (draft-07) -> array of {upper_bound, label} objects
- Schema-valued additionalProperties -> array of objects with explicit keys
Update _parse_household_config() to convert new array-of-objects format back
to dict/tuple structures expected by HouseholdConfig.
Fix _clean_schema_for_tool() to preserve additionalProperties: false (valid)
while stripping schema-valued additionalProperties (unsupported).
Tested with Claude Sonnet 4.5 - Japan-specific data now returned correctly
instead of falling back to US defaults.
Timeline Events: - Add TimelineEvent model for evolving scenarios (crises, campaigns) - Scenarios auto-detect static vs evolving via LLM in generate_timeline() - Timeline events fire exposures at specified timesteps - CLI --timeline flag: auto/static/evolving Contagion & Social Pressure: - Observable peer actions: agents only see peers who will_share=True - Conformity attribute shapes self-awareness in prompts - Timeline recap section shows scenario history in prompts Open-Ended Skip: - build_pass2_schema() returns None when all outcomes are open_ended - Skips Pass 2 classification for exploratory scenarios Merged Pass Flag: - Add --merged-pass CLI flag (experimental) - merged_pass field in SimulationRunConfig
Add _should_hydrate_household_config() to conditionally skip the expensive agentic research call for populations that don't need household context. Only hydrate household config when: 1. Any discovered attribute has scope="household", OR 2. Population description contains household keywords (family, couple, retired, etc.) For purely professional populations (physicians, office workers, voters), skip household research and use defaults if household sampling triggers. Saves ~30-60s of LLM calls for 70%+ of use cases.
Add scenario keywords (childcare, housing, school district, etc.) to _should_hydrate_household_config() so scenarios can trigger household research even when the base population didn't need it. Examples: - "2000 physicians" + "malpractice policy" -> skip household (default) - "2000 physicians" + "subsidized childcare policy" -> research household Also fix extend.py to pass household_config and name_config to build_spec so they're properly merged into the final spec.
Add rich household context to agent personas:
1. Generate first names for NPC partners in _generate_npc_partner()
using the same name generation as regular agents
2. Add render_household_section() to persona renderer with:
- Partner phrases: "My husband David is 45", "Sarah and I have been
together for a while"
- Kids phrases: "Our daughter Sofia is 14, in high school",
"We have 2 kids: Emma (12) and Jake (8)"
- Elderly phrases: "My mother Rosa (72) also lives with us"
- Single parent support: "It's just me and my son Marcus (10)"
- Baby-friendly age formatting: "less than a year old" for age 0
3. Call household section from render_persona() after the intro
Templates vary randomly (seeded by agent ID) for natural variety.
…fy agent_focus mechanism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes Phase C of the v2 architecture, adding:
--merged-pass) for cheaper/faster simulationsKey Changes
Simulation
_reason_agent_merged_async()- single LLM call with combined role-play + classification schemabatch_reason_agents_async()now routes based onconfig.merged_passapply_timeline_exposures()in propagationScenario
timeline.pymodule for timeline generation and static/evolving detection--timelineCLI flag (auto, static, evolving)TimelineEventmodel with timestep, event, exposure_rules, descriptionPopulation
Docs
docs/capabilities.md- narrative walkthrough of all supported scenariosdocs/simulation-v2-architecture.md- removed explicit ratio injection, clarified conformity approachTest Plan
--merged-passflag