Subgraphs with different state and communication between graphs

Topic 2 of 4 in Subgraphs & modular design23 min readAdvancedFree course

Overview

In the previous lesson, Subgraphs — reusable graph components, you learned how to construct smaller graphs and incorporate them into larger LangGraph workflows.

However, reusable components introduce an important architectural question: what happens when the parent graph and its subgraphs represent completely different kinds of information?

Consider an enterprise customer support system containing several specialized workflows:

  • A parent graph responsible for ticket orchestration.
  • A billing subgraph responsible for transaction analysis.
  • A technical support subgraph responsible for troubleshooting.
  • A compliance subgraph responsible for policy verification.
  • A response generation subgraph responsible for customer communication.

The billing workflow might require transaction amounts, invoice identifiers, and refund policies. Technical support might require device information, diagnostic results, and error codes.

Forcing every component to use one enormous state schema creates unnecessary dependencies, increases the amount of information processed, and makes independent development difficult.

LangGraph solves this problem by allowing a compiled subgraph to be invoked from inside a parent node. The parent node becomes an adapter that translates information between the two graphs.

This lesson focuses on designing those boundaries correctly, understanding nested execution, and communicating safely between independently structured workflows.

Environment setup

The examples use LangGraph 1.x, including the v2 streaming interface available from LangGraph 1.1 onward.

Terminal
pip install -U "langgraph>=1.1,<2" "langchain>=1,<2" typing-extensions

The examples deliberately use deterministic business logic rather than external language model calls. This isolates the graph mechanics, eliminates API costs, and makes the expected results reproducible.

Each complete Python example can be saved and run independently.

Calling a subgraph inside a node

A compiled LangGraph graph exposes an invoke() method. Because a parent node is an ordinary Python function, it can invoke another compiled graph while executing.

Instead of registering the compiled child directly, register a function that calls the child.

This function has three responsibilities:

  1. Construct the child’s input from the parent state.
  2. Execute the child workflow.
  3. Translate the child’s output into valid parent state updates.

This is commonly called the adapter pattern.

The following diagram illustrates the state translation boundary.

Calling a subgraph inside a node diagram: Parent State to Input Mapping; Validate Input to Analyze Request; Analyze Request to Child Output; Input Mapping to Validate Input; Child Output to Output Mapping; Output Mapping to Parent Update.

The parent controls what crosses the boundary. The child controls how its specialized work is performed.

Example 1: Independent billing workflow

This example creates a billing subgraph whose state fields have entirely different names from the parent’s state fields.

Python
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END

class BillingState(TypedDict, total=False):
    charge: float
    duplicate: bool
    validated_amount: float
    refund: float
    internal_reason: str

def validate_charge(state: BillingState):
    amount = state["charge"]

    if amount < 0:
        raise ValueError("Invalid transaction amount")

    return {"validated_amount": amount}

def calculate_refund(state: BillingState):
    refund = (
        state["validated_amount"]
        if state["duplicate"]
        else 0.0
    )

    return {
        "refund": refund,
        "internal_reason": "Duplicate charge policy",
    }

billing_graph = (
    StateGraph(BillingState)
    .add_node("validate", validate_charge)
    .add_node("calculate", calculate_refund)
    .add_edge(START, "validate")
    .add_edge("validate", "calculate")
    .add_edge("calculate", END)
    .compile()
)

class SupportState(TypedDict, total=False):
    ticket_id: str
    payment_amount: float
    repeated_payment: bool
    approved_refund: float
    customer_response: str

def billing_adapter(state: SupportState):
    child_input = {
        "charge": state["payment_amount"],
        "duplicate": state["repeated_payment"],
    }

    child_output = billing_graph.invoke(child_input)

    return {
        "approved_refund": child_output["refund"],
    }

def prepare_response(state: SupportState):
    amount = state["approved_refund"]

    response = (
        f"You are eligible for a refund of ${amount:.2f}."
        if amount > 0
        else "No refund is applicable."
    )

    return {"customer_response": response}

support_graph = (
    StateGraph(SupportState)
    .add_node("billing", billing_adapter)
    .add_node("respond", prepare_response)
    .add_edge(START, "billing")
    .add_edge("billing", "respond")
    .add_edge("respond", END)
    .compile()
)

result = support_graph.invoke({
    "ticket_id": "SUP-101",
    "payment_amount": 120.0,
    "repeated_payment": True,
})

