Skip to content

docs_agent

SensAI domain agent for questions about how to use MuJoCo Mojo, answered from the docs that ship with the package.

search_docs

Python
search_docs(query: str) -> str

Finds the parts of the Mojo docs that best match some words, best first.

Parameters:

Name Type Description Default
query str

What to look for, in a few words such as "submit a job to SLURM" or "early termination of a requirement". Plain words are enough: how, the and similar words are ignored, and an ending such as -ing or -s does not matter.

required

Returns:

Type Description
str

Up to five matches, each with the page's path, the section, the line that matched best and the docs site link. Nothing matched is said in words.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/docs_agent.py
Python
@docs_agent.tool_plain
def search_docs(query: str) -> str:
    """
    Finds the parts of the Mojo docs that best match some words, best first.

    Args:
        query: What to look for, in a few words such as "submit a job to SLURM" or "early termination of a requirement". Plain words are enough: how, the and similar words are ignored, and an ending such as -ing or -s does not matter.

    Returns:
        Up to five matches, each with the page's path, the section, the line that matched best and the docs site link. Nothing matched is said in words.

    """
    hits = _search_docs(query)
    logger.info("SensAI search_docs %r: %d hit(s)", query, len(hits))
    if not hits:
        return "Nothing in the docs matches those words. Try other words, or pick a page from your list."
    return "\n".join(
        f"{n}. {hit.section.path} | {hit.section.label}\n   {hit.snippet}\n   {hit.section.link}"
        for n, hit in enumerate(hits, start=1)
    )

read_docs

Python
read_docs(path: str, section: str = '') -> str

Reads a page of the Mojo docs, or one section of it, with its title and docs site link on top.

Parameters:

Name Type Description Default
path str

The page's path, as the list in your instructions and the search results give it, such as "user-guides/workflow/running-jobs/running-jobs.md".

required
section str

Leave it out to read the whole page. To read one part of it, a heading of that page such as "SLURM Mode": the section and the ones under it are returned. A long page comes back cut, with a list of its sections to ask for.

''

Returns:

Type Description
str

The text of the page or section. A path or section that is not there is answered with the ones that are.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/docs_agent.py
Python
@docs_agent.tool_plain
def read_docs(path: str, section: str = "") -> str:
    """
    Reads a page of the Mojo docs, or one section of it, with its title and docs site link on top.

    Args:
        path: The page's path, as the list in your instructions and the search results give it, such as "user-guides/workflow/running-jobs/running-jobs.md".
        section: Leave it out to read the whole page. To read one part of it, a heading of that page such as "SLURM Mode": the section and the ones under it are returned. A long page comes back cut, with a list of its sections to ask for.

    Returns:
        The text of the page or section. A path or section that is not there is answered with the ones that are.

    """
    logger.info("SensAI read_docs: %s %s", path, section)
    return _read_docs(path, section)

read_settings

Python
read_settings(section: str = '') -> str

Reads the settings of MuJoCo Mojo: each one's key, the label the settings panel shows for it, the values it takes, its default and what it does.

Parameters:

Name Type Description Default
section str

Leave it out to list the sections. To read one, its name such as "dojo" or "dojo.sensai". To find settings by words instead, a few words such as "fullscreen" or "play a sound when the job ends".

''

Returns:

Type Description
str

The settings of that section, or the ones that match the words, and how to change a setting with a link to the settings panel. Nothing matched is answered with the list of sections.

Source code in src/mujoco_mojo/utils/layers/dojo/sensai/docs_agent.py
Python
@docs_agent.tool_plain
def read_settings(section: str = "") -> str:
    """
    Reads the settings of MuJoCo Mojo: each one's key, the label the settings panel shows for it, the values it takes, its default and what it does.

    Args:
        section: Leave it out to list the sections. To read one, its name such as "dojo" or "dojo.sensai". To find settings by words instead, a few words such as "fullscreen" or "play a sound when the job ends".

    Returns:
        The settings of that section, or the ones that match the words, and how to change a setting with a link to the settings panel. Nothing matched is answered with the list of sections.

    """
    found = _read_settings(section)
    logger.info("SensAI read_settings %r", section)
    return found