Timely Guidance for Fast Decisions: Dynamic LLM–Jev Collaboration under Time Pressure
DynaJev combines a slow language-model Planner, a fast Formatter and a Jev System One Choice Actor. Each environment step exposes a bounded prefix of the slow plan. The Formatter converts that prefix into an actionable handoff; the Actor uses both sources with the current observation. After an action, a short-horizon checker decides whether to retain the plan or restart. Fixed Snake skillbooks can optionally guide the fast and slow roles.
This research-code release provides Snake, Freeway and Overcooked,
token-budget experiments, a Snake-Hard wall-clock scheduler, and the
Formatter-only ablation. Only the selected final feedback checker is
distributed, under the name dynamic.
Use a Linux environment and Python 3.10 (tested). The batch launchers use Bash and Linux process groups. No GPU is needed to run offline previews or tests.
python3.10 -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'For the tested Python dependencies, install requirements-tested.txt
before installing the project. The Python package remains importable as
realtimegym for compatibility with the upstream benchmark; the installed
distribution is named dynajev. Run the experiment commands below from
the repository root. Download model tokenizers separately as required by
the selected model profile; this repository contains no model weights.
These run the actual game and prompt constructors, using explicit placeholder model text. They do not read API credentials or contact a service.
python examples/environment_smoke.py
python -m experiments.token_budget.run snake --method dynajev --skills v1 \
--seeds 0 --dry-run --output outputs/preview-snake
python -m experiments.token_budget.run freeway --method dynajev \
--seeds 0 --dry-run --output outputs/preview-freeway
python -m experiments.token_budget.run overcooked --method dynajev \
--seeds 0 --dry-run --output outputs/preview-overcooked
python -m experiments.wallclock.run --method dynajev --skills v1 --seed 0 --dry-run
python -m experiments.token_budget.formatter_only --dry-run --output outputs/preview-formatter
python -m pytest -qThe preview files are not experimental results. Tests exercise mock clients, loopback-only mock HTTP servers, environment dynamics, restart policies, stream cancellation, configuration snapshots, and skillbook validation.
The public API uses three planning policies: persistent (completion),
fresh (per-step), and dynamic (the final feedback checker).
The named experiment methods use these same policies:
dynajev:dynamic+fast_handoff_rawjev-only: an Actor without Planner, Formatter, or checkerprefix-completion:persistent+rawprefix-per-step:fresh+rawprefix-feedback:dynamic+rawhandoff-completion:persistent+fast_handoff_rawhandoff-per-step:fresh+fast_handoff_raw
For format ablations, use --policy and --format instead of
--method. Supported formats are raw, prompt_handoff,
fast_handoff, fast_handoff_raw, slow_handoff and only_jev.
Set your own API base URL and credentials via the environment or a local
.env copied from .env.example.
The default model profile, glm5_3_flash, uses an OpenAI-compatible
Planner/Formatter endpoint and the Jev endpoint in configs/jev.yaml.
Set DYNAJEV_GLM53_FLASH_BASE_URL, DYNAJEV_GLM53_FLASH_API_KEY and
TYPESAFE_API_KEY before a live run. Alternative role profiles are defined
in configs/snake-format-models.yaml; custom configurations can be
specified with --model-registry and --jev-model-config.
# Main Snake-Hard condition (six test seeds, fixed V1 skills).
python -m experiments.token_budget.run snake --method dynajev --difficulty H \
--skills v1 --seeds 0 1 2 3 4 5 --step-tokens 2048 \
--planner-max-tokens 8192 --output data/runs/snake-h-dynajev-v1
# Other paper environments (no skills).
python -m experiments.token_budget.run freeway --method dynajev --difficulty E \
--seeds 0 1 2 3 4 5 --max-steps 30 --output data/runs/freeway-e-dynajev
python -m experiments.token_budget.run overcooked --method dynajev --difficulty E \
--seeds 0 1 2 3 4 5 --max-steps 60 --output data/runs/overcooked-e-dynajev
# A format ablation.
python -m experiments.token_budget.run snake --policy dynamic --format fast_handoff \
--difficulty H --seeds 0 1 --output data/runs/snake-h-formatAll live commands use model services and may incur charges. Use a new
output directory each time. At the default 2048-step setting, the
Planner receives 2048 prefix-progress tokens in the raw condition, or
1536 plus a 512-token Formatter allowance in a reformatted condition.
The separate Actor accounting reserve is 256 tokens. Planner request
caps and prefix-progress budgets are independent. The default 8192
Planner cap matches the archived 2048-budget protocol used for the
wall-clock request templates; other caps (including 12288) are
explicitly selectable. The token runner defaults to full-response
prefix simulation; --planner-execution stream selects the
cancellable streaming implementation of the same checker.
The per-game Python scripts in scripts/ implement the underlying
evaluation, output manifests, episode logs and aggregations. The Bash
scripts provide multi-seed/difficulty policy batches and Snake skill
rounds. Prefer explicit CLI settings rather than relying on their
editable default arrays. See replication notes.
The standalone scheduler uses a 50-second Snake-Hard window: sample the
prefix at 34 s for handoff methods, allow up to 10 s for formatting,
lock the Actor choice at 49.75 s and apply it at 50 s. Raw-prefix
methods sample at 44 s; Jev-only starts from the observation. The
feedback checker has a 2 s wait. It uses the same final dynamic
checker as the token-budget implementation.
Provide a compatible GLM streaming endpoint and credentials through
DYNAJEV_WALLCLOCK_BASE_URL, DYNAJEV_WALLCLOCK_API_KEY, and
TYPESAFE_API_KEY. Obtain the GLM-5.3-Flash tokenizer JSON separately
from the model distributor, respecting its terms.
python -m experiments.wallclock.run --method dynajev --skills v1 --seed 0 \
--tokenizer /path/to/tokenizer.json --glm-model GLM-5.3-W4A8 \
--output data/runs/wallclock-dynajev-v1-seed0The other six named methods are also supported; --skills none selects
the no-skill condition. Repeat each seed with a new output directory for
additional trials. Manifests, step-level timing, plan retirements and
summaries are written locally; model/service speed can affect outcomes.
No historical experiment directory or private gateway configuration is
needed. For the separate Formatter-only condition:
python -m experiments.token_budget.formatter_only --seeds 0 1 2 3 4 5 \
--output data/runs/formatter-only-v1The fixed resources/skills/snake-v0.json and snake-v1.json
include the evaluation instructions and structured rules.
The generation/refinement command is python scripts/update_snake_skills.py;
see the replication notes for input requirements. The original
development trajectories are not distributed. For recorded runs,
summary.json includes per-condition outcomes and per-episode records;
scripts/analyze_snake_format_ablation.py provides paired format
analysis when the required matched input summaries are available.
src/realtimegym/agents/: planning, streaming, formatter, actor and policy implementationssrc/realtimegym/prompts/: game-specific instructions, including exactly one public checkersrc/realtimegym/environments/: supported environments and rendering resourcesconfigs/: model-role and service configuration templatesexperiments/token_budget/: public token-budget entry pointsexperiments/wallclock/: independent monotonic-clock scheduler and fixed protocol parametersscripts/: tested lower-level runners, batch orchestration and skill/analysis utilitiesresources/skills/: fixed V0 and V1 evaluation skillbookstests/: offline regression suite
This checkout is a selected research implementation, not a copy of the
development repository. It omits historical logs, alternate feedback
checkers, private data, and unlicensed third-party PvZ engine/assets; PvZ
is therefore not runnable in this checkout. See the replication notes
for experimental-provenance limitations and THIRD_PARTY_NOTICES.md
for licenses and attribution. Citation metadata is in CITATION.cff.