print(result["approved_refund"])
print(result["customer_response"])
print("internal_reason" in result)

Expected output:

Text
120.0
You are eligible for a refund of $120.00.
False

The billing subgraph determines eligibility; it does not execute a financial transaction.

Understanding nested execution internally

When the parent reaches billing_adapter, the following sequence occurs:

  1. The parent runtime schedules the adapter node.
  2. The adapter receives the parent state snapshot.
  3. The adapter constructs a dictionary matching the child schema.
  4. The compiled child graph executes its own nodes and edges.
  5. The child produces its final output.
  6. The adapter returns selected fields as a parent state update.
  7. The parent runtime applies those updates and schedules the next node.

The child has its own state channels, node transitions, reducers, and execution lifecycle.

Its intermediate updates do not automatically become parent updates. In normal completion, the parent receives the information explicitly returned by the adapter.

The synchronous invoke() call also means that downstream parent nodes dependent on the adapter cannot continue until the child finishes or execution is suspended.

This is nested graph execution, not a separate background process or remote service.

For asynchronous workflows, use an asynchronous adapter with await child_graph.ainvoke(child_input) rather than blocking the event loop with synchronous execution.

Shared vs independent schemas

LangGraph supports two primary approaches to integrating subgraphs.

Shared state schemas

When a parent and child share compatible state keys, the compiled subgraph can be registered directly as a parent node.

For example, both graphs might contain a messages channel or a ticket_status channel.

Their complete schemas do not need to be identical. A child may maintain additional internal channels that are absent from the parent.

Direct registration is useful when the shared fields already represent a suitable communication interface.

Independent state schemas

When the parent and child have unrelated fields, or when their field semantics differ, use a wrapper node.

The wrapper performs explicit transformations rather than relying on matching names.

Characteristic Shared schema Independent schema
Integration Register compiled graph directly Invoke graph inside a wrapper
Communication Common state channels Explicit input and output mapping
Coupling Higher Lower
Schema evolution Coordinate shared fields Maintain boundary contracts
Data transformation Usually unnecessary Fully customizable
Private child fields Supported Supported with explicit isolation
Typical use Unified workflow stages Specialized agents and services

Choose based on the desired contract, not simply whether two schemas happen to contain matching field names.

Two fields named status may have entirely different meanings. A billing status such as eligible should not accidentally overwrite a customer ticket status such as open.

Reducers across graph boundaries

Reducers determine how state updates are merged.

For example, a list channel without a reducer normally replaces its previous value. A list channel using Annotated[list[str], operator.add] accumulates returned items.

When child results cross into the parent, the parent’s reducer determines how those updates are applied.

If the parent accumulates evidence and the wrapper returns both previously collected evidence and new evidence, existing entries can be duplicated.

Return only the new items expected by the parent reducer.

For conversational state, MessagesState and add_messages provide message-aware merging. Preserve appropriate message IDs when updating existing messages, and maintain valid tool-call and tool-result relationships.

Independent schemas are particularly helpful when different agents require different conversation histories. A specialist can maintain a private working history while exposing only a final recommendation.

Communication between graphs

Communication should be designed as an explicit application interface rather than an unrestricted exchange of dictionaries.

A useful distinction is between the child’s internal state and its public contract.

The internal state represents everything necessary to execute the workflow. The public contract represents only what callers need to provide and receive.

Defining explicit input and output schemas

StateGraph accepts input_schema and output_schema in addition to its internal state schema.

This allows a child graph to declare:

  • Required information from callers.
  • Intermediate information available to its own nodes.
  • Information returned after execution.

An output schema is particularly valuable when a specialist handles sensitive information or complex intermediate calculations.

Example 2: Communication between specialized subgraphs

The following example creates two independent subgraphs. A diagnostic graph identifies a technical problem, and a knowledge graph produces a recommended solution.

Neither child directly depends on the other. The parent coordinates their communication.

Python
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END

class DiagnosticInput(TypedDict):
    symptom: str

class DiagnosticOutput(TypedDict):
    issue_code: str

class DiagnosticState(TypedDict, total=False):
    symptom: str
    issue_code: str
    internal_diagnostic: str

def diagnose(state: DiagnosticState):
    issue = (
        "AUTH_FAILURE"
        if "login" in state["symptom"].lower()
        else "GENERAL"
    )

    return {
        "issue_code": issue,
        "internal_diagnostic": "Rule engine completed",
    }

