{"record":{"id":"1e331628ae3adf2a","repo":"langchain-ai/deepagents","slug":"mode-prefixes-and-mode-display-glyphs-have-mismatc","errorCode":null,"errorMessage":"MODE_PREFIXES and MODE_DISPLAY_GLYPHS have mismatched keys: only in PREFIXES={_only_prefixes}, only in GLYPHS={_only_glyphs}","messagePattern":"MODE_PREFIXES and MODE_DISPLAY_GLYPHS have mismatched keys: only in PREFIXES=(.+?), only in GLYPHS=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"libs/code/deepagents_code/config.py","lineNumber":1480,"sourceCode":"    \"command\": \"/\",\n}\n\"\"\"Maps each non-normal mode to its trigger character.\"\"\"\n\nMODE_DISPLAY_GLYPHS: dict[str, str] = {\n    \"shell_incognito\": \"$\",\n    \"shell\": \"$\",\n    \"command\": \"/\",\n}\n\"\"\"Maps each non-normal mode to its display glyph shown in the prompt/UI.\"\"\"\n\nif MODE_PREFIXES.keys() != MODE_DISPLAY_GLYPHS.keys():\n    _only_prefixes = MODE_PREFIXES.keys() - MODE_DISPLAY_GLYPHS.keys()\n    _only_glyphs = MODE_DISPLAY_GLYPHS.keys() - MODE_PREFIXES.keys()\n    msg = (\n        \"MODE_PREFIXES and MODE_DISPLAY_GLYPHS have mismatched keys: \"\n        f\"only in PREFIXES={_only_prefixes}, only in GLYPHS={_only_glyphs}\"\n    )\n    raise ValueError(msg)\n\n_MODE_PREFIXES_BY_LENGTH: tuple[tuple[str, str], ...] = tuple(\n    sorted(MODE_PREFIXES.items(), key=lambda item: len(item[1]), reverse=True)\n)\n\"\"\"Mode entries ordered longest-prefix-first.\n\nPre-sorted at import so `detect_mode_prefix` runs in constant time per\nkeystroke without re-sorting.\n\"\"\"\n\n\ndef detect_mode_prefix(text: str) -> tuple[str, str] | None:\n    \"\"\"Return the longest mode prefix and mode for `text`, if any.\n\n    Longer prefixes win so multi-character triggers like `!!` are matched\n    before their single-character prefixes (`!`).\n\n    Args:","sourceCodeStart":1462,"sourceCodeEnd":1498,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/config.py#L1462-L1498","documentation":"At import time, config.py verifies that MODE_PREFIXES and MODE_DISPLAY_GLYPHS define exactly the same mode keys, raising ValueError on any difference. This is an internal consistency check guarding the developer-mode UI: every mode prefix must have a display glyph and vice versa.","triggerScenarios":"Adding an entry to MODE_PREFIXES (or MODE_DISPLAY_GLYPHS) without the matching entry in the other dict, renaming a mode key in only one, or editing a fork/patch of config.py asymmetrically.","commonSituations":"Contributing a new agent mode to the coding agent and forgetting the glyph, a merge conflict resolved in only one dict, or a plugin monkeypatching one mapping at import time.","solutions":["Add the missing key to the other mapping so both dicts share the identical key set.","If the mode was removed, delete its entry from both MODE_PREFIXES and MODE_DISPLAY_GLYPHS.","If you see this after an upgrade without local edits, report it as a release bug and pin the previous version."],"exampleFix":"// before\nMODE_PREFIXES = {\"plan\": \"plan\", \"code\": \"code\", \"review\": \"review\"}\nMODE_DISPLAY_GLYPHS = {\"plan\": \"*\", \"code\": \">\"}  # 'review' missing\n// after\nMODE_DISPLAY_GLYPHS = {\"plan\": \"*\", \"code\": \">\", \"review\": \"~\"}","handlingStrategy":"validation","validationCode":"# run in tests\ndef assert_mode_maps_consistent(prefixes: dict, glyphs: dict) -> None:\n    assert prefixes.keys() == glyphs.keys(), prefixes.keys() ^ glyphs.keys()","typeGuard":null,"tryCatchPattern":"try:\n    import deepagents_code.config as config\nexcept ValueError as e:\n    raise RuntimeError(\"mode mappings out of sync; check MODE_PREFIXES vs MODE_DISPLAY_GLYPHS\") from e","preventionTips":["When adding/removing a mode, update both MODE_PREFIXES and MODE_DISPLAY_GLYPHS in the same commit","Add a unit test asserting the two key sets are equal","Resolve merge conflicts in config.py by checking both mappings, not just one"],"tags":["import-time","internal-consistency","config"],"backgroundTag":"mismatched-key-sets","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}