A lightweight framework for building multi-stage simulation demos with LLM-driven agents.
This repo helps you build scenarios where:
- multiple sub-environments are composed into one
MetaEnv - an agent makes stage-wise decisions (for example
social -> physical) - behavior and outcomes are logged with readable, config-driven summaries
The current reference demo is demos/red_light_crossing.
Simulation_Context_Protocol/
├── agent/ # Generic LLM backend + action parsing
├── envs/ # Reusable sub-environments (gym-style interface)
├── scp/ # MetaEnv abstractions, adapters, topology helpers
├── runtime/ # Runner + readable logging (driven by log schema)
├── demos/ # Scenario demos (config + builder + meta env + run script)
│ └── red_light_crossing/
├── config/ # Config loader + templates
├── skills/ # Project skills for code agents
└── user_input_template.md # User-facing form for new demo requirements
agent/llm_agent.py- generic OpenAI-compatible client (
openai/deepseek) - demo-specific logic stays outside this file
- generic OpenAI-compatible client (
envs/*.py- sub simulators with project-style gym-like API:
reset(...) -> (obs, info)step(action) -> (obs, reward, done, info)get_state() -> dict
- sub simulators with project-style gym-like API:
demos/<demo>/demo_meta_env.py- orchestrates stage order and data flow across envs
demos/<demo>/demo_builder.py- builds env instances from
demo_config.yaml - builds demo agent from
agentconfig
- builds env instances from
runtime/runner.py- runs episodes
- prints readable logs based on
meta_env.loggingschema in config
Each demo lives in its own folder (for example demos/red_light_crossing) and usually contains:
demo_config.yaml(global source of truth)demo_builder.pydemo_meta_env.py<demo>_llm_agent.pyrun_demo.py
Recommended build sequence:
- define
demo_config.yamlfirst - reuse existing envs from
envs/where possible - create missing envs in gym-style if needed
- implement
demo_meta_env.pyorchestration - implement demo agent wrapper around generic
LLMAgent - wire everything in
demo_builder.py - run through
run_demo.py
Use this structure in each demo config:
meta_env- id/name/purpose
- relation between envs (
type,flow, description) - I/O spec
- logging schema (
step_fields,derived_fields,summaries)
envs- each stage has
class+settings
- each stage has
agent- backend settings and
llm_personality
- backend settings and
Reference files:
- template:
config/demo_config_template.yaml - concrete example:
demos/red_light_crossing/demo_config.yaml
Install dependencies:
pip install -r requirements.txtRun:
python demos/red_light_crossing/run_demo.pyYou will see step-level logs and summary stats rendered from config-defined log schema.
For fast scenario creation with Claude Code or similar code agents:
- Fill the form in
user_input_template.md - Ask the code agent to build a new demo using that filled input
- Let the agent:
- generate
demo_config.yaml - reuse or create needed envs
- build
meta_env, demo agent, builder, andrun_demo.py
- generate
- run and iterate based on readable logs
The form already includes:
- empty template for new demos
- filled red-light-crossing example for reference
For detailed fields and examples, see user_input_template
In short, provide:
- demo basics and evaluation target
- multi-stage flow definition
- per-stage env I/O and key settings
- agent settings and
llm_personality - expected step outputs/logging and success criteria
The file includes both an empty template and a filled red-light-crossing example, so you can copy-and-fill directly for code agents.
This repo includes a project skill:
skills/demo-scene-builder/SKILL.mdskills/demo-scene-builder/reference.md
What it provides:
- methodized workflow (config first -> env reuse/create -> compose meta env/agent -> run demo)
- env search-and-reuse strategy
- gym-style env creation guidance when missing
- validation checklist and minimal follow-up question policy
Use this skill when users provide user_input_template.md content and ask for a new demo scenario.
requirements.txt includes:
numpyPyYAMLopenaihttpx[socks](for environments using SOCKS proxy)
- Keep scenario-specific behavior in
demos/<demo>/, not in generic runtime or base agent. - Keep logging semantics in config (
meta_env.logging) to avoid hard-coded demo assumptions.