diagnostic_graph = (
    StateGraph(
        DiagnosticState,
        input_schema=DiagnosticInput,
        output_schema=DiagnosticOutput,
    )
    .add_node("diagnose", diagnose)
    .add_edge(START, "diagnose")
    .add_edge("diagnose", END)
    .compile()
)

class KnowledgeState(TypedDict, total=False):
    search_key: str
    recommendation: str

def search_knowledge(state: KnowledgeState):
    articles = {
        "AUTH_FAILURE": "Reset your password and retry.",
        "GENERAL": "Contact technical support.",
    }

    return {
        "recommendation": articles.get(
            state["search_key"],
            "Escalate to a specialist.",
        )
    }

knowledge_graph = (
    StateGraph(KnowledgeState)
    .add_node("search", search_knowledge)
    .add_edge(START, "search")
    .add_edge("search", END)
    .compile()
)

class SupportState(TypedDict, total=False):
    customer_query: str
    diagnosis: str
    resolution: str

def call_diagnostic(state: SupportState):
    result = diagnostic_graph.invoke({
        "symptom": state["customer_query"]
    })

    return {"diagnosis": result["issue_code"]}

def call_knowledge(state: SupportState):
    result = knowledge_graph.invoke({
        "search_key": state["diagnosis"]
    })

    return {"resolution": result["recommendation"]}

support_graph = (
    StateGraph(SupportState)
    .add_node("diagnostic", call_diagnostic)
    .add_node("knowledge", call_knowledge)
    .add_edge(START, "diagnostic")
    .add_edge("diagnostic", "knowledge")
    .add_edge("knowledge", END)
    .compile()
)

result = support_graph.invoke({
    "customer_query": "I cannot login to my account."
})

print(result)

Expected output:

Text
{
    'customer_query': 'I cannot login to my account.',
    'diagnosis': 'AUTH_FAILURE',
    'resolution': 'Reset your password and retry.'
}

The first child exports an issue code. The parent translates that code into the second child’s input.

This avoids direct dependencies between specialized components and allows either child to be replaced without redesigning the other.

Parent-mediated communication and handoffs

There are several ways to coordinate information across graphs.

Communication mechanism Appropriate use
Wrapper return values Transfer results between independent graphs
Shared state channels Coordinate closely related workflows
Runtime context Supply request-scoped dependencies
Store Share durable information across executions
Command.PARENT Navigate from a child to an immediate parent node

Command.PARENT provides a more specialized control-flow mechanism. A child node can return a Command targeting a named node in its immediate parent graph, optionally including state updates.

This is useful for agent handoffs, such as transferring control from a billing specialist to a supervisor.

However, it creates a dependency on the parent’s node names and state contract. When updating a field shared by both graphs through Command.PARENT, define the appropriate reducer in the parent.

For independently reusable components, prefer returning a business outcome such as requires_escalation and allowing the parent to select the next destination.

Passing runtime context safely

Not every dependency belongs in graph state.

Tenant identifiers, authenticated principals, service clients, and request-scoped settings can be supplied through runtime context.

Define a context_schema for graphs that require these dependencies and access them through Runtime.

The following example explicitly forwards a validated context into an independently structured child graph.

Python
from dataclasses import dataclass
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.runtime import Runtime

@dataclass(frozen=True)
class Context:
    tenant_id: str

class ChildState(TypedDict, total=False):
    article_code: str
    article_text: str

def lookup_article(
    state: ChildState,
    runtime: Runtime[Context],
):
    articles = {
        ("acme", "LOGIN"): "Use the Acme SSO portal.",
        ("globex", "LOGIN"): "Use the Globex login page.",
    }

    key = (
        runtime.context.tenant_id,
        state["article_code"],
    )

    return {
        "article_text": articles.get(key, "Not found")
    }

child_graph = (
    StateGraph(ChildState, context_schema=Context)
    .add_node("lookup", lookup_article)
    .add_edge(START, "lookup")
    .add_edge("lookup", END)
    .compile()
)

class ParentState(TypedDict, total=False):
    topic: str
    answer: str

def call_child(
    state: ParentState,
    runtime: Runtime[Context],
):
    result = child_graph.invoke(
        {"article_code": state["topic"]},
        context=Context(
            tenant_id=runtime.context.tenant_id
        ),
    )

    return {"answer": result["article_text"]}

parent_graph = (
    StateGraph(ParentState, context_schema=Context)
    .add_node("delegate", call_child)
    .add_edge(START, "delegate")
    .add_edge("delegate", END)
    .compile()
)

