Skip to main content

enterprise_ai.runtime.langgraph

Source: sdks/python/src/enterprise_ai/runtime/langgraph.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Functions​

initial_state​

initial_state(task: Any = None, system: str | None = None, messages: list[dict[str, Any]] | None = None) -> dict[str, Any]

Graph input: the messages of the turn.

NameTypeDefaultRequiredDescription
taskAnyNonenoTask appended as the last user message (converted to text).
systemstr | NoneNonenoSystem prompt inserted as the first message.
messageslist[dict[str, Any]] | NoneNonenoMessages that already open the turn; empty by default.

Returns: dict[str, Any]. Dict {"messages": [...]} used as graph input.

turn_node​

turn_node(runner: AgentRunner) -> Any

The graph node: one :meth:AgentRunner.run_turn over state["messages"].

NameTypeDefaultRequiredDescription
runnerAgentRunneryesNavin runner that executes the turn.

Returns: Any. Function state -> dict that runs one turn, or resumes state["resume"], and returns TurnResult.state().

to_result​

to_result(state: dict[str, Any]) -> TurnResult

Rebuild a :class:TurnResult from the graph output.

NameTypeDefaultRequiredDescription
statedict[str, Any]yesGraph output in the TurnResult.state() format (messages, step, final, stop_reason...).

Returns: TurnResult. A TurnResult: Outcome of :meth:AgentRunner.run_turn.

build_graph​

build_graph(runner: AgentRunner) -> Any

A langgraph.graph.StateGraph (not compiled): START -> turn -> END.

NameTypeDefaultRequiredDescription
runnerAgentRunneryesNavin runner whose run_turn is the single turn node.

Returns: Any. Uncompiled StateGraph to compile with a LangGraph checkpointer; raises an error naming the langgraph extra when LangGraph is missing.

run_without_langgraph​

run_without_langgraph(runner: AgentRunner, task: Any = None, system: str | None = None, messages: list[dict[str, Any]] | None = None) -> TurnResult

Run the same single-node graph without LangGraph installed.

NameTypeDefaultRequiredDescription
runnerAgentRunneryesNavin runner that executes the turn.
taskAnyNonenoTask appended as the last user message.
systemstr | NoneNonenoSystem prompt inserted as the first message.
messageslist[dict[str, Any]] | NoneNonenoMessages that already open the turn.

Returns: TurnResult. A TurnResult: Outcome of :meth:AgentRunner.run_turn.