> For the complete documentation index, see [llms.txt](https://robodex.gitbook.io/robodex-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://robodex.gitbook.io/robodex-docs/research/strategies-experiments.md).

# Strategies And Experiments

Research strategies live in:

```
packages/research/strategy/
```

Experiments live in:

```
packages/research/experiment/
```

Benchmarks live in:

```
packages/research/benchmark/
```

## Strategy protocol

The `GenerationStrategy` protocol is:

```python
generate(prompt, config) -> list[RobotDesignIR]
```

Strategies produce canonical IR designs for research benchmarking. They are not the same as app-compatible loops.

## Grammar strategy

`packages/research/strategy/grammar_strategy.py` wraps grammar-loop behavior for experiments.

It can:

* build V2 registry agents from prompt templates,
* run `run_grammar_v2_agent_loop`,
* pass program, graph, component program, spec, compile-safety, and HITL data to the materializer,
* create variants when fewer designs than the requested population are produced.

## LLM materializer

`packages/research/strategy/llm_materializer.py` converts graph or component data into `RobotDesignIR`.

It:

* extracts node contexts,
* requests physical attributes from an LLM when configured,
* uses deterministic fallback attributes when needed,
* builds links, joints, sensors, and actuators,
* validates and repairs dangling references.

## Experiment runner

`ExperimentRunner` orchestrates:

```
strategy.generate() -> benchmark harness -> SQLite store
```

It captures a `ReproEnvelope` with:

* seed,
* model id,
* prompt hashes,
* strategy version,
* git SHA.

## Benchmark harness

The benchmark harness can:

* validate the IR,
* compile MJCF,
* run MuJoCo screening when available,
* measure stability and actuator coverage,
* compute diversity metrics,
* aggregate compile and screening results.

If MuJoCo or a heavier dependency is unavailable, the harness should degrade clearly rather than hiding the missing evidence.

## Research CLI

Common commands:

```bash
python3 -m packages.research.cli strategies
python3 -m packages.research.cli run "quadruped that climbs stairs" -s grammar --seed 42 -e stair-v1
python3 -m packages.research.cli show stair-v1
python3 -m packages.research.cli metrics <run-id>
python3 -m packages.research.cli compare <run-id-1> <run-id-2>
```

Use the CLI for reproducible research runs, not the product workspace route.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://robodex.gitbook.io/robodex-docs/research/strategies-experiments.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