result = parent_graph.invoke(
    {"topic": "LOGIN"},
    context=Context(tenant_id="acme"),
)

print(result["answer"])

Expected output:

Text
Use the Acme SSO portal.

In production, establish tenant identity through trusted authentication infrastructure rather than accepting arbitrary tenant identifiers from user messages. Runtime context transports identity; it does not authenticate it.

Note: Schema isolation is not a security sandbox. Child state may still appear in checkpoints, diagnostic streams, or traces. Enforce authorization, data minimization, and appropriate retention policies separately.

Interrupts inside subgraphs

A specialized workflow may require human approval before completing.

Examples include approving a refund, reviewing an account suspension, or authorizing a sensitive data change.

A subgraph can call interrupt() even when invoked from inside a parent wrapper node.

With an appropriate inherited checkpointer, the nested interruption propagates to the root graph. The application can resume the workflow through the parent without manually invoking the interrupted child.

Example 3: Nested refund approval

This example demonstrates how a child graph requests approval and returns the decision through an adapter.

Python
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.types import Command, interrupt

class ReviewState(TypedDict, total=False):
    requested_amount: float
    decision: bool

def request_approval(state: ReviewState):
    print("Child approval node entered")

    approved = interrupt({
        "action": "approve_refund",
        "amount": state["requested_amount"],
        "question": "Approve this refund?",
    })

    if not isinstance(approved, bool):
        raise ValueError("Approval must be a boolean")

    return {"decision": approved}

review_graph = (
    StateGraph(ReviewState)
    .add_node("approval", request_approval)
    .add_edge(START, "approval")
    .add_edge("approval", END)
    .compile()
)

class SupportState(TypedDict, total=False):
    ticket_id: str
    refund_amount: float
    approved: bool
    status: str

def call_review(state: SupportState):
    print("Parent wrapper entered")

    result = review_graph.invoke({
        "requested_amount": state["refund_amount"]
    })

    return {"approved": result["decision"]}

def finalize(state: SupportState):
    return {
        "status": (
            "Approved"
            if state["approved"]
            else "Rejected"
        )
    }

support_graph = (
    StateGraph(SupportState)
    .add_node("review", call_review)
    .add_node("finalize", finalize)
    .add_edge(START, "review")
    .add_edge("review", "finalize")
    .add_edge("finalize", END)
    .compile(checkpointer=InMemorySaver())
)

config = {
    "configurable": {
        "thread_id": "refund-ticket-501"
    }
}

paused = support_graph.invoke({
    "ticket_id": "T-501",
    "refund_amount": 250.0,
}, config)

print("Pending:", paused["__interrupt__"][0].value)

completed = support_graph.invoke(
    Command(resume=True),
    config,
)

print("Final status:", completed["status"])

Expected output:

Text
Parent wrapper entered
Child approval node entered
Pending: {'action': 'approve_refund', 'amount': 250.0,
          'question': 'Approve this refund?'}
Parent wrapper entered
Child approval node entered
Final status: Approved

The repeated print statements reveal an essential property of nested interrupts: execution restarts at node boundaries.

What happens during resumption?

The following diagram illustrates the nested interruption lifecycle.

Interrupts inside subgraphs diagram: START to Parent Wrapper; Parent Wrapper to Child Approval Node; Child Approval Node to Decision Available?; Decision Available? to Save Checkpoint (No); Save Checkpoint to Human Review; Human Review to Parent Wrapper (Resume); Decision Available? to Child Result (Yes); Child Result to Parent Update; Parent Update to END.

When the interruption occurs, the parent invocation returns with pending interrupt information.

On resumption:

  1. LangGraph loads the relevant execution checkpoint.
  2. The parent wrapper starts again.
  3. The child invocation is re-entered.
  4. The interrupted child node starts again.
  5. The corresponding interrupt() returns the supplied resume value.
  6. Normal execution continues.

Completed child steps preserved by checkpointing need not be executed again.

This differs from preserving a live Python call stack. Local variables and instructions preceding the interruption may be reconstructed or repeated.

Preventing duplicate side effects

Suppose the wrapper charges a customer’s payment method immediately before invoking the approval subgraph.

Because the wrapper restarts on resume, that charge could be attempted again.

The same risk applies to sending emails, creating database records, publishing events, and calling external APIs.

