Skip to content

plot_config_agent

SensAI domain agent for the trial viewer plot - full CRUD over saved plot config profiles.

get_current_plot_config async

Python
get_current_plot_config(ctx: RunContext[SensAIDeps]) -> str

Returns the full trial viewer plot configuration as JSON. Call this before proposing any config update.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_agent.py
Python
@plot_config_agent.tool
async def get_current_plot_config(ctx: RunContext[SensAIDeps]) -> str:
    """Returns the full trial viewer plot configuration as JSON. Call this before proposing any config update."""
    if ctx.deps.current_plot_config is None:
        return "No plot config is currently loaded."
    return ctx.deps.current_plot_config.model_dump_json(indent=2)

get_plotted_signals async

Python
get_plotted_signals(
    ctx: RunContext[SensAIDeps],
) -> list[str]

Returns the y-axis signal column names currently displayed in the trial viewer plot.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_agent.py
Python
@plot_config_agent.tool
async def get_plotted_signals(ctx: RunContext[SensAIDeps]) -> list[str]:
    """Returns the y-axis signal column names currently displayed in the trial viewer plot."""
    config = ctx.deps.current_plot_config
    if config is None:
        return []
    return list(config.y_axes.keys())

get_x_axis_signal async

Python
get_x_axis_signal(ctx: RunContext[SensAIDeps]) -> str

Returns the column name used as the x-axis in the trial viewer plot.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_agent.py
Python
@plot_config_agent.tool
async def get_x_axis_signal(ctx: RunContext[SensAIDeps]) -> str:
    """Returns the column name used as the x-axis in the trial viewer plot."""
    config = ctx.deps.current_plot_config
    if config is None:
        return "No plot config is currently loaded."
    return config.x_axis.col if config.x_axis else "time"

list_saved_plot_configs

Python
list_saved_plot_configs() -> list[str]

List the names of every saved plot config profile.

Returns:

Type Description
list[str]

Every saved profile's name (including sub-folder paths, e.g. 'robotics/baseline'), most recently modified first.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_agent.py
Python
@plot_config_agent.tool_plain
def list_saved_plot_configs() -> list[str]:
    """
    List the names of every saved plot config profile.

    Returns:
        Every saved profile's name (including sub-folder paths, e.g. 'robotics/baseline'), most recently modified first.

    """
    d = _get_profiles_dir()
    return [
        f.relative_to(d).with_suffix("").as_posix()
        for f in sorted(
            d.rglob("*.json"), key=lambda p: p.stat().st_mtime, reverse=True
        )
    ]

load_plot_config

Python
load_plot_config(name: str) -> PlotConfig

Load a previously saved plot config profile by name.

Parameters:

Name Type Description Default
name str

The profile name to load, e.g. 'robotics/baseline'.

required

Returns:

Type Description
PlotConfig

The profile's active tab's plot config.

Raises:

Type Description
ModelRetry

If no profile with this name exists, so the caller can retry with a corrected name.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/plot_config_agent.py
Python
@plot_config_agent.tool_plain
def load_plot_config(name: str) -> PlotConfig:
    """
    Load a previously saved plot config profile by name.

    Args:
        name: The profile name to load, e.g. 'robotics/baseline'.

    Returns:
        The profile's active tab's plot config.

    Raises:
        ModelRetry: If no profile with this name exists, so the caller can retry with a corrected name.

    """
    path = _resolve_profile_path(name)
    if not path.exists():
        raise ModelRetry(f"No saved profile named {name!r} found.")
    try:
        data = json.loads(path.read_text(encoding="utf-8"))
        profile = _parse_profile(data, name)
    except (json.JSONDecodeError, ValidationError) as exc:
        raise ModelRetry(
            f"Profile {name!r} failed validation and cannot be loaded: {exc}"
        ) from exc
    return profile.tabs[profile.active_tab_index].config