langchain-ai/langgraph · error · ValueError

A tool argument should not be annotated with

Error message

A tool argument should not be annotated with {injection_type.__name__} more than once. Found: {matches}

What it means

Annotation check in the injection-extraction helper (_find_injection): a single tool argument's type annotation contains the same injection marker (e.g. InjectedState, InjectedStore, InjectedToolArg) more than once. The injector cannot decide which occurrence to use, so it rejects the annotation.

Solutions

  1. Use each injection marker at most once per parameter annotation
  2. Move the second injection to a separate tool parameter
  3. Remove redundant wrapper types like Optional[InjectedState[X]] combined with another InjectedState occurrence
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1957 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/e725e5b636c97fee. Report an issue: GitHub.

Appendix: source

Thrown at libs/prebuilt/langgraph/prebuilt/tool_node.py:1957

) -> Any | None:
    """Extract injection instance from a type annotation.

    Args:
        type_: The type annotation to check.
        injection_type: The injection type to look for.

    Returns:
        The injection instance if found, True if injection marker found without instance, None otherwise.
    """
    type_args = get_args(type_)
    matches = [arg for arg in type_args if _is_injection(arg, injection_type)]

    if len(matches) > 1:
        msg = (
            f"A tool argument should not be annotated with {injection_type.__name__} "
            f"more than once. Found: {matches}"
        )
        raise ValueError(msg)

    if len(matches) == 1:
        return matches[0]
    elif _is_injection(type_, injection_type):
        return True

    return None


def _get_all_injected_args(tool: BaseTool) -> _InjectedArgs:
    """Extract all injected arguments from tool in a single pass.

    This function analyzes both the tool's input schema and function signature
    to identify all arguments that should be injected (state, store, runtime).

    Args:
        tool: The tool to analyze for injection requirements.

View on GitHub (pinned to 38031739e5)