AlexandrAI AGENTS.md
agents-md

LMSSEP Counterfactual Reasoning MCP Server Agent Guide

Project-specific AGENTS.md guidance for the LMSSEP Counterfactual Reasoning MCP server, four-phase analysis, scenario types, session reports, and reset rules.

AGENTS.md

Guidance for coding agents working on LMSSEP Counterfactual Reasoning MCP Server. This server supports structured what-if analysis for incidents, risks, and improvement planning.

Project overview

The counterfactual workflow starts from an actual situation, generates alternative scenarios, performs deep reasoning, compares outcomes, and writes a Markdown session report. It supports diagnostic, predictive, preventive, and optimization scenario types.

Setup commands

bashcd <project-root>/genesis/LMSSEP/counterfactual_reasoning
pip install -r requirements.txt
python main.py

Configure server name, version, transport, log level, and optional HTTP port through environment variables. Use <PORT> in public docs.

Tool workflow

  1. counterfactual_initialize creates a session and initial Markdown report.
  2. counterfactual_phase1 records actual state and causal chain.
  3. counterfactual_phase2 provides diagnostic, predictive, preventive, and optimization scenarios, selecting the next scenario type.
  4. counterfactual_phase3_step1 applies minimal change, causal consistency, and proximity principles.
  5. counterfactual_phase3_step2 through step5 analyze direct impact, ripple effects, multidimensional effects, long-term evolution, and outcomes.
  6. counterfactual_phase4 compares actual and counterfactual outcomes and records actions.
  7. counterfactual_get_result, reset, and list_sessions support review and lifecycle management.

Code map

  • src/tools/counterfactual_reasoning.py owns sessions, phase validation, Markdown updates, and result retrieval.
  • configs/config.py owns server and output configuration.
  • src/utils/session_persistence.py and validators provide shared utilities.

Testing and verification

Test the full happy path for one scenario type, an invalid phase order, missing required phase keys, completion of all scenario types, result retrieval, session listing, and reset.

Safety and output hygiene

Counterfactual reports often describe incidents. Remove customer names, private system names, endpoints, secrets, and internal timings before publishing. Treat recommendations as hypotheses until validated against real evidence.

Commit and PR rules

Changes to phase schema or Markdown report shape need a migration note and a sample sanitized output. Preserve strict phase ordering.