oraios/serena · error · FileNotFoundError

Internal mode '{from_internal}' not found in {SERENAS_OWN_MO

Error message

Internal mode '{from_internal}' not found in {SERENAS_OWN_MODE_YAMLS_DIR}. Available modes: {SerenaAgentMode.list_registered_mode_names()}

What it means

`serena mode create --from <internal-mode>` copies a bundled mode YAML from SERENAS_OWN_MODE_YAMLS_DIR as a template for a custom mode. If the requested internal mode yml does not exist in that directory, it raises FileNotFoundError listing all registered mode names. This prevents creating a custom mode from a nonexistent base.

Source

Thrown at src/serena/cli.py:550

        "--name",
        "-n",
        type=str,
        default=None,
        help="Name for the new mode. If --from-internal is passed may be left empty to create a mode of the same name, which will then override the internal mode.",
    )
    @click.option("--from-internal", "from_internal", type=str, default=None, help="Copy from an internal mode.")
    def create(name: str, from_internal: str) -> None:
        if not (name or from_internal):
            raise click.UsageError("Provide at least one of --name or --from-internal.")
        mode_name = name or from_internal
        dest = os.path.join(SerenaPaths().user_modes_dir, f"{mode_name}.yml")
        src = (
            os.path.join(SERENAS_OWN_MODE_YAMLS_DIR, f"{from_internal}.yml")
            if from_internal
            else os.path.join(SERENAS_OWN_MODE_YAMLS_DIR, "mode.template.yml")
        )
        if not os.path.exists(src):
            raise FileNotFoundError(
                f"Internal mode '{from_internal}' not found in {SERENAS_OWN_MODE_YAMLS_DIR}. Available modes: {SerenaAgentMode.list_registered_mode_names()}"
            )
        os.makedirs(os.path.dirname(dest), exist_ok=True)
        shutil.copyfile(src, dest)
        click.echo(f"Created mode '{mode_name}' at {dest}")
        _open_in_editor(dest)

    @staticmethod
    @click.command("edit", help="Edit a custom mode YAML file.", context_settings={"max_content_width": _MAX_CONTENT_WIDTH})
    @click.argument("mode_name")
    def edit(mode_name: str) -> None:
        path = os.path.join(SerenaPaths().user_modes_dir, f"{mode_name}.yml")
        if not os.path.exists(path):
            if mode_name in SerenaAgentMode.list_registered_mode_names(include_user_modes=False):
                click.echo(
                    f"Mode '{mode_name}' is an internal mode and cannot be edited directly. "
                    f"Use 'mode create --from-internal {mode_name}' to create a custom mode that overrides it before editing."
                )

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. List valid bases with the 'Available modes' names in the error, or inspect Serena's resources/config/modes directory, and retry with an exact name.
  2. Omit --from to start from the generic mode.template.yml.
  3. Reinstall Serena (pip install -U serena-agent / reinstall package) if resource files are missing; report a bug if the template itself is absent.

Example fix

// before
serena mode create my-mode --from interactiv-editing
// after
serena mode create my-mode --from interactive-editor   # or omit --from
Defensive patterns

Strategy: validation

Validate before calling

import os
from serena.constants import SERENAS_OWN_MODE_YAMLS_DIR
def internal_mode_exists(name: str) -> bool:
    src = os.path.join(SERENAS_OWN_MODE_YAMLS_DIR, f"{name}.yml")
    return os.path.exists(src)

Try / catch

try:
    create_mode(name, from_internal=base)
except FileNotFoundError:
    log.error('Unknown base mode %r; use one of %s or omit --from', base, SerenaAgentMode.list_registered_mode_names())

Prevention

When it happens

Trigger: Running `serena mode create <name> --from <internal>` where `<internal>.yml` is absent from Serena's own resources/src/resources/config/modes directory (typo or mode removed in a newer version); the fallback template mode.template.yml is also missing (broken installation).

Common situations: Typos in internal mode names (e.g. 'interactive-editor' misspelled); copying a command from an outdated tutorial for a mode that no longer ships; incomplete pip install where resource files are missing.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/2a1cd2609eea0228. Report an issue: GitHub.