liveBook · Manning

Multi-step orchestration

As explained in Designing AI Systems

Multi-step orchestration is the coordination of a sequence of dependent AI workflow steps with step-specific capabilities, error handling, and recovery.

Multi-step orchestration coordinates dependent AI workflow steps, each with its own capabilities and failure modes. A production workflow may need document analysis, policy checks, calculations, approvals, and external system updates—not just a single model call. It must carry state between steps and recover when one fails. section 1.3

A Workflow Service can separate business logic from execution coordination. A workflow definition describes the operations, while the service manages state, retries, and failure recovery across sequential and parallel steps. This avoids rebuilding coordination logic for every application. section 1.4 section 2.1.8

Patient intake pipeline

A patient intake workflow validates the question, retrieves conversation history and clinic policies, generates a response with tools available, executes any requested tool calls, validates the output, and persists the exchange. Input guardrails can stop an unsafe request; output guardrails can trigger sanitization or regeneration. A knowledge search timeout should be retried, while observability should expose step duration, failures, and total workflow cost. section 2.1.7

Listing 2.9 Multi-step workflow coordinating all platform services
@workflow(name="patient_intake")    #A
def handle_patient_question(    #A
    question,    #A
    patient_id,    #A
    session_id    #A
):    #A
 
    session = platform.sessions.get_or_create(    #B
        patient_id, session_id    #B
    )    #B
 
    safety_check = platform.guardrails.validate_input(    #C
        question,    #C
        checks=["no_medical_advice"]    #C
    )    #C
    if not safety_check["allowed"]:    #C
        return {"response": safety_check["denial_reason"]}    #C
 
    prompt = platform.models.get_prompt("patient_intake")    #D
    conversation_history, _ = platform.sessions.get_messages(    #D
        session_id, limit=10    #D
    )    #D
    history_messages = [    #D
        {"role": m.role, "content": m.content}    #D
        for m in conversation_history    #D
    ]    #D
 
    relevant_info = platform.data.search(    #E
        query=question,    #E
        index_name="patient_procedures"    #E
    )    #E
    policy_text = "\n".join(    #E
        r.text for r in relevant_info    #E
    )    #E
 
    messages = history_messages + [    #F
        {"role": "system", "content": prompt["content"]},    #F
        {"role": "system",    #F
         "content": f"Relevant clinic policies:\n{policy_text}"},    #F
        {"role": "user", "content": question}    #F
    ]    #F
 
    tools, _ = platform.tools.build_model_tools(    #G
        names=["appointment_scheduler"]    #G
    )    #G
    response = platform.models.chat(    #G
        messages=messages,    #G
        model="gpt-4o",    #G
        tools=tools    #G
    )   #G
 
    if response.tool_calls:    #H
        for tool_call in response.tool_calls:    #H
            result = platform.tools.execute(    #H
                tool_call["function"]["name"],    #H
                arguments=json.loads(
                    tool_call["function"]["arguments"])    #H
            )    #H
            messages.append({    #H
                "role": "tool",    #H
                "content": str(result.result),    #H
                "tool_call_id": tool_call["id"]    #H
            })    #H
        response = platform.models.chat(    #H
            messages=messages,
            model="gpt-4o"
        )    #H
 
    output_check = platform.guardrails.filter_output(    #I
        response.content,    #I
        filters=[    #I
            "no_medical_advice",    #I
            "pii_redaction"    #I
        ]    #I
    )    #I
 
    platform.sessions.add_messages(    #J
        session_id,    #J
        [{"role": "user", "content": question},    #J
         {"role": "assistant",    #J
          "content": output_check["content"]}]    #J
    )    #J
 
    return {
        "response": output_check["content"],
        "sources": [r.document_id for r in relevant_info]
    }

The workflow listing illustrates a Python decorator and service calls that keep application logic separate from managed coordination. section 2.1.7

Expense report workflow

An expense assistant analyzes receipts, checks categories against company policies and spending limits, calculates tax and currency implications, routes approvals, and records the expense in financial systems. Each operation requires its own capabilities and recovery strategy. section 1.3

How Designing AI Systems covers it

How deep it goes
Describes sequential and parallel coordination, retries, state, and recovery, with a workflow interface but no underlying implementation.
Examples
Illustrates orchestration through patient intake, expense reporting, and refund processing workflows.
What you can do after
Evaluate workflow designs for step dependencies, recovery, safety checks, and operational visibility.
How it connects
Connects orchestration to conversation memory, knowledge retrieval, guardrails, tool integration, and observability.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.