langchain-ai/deepagents · error · ValueError

Unsupported hook event: {event}

Error message

Unsupported hook event: {event}

What it means

`_decision` converts the accumulated reduction state into the final typed decision object for the hook event. Its exhaustive branch table covers each `HookEvent` member; if an event falls through, it raises `ValueError`, meaning an event kind reached the reducer that has no decision mapping.

Source

Thrown at libs/code/deepagents_code/hooks/reducer.py:547

            feedback=state.feedback,
            context=state.context,
            **common,
        )
    if event is HookEvent.PRE_COMPACT:
        return PreCompactDecision(event=event, **common)
    if event is HookEvent.STOP:
        return StopDecision(
            event=event,
            continue_loop=state.continue_loop,
            feedback=state.feedback,
            **common,
        )
    if event is HookEvent.SUBAGENT_START:
        return SubagentStartDecision(event=event, context=state.context, **common)
    if event is HookEvent.SUBAGENT_STOP:
        return SubagentStopDecision(event=event, context=state.context, **common)
    msg = f"Unsupported hook event: {event}"
    raise ValueError(msg)


def _append(values: list[str], value: str | None) -> None:
    if value is not None:
        values.append(value)


def _loop_guard_diagnostic() -> HookDiagnostic:
    return HookDiagnostic(
        code="continuation_guard",
        severity="warning",
        message="Ignored recursive stop-hook continuation",
    )

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Reduce only supported HookEvent values; map/filter unknown events before calling `reduce_hook_results`
  2. Add a branch in `_decision` returning the appropriate decision object if the event is a legitimate new kind
  3. Align package versions so enum and reducer come from the same release

Example fix

// before
reduce_hook_results(results, HookEvent("PreToolUseX"))
// after
if event in SUPPORTED_EVENTS:
    reduce_hook_results(results, event)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_EVENTS = set(HookEvent)
if event not in SUPPORTED_EVENTS:
    raise ValueError(f"event not reducible: {event}")

Try / catch

try:
    decision = reduce_hook_results(results, event)
except ValueError as e:
    logger.warning("unsupported hook event in reducer: %s", e)

Prevention

When it happens

Trigger: Calling `reduce_hook_results` (via `_decision`) with a `HookEvent` not handled by the branch table — a newly added enum member, a custom event kind, or code paths constructing HookEvent values outside the supported set.

Common situations: Library version skew where an event enum was extended without updating `_decision`; tests feeding synthetic HookEvent values into the reducer; forwarding raw event names from external config into the reducer.

Related errors


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