Keep pre-interrupt operations deterministic or idempotent. Separate irreversible actions into appropriately governed nodes and use stable idempotency keys at external service boundaries.

Do not swallow the internal interrupt signal with a broad try/except around the child invocation.

Tip: Resume using the root graph, the original thread ID, and Command(resume=...). Authenticate the approver, validate the response, and recheck authorization before performing any sensitive action.

For concurrent pending interrupts, use an interrupt-ID-to-resume-value mapping to associate each response with the correct interrupted operation.

Pitfall: Calling the same subgraph twice in one node

A wrapper function may appear to be a convenient place to call the same specialist repeatedly.

For example, imagine a policy evaluation subgraph that must assess two different documents.

The problem is that repeated nested calls are not always equivalent to calling an ordinary stateless Python function twice.

When checkpointing is enabled, the runtime must associate each child execution with the correct checkpoint namespace.

A namespace identifies where a nested execution’s checkpoint data belongs.

Why repeated invocations can cause problems

Consider a wrapper that invokes a stateful child twice.

The child may retain messages, intermediate results, or pending interruptions across invocations.

If those calls use conflicting namespaces, their state can interfere with each other.

Current LangGraph 1.x behavior depends on the child’s compilation mode.

Child compilation Repeated invocation behavior
compile() Fresh child execution per invocation; inherits parent checkpointing when available
compile(checkpointer=True) Retains child state across invocations; requires careful namespace management
compile(checkpointer=False) Disables child checkpointing; unsuitable for resumable nested interrupts

The default inherited mode supports repeated independent invocations and gives them separate execution namespaces.

With continuation mode, checkpointer=True, namespace conflicts can occur, particularly with parallel calls. Current implementations may distinguish sequential calls by their invocation position, but changing call order can make that association unstable.

The MULTIPLE_SUBGRAPHS error concerns conflicting repeated stateful child invocations. It does not mean that every repeated subgraph call is prohibited.

Example 4: Separate named wrapper nodes

A robust architectural approach is to assign each logically distinct child invocation its own named parent node.

The following example evaluates two independently supplied transaction amounts using the same compiled child graph.

Python
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END
from langgraph.checkpoint.memory import InMemorySaver

class PolicyState(TypedDict, total=False):
    amount: float
    risk: str

def evaluate_policy(state: PolicyState):
    return {
        "risk": (
            "HIGH"
            if state["amount"] >= 1000
            else "LOW"
        )
    }

policy_graph = (
    StateGraph(PolicyState)
    .add_node("evaluate", evaluate_policy)
    .add_edge(START, "evaluate")
    .add_edge("evaluate", END)
    .compile()
)

class ParentState(TypedDict, total=False):
    first_amount: float
    second_amount: float
    first_risk: str
    second_risk: str

def assess_first(state: ParentState):
    result = policy_graph.invoke({
        "amount": state["first_amount"]
    })

    return {"first_risk": result["risk"]}

def assess_second(state: ParentState):
    result = policy_graph.invoke({
        "amount": state["second_amount"]
    })

    return {"second_risk": result["risk"]}

graph = (
    StateGraph(ParentState)
    .add_node("first_assessment", assess_first)
    .add_node("second_assessment", assess_second)
    .add_edge(START, "first_assessment")
    .add_edge("first_assessment", "second_assessment")
    .add_edge("second_assessment", END)
    .compile(checkpointer=InMemorySaver())
)

result = graph.invoke({
    "first_amount": 300,
    "second_amount": 1500,
}, {
    "configurable": {
        "thread_id": "assessment-001"
    }
})

print(result["first_risk"])
print(result["second_risk"])

Expected output:

Text
LOW
HIGH

Each wrapper has a distinct node identity and writes to a different parent field.

This improves observability and gives the parent runtime separate execution boundaries for checkpointing, retries, and recovery.

A single wrapper can still invoke the default per-invocation child repeatedly when appropriate. Separate nodes are preferable when each call represents a meaningful workflow stage.

For dynamic collections of independent tasks, consider the Send API with per-invocation child persistence and carefully designed result reducers.

Observing communication across graph boundaries

The parent graph’s final output may not reveal everything that happened inside its children.

During development, enable nested streaming to inspect intermediate updates.

Using the graph and config structure from the preceding example, run a new execution as follows:

Python
stream_config = {
    "configurable": {
        "thread_id": "assessment-stream-001"
    }
}

