Part of #121. See IDEA.md stage 6.
Goal
The new capability unlocked by the refactor: let agents write MJCF elements that SimObject can't express (<tendon>, <equality>, <pair>, custom friction/solref/solimp, sites, flex bodies, hfields, skins, plugins, etc).
API
Two new @tool-exposed actions:
def replace_scene_mjcf(world, xml: str):
\"\"\"Atomically swap the whole scene to agent-written MJCF.
Validated by actually compiling it. Raises on failure with the
MuJoCo compiler error verbatim.\"\"\"
new_spec = mujoco.MjSpec.from_string(xml)
new_model = new_spec.compile() # raises if invalid
...
def patch_scene_mjcf(world, ops: list[dict]):
\"\"\"Apply a list of structured ops to the live spec.
ops = [
{'op': 'add_body', 'parent': 'world', 'name': 'foo', 'pos': [...]},
{'op': 'add_geom', 'body': 'foo', 'type': 'box', ...},
{'op': 'set_attr', 'path': 'body/foo', 'attr': 'pos', 'value': [1,0,0]},
{'op': 'delete', 'path': 'body/foo'},
]\"\"\"
Acceptance
- Both tool actions in
tool_spec.json enum.
- Wrapped
spec.compile() in try/except with clear error-shape parity with the rest of the tool surface.
- Integration test: agent writes a scene with a
<tendon> element, confirms it compiles and simulates.
- Documented in the main tool docstring as an 'escape hatch' from the
SimObject vocabulary.
Part of #121. See IDEA.md stage 6.
Goal
The new capability unlocked by the refactor: let agents write MJCF elements that
SimObjectcan't express (<tendon>,<equality>,<pair>, custom friction/solref/solimp, sites, flex bodies, hfields, skins, plugins, etc).API
Two new
@tool-exposed actions:Acceptance
tool_spec.jsonenum.spec.compile()intry/exceptwith clear error-shape parity with the rest of the tool surface.<tendon>element, confirms it compiles and simulates.SimObjectvocabulary.