langchain-ai/deepagents · error · RuntimeError

Approval-mode Store writer is unavailable

Error message

Approval-mode Store writer is unavailable

What it means

_require_approval_mode_key is a narrowing helper for the approval-mode Store writer: when the resolved writer is None it raises RuntimeError because manual approval decisions cannot be persisted without it. The function is a guard so downstream code can assume a non-None writer.

Source

Thrown at libs/code/deepagents_code/tui/textual_adapter.py:1343

            states a non-boolean. `None` means "unknown", which leaves the
            client's own view of pricing health untouched rather than
            overriding it with a guess.
    """
    if not isinstance(data, dict):
        return None
    pricing_ok = data.get("pricing_ok")
    return pricing_ok if isinstance(pricing_ok, bool) else None


def _require_approval_mode_key(value: str | None) -> str:
    """Return a written Store key for fail-closed startup.

    Raises:
        RuntimeError: If the remote agent has no Store writer.
    """
    if value is None:
        msg = "Approval-mode Store writer is unavailable"
        raise RuntimeError(msg)
    return value


class _AutoModeReviewEvent(NamedTuple):
    """Validated lifecycle event for one Auto classifier review."""

    phase: Literal["review_started", "review_completed"]
    batch_id: str
    tool_call_ids: tuple[str, ...]
    approved_tool_call_ids: tuple[str, ...]
    recovered: bool = False
    """Synthesized from a rejected completion, so its ID lists carry no meaning."""


def _opaque_ids(value: object, *, allow_empty: bool = False) -> tuple[str, ...] | None:
    """Validate an ordered list of unique opaque identifiers.

    Empty strings are rejected along with non-strings: an ID that cannot key a

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Ensure the session is started with a Store-backed agent so the approval-mode writer is registered.
  2. Check remote agent health/Store connectivity and restart the session if the Store dropped.
  3. Add a pre-flight check for Store availability before enabling approval-mode persistence, and surface a user-visible message instead of crashing mid-turn.
  4. Gate approval-mode persistence behind an optional fallback (in-memory) when the Store is absent.

Example fix

// before
writer = _require_approval_mode_key(resolve_writer(adapter))
// after
writer = resolve_writer(adapter)
if writer is None:
    adapter._update_status("Approval mode persistence unavailable (no Store)")
    return
writer = _require_approval_mode_key(writer)
Defensive patterns

Strategy: validation

Validate before calling

writer = resolve_store_writer(adapter)
if writer is None:
    raise SessionError("approval-mode Store writer unavailable; cannot persist approval mode")

Type guard

def has_store_writer(adapter: object) -> TypeGuard[AdapterWithStore]:
    return resolve_store_writer(adapter) is not None

Try / catch

try:
    _require_approval_mode_key(resolve_store_writer(adapter))
except RuntimeError:
    adapter._update_status("Store unavailable; approval persistence disabled")
    return

Prevention

When it happens

Trigger: execute_task_textual resolves the approval-mode Store writer and gets None — e.g. the remote agent's Store is unavailable/disconnected — and then tries to persist an approval-mode change.

Common situations: Remote agent sessions where the Store backend failed to initialize or dropped its connection; running with a configuration that never wires a Store writer; calling persistence paths outside a Store-enabled session.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/594aad482080cf4d. Report an issue: GitHub.