for chunk in graph.stream(
    {
        "first_amount": 300,
        "second_amount": 1500,
    },
    stream_config,
    subgraphs=True,
    stream_mode=["updates"],
    version="v2",
):
    print("Namespace:", chunk["ns"])
    print("Type:", chunk["type"])
    print("Data:", chunk["data"])

The root namespace is an empty tuple. Nested events include a namespace identifying the child execution.

Expect to see internal evaluate updates alongside parent updates from first_assessment and second_assessment.

This helps locate incorrect state mappings and understand which graph generated a particular update.

Do not expose unrestricted nested streams directly to customers. Streamed intermediate results may contain information deliberately excluded from the final parent output.

Common mistakes and best practices

Returning the entire child state

Avoid returning the complete child output simply because it is available.

Explicitly select and translate fields. This prevents accidental data exposure and unwanted updates to overlapping parent channels.

Treating TypedDict as runtime validation

TypedDict describes expected dictionary structure for typing purposes; it does not independently validate untrusted inputs at runtime.

Use explicit validation or Pydantic models at important application boundaries.

Mutating shared objects

Do not rely on directly modifying nested dictionaries or lists from parent state inside a child.

Construct intentional inputs, copy mutable structures when necessary, and return explicit state updates.

Overcoupling specialized agents

Avoid giving every subgraph access to the entire ticket, conversation history, and application configuration.

Pass only the information required for the specialist’s responsibility.

Ignoring failures at graph boundaries

Define expected business outcomes separately from unexpected execution failures.

For example, REFUND_NOT_ELIGIBLE is a valid result, while an unavailable transaction database is an operational error.

Do not convert every exception into a successful-looking recommendation.

Designing production-grade modular applications

For the upcoming enterprise customer support project, establish clear ownership of state before writing orchestration logic.

The parent should own ticket identity, routing decisions, customer-facing responses, and overall resolution status.

Specialized children should own domain-specific processing, intermediate evidence, and internal workflow decisions.

Keep communication contracts small, stable, documented, and versionable. Ensure that each child can be invoked independently with realistic test inputs.

The previous lesson established the mechanics of reusable subgraphs. This lesson introduces the explicit interfaces that allow those components to evolve independently.

The next lesson, Subgraph persistence and testing subgraphs, will build on these interfaces by examining checkpoint inheritance, persistent child state, state inspection, and independent testing strategies.

Further technical references

The examples use the documented LangGraph 1.x interfaces and deterministic demonstration data. Expected outputs are derived from the example logic; the examples have not been executed in a live LangGraph environment for this lesson.

Exercise

Build an Independent Billing Subgraph

Build a customer support parent graph that delegates billing analysis to a subgraph with an independent state schema. Translate the parent ticket into the billing subgraph's input, calculate refund eligibility, and return only the approved output fields to the parent. Ensure that internal billing information remains outside the parent state and that repeated requests produce independent results.

Python
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END


class SupportState(TypedDict, total=False):
    ticket_id: str
    amount_paid: float
    duplicate_charge: bool
    resolution: str
    refund_amount: float


class BillingState(TypedDict, total=False):
    transaction_amount: float
    is_duplicate: bool
    eligible: bool
    calculated_refund: float
    internal_policy: str


def analyze_billing(state: BillingState):
    # TODO: Determine refund eligibility.
    # TODO: Calculate the refund amount.
    raise NotImplementedError


# TODO: Build and compile the billing subgraph.


def call_billing(state: SupportState):
    # TODO: Translate parent state into billing state.
    # TODO: Invoke the billing subgraph.
    # TODO: Return only resolution and refund_amount.
    raise NotImplementedError


# TODO: Build and compile the parent graph.

# Test input:
ticket = {
    "ticket_id": "T-1001",
    "amount_paid": 149.0,
    "duplicate_charge": True,
}

# Expected resolution: Refund eligible
# Expected refund_amount: 149.0

Summary

  • Independent state schemas allow parent and child graphs to evolve without exposing their internal implementation details.
  • A wrapper node explicitly translates parent state into child input and child output into parent state updates.
  • Subgraph input and output schemas establish clear communication contracts while keeping intermediate state internal.
  • Parent-mediated communication reduces coupling between specialized agents and simplifies orchestration.
  • Nested interrupts restart both the interrupted child node and the parent wrapper node during resumption.
  • Repeated subgraph invocations require careful checkpoint namespace management, especially when retaining state across calls.
  • State isolation improves modularity but must be combined with authorization, validation, and secure observability practices.