Skip to content

Utilities API Reference

Classes:

NamespaceTemplate

Utility for templating namespace strings from configuration.

Takes a namespace template with optional variables in curly braces and substitutes values from the RunnableConfig's 'configurable' field.

Examples

Basic fixed namespace.

ns = NamespaceTemplate("user_123")
ns()  # Returns: ('user_123',)

Variable namespaceing. This will substitute values from the 'configurable' field in the RunnableConfig.

ns = NamespaceTemplate(("org", "{user_id}"))
ns({"configurable": {"user_id": "alice"}})
# Returns: ('org', 'alice')

If called within a "Runnable" context (e.g., in a langgraph instance), the 'configurable' field will be automatically retrieved from the context.

from langgraph.func import entrypoint

ns = NamespaceTemplate(("org", "{user_id}"))


@entrypoint()
def my_agent(messages):
    print(ns({"configurable": {"user_id": "alice"}}))


my_agent.invoke([])
# Returns: ('org', 'alice')

Functions:

  • ReflectionExecutor

    Create a reflection executor for either local or remote execution.

ReflectionExecutor

ReflectionExecutor(
    reflector: Runnable | str,
    namespace: str | tuple[str, ...] | None = None,
    /,
    *,
    url: Optional[str] = None,
    client: Optional[LangGraphClient] = None,
    sync_client: Optional[SyncLangGraphClient] = None,
    store: Optional[BaseStore] = None,
) -> Executor

Create a reflection executor for either local or remote execution.

Parameters:

  • namespace (str | tuple[str, ...] | None, default: None ) –

    A string to identify the reflection domain (e.g. "user:123").

  • reflector (Runnable | str) –

    Either a callable that implements the reflection logic or a string that names a remote graph.

  • url (Optional[str], default: None ) –

    Optional URL for remote processing.

  • client (Optional[LangGraphClient], default: None ) –

    Optional LangGraph client for remote processing.

  • sync_client (Optional[SyncLangGraphClient], default: None ) –

    Optional sync LangGraph client for remote processing.

  • store (Optional[BaseStore], default: None ) –

    Required store for local processing.

Returns:

  • Executor

    Either a LocalReflectionExecutor or RemoteReflectionExecutor based on the reflector type.

Comments