liveBook · Manning

Service coordination

As explained in Designing AI Systems

Service coordination is the management of dependencies and interactions among components of a service-based system.

Service coordination manages dependencies and interactions across a multi-step service pipeline, keeping application logic focused on business behavior while infrastructure handles recovery, retries, state, and observability. section 2.1.7 section 1.3

A coordinated patient-intake workflow can:

  • Create or retrieve a session and conversation history. section 2.1.7
  • Validate input before processing and validate generated output before delivery. section 2.1.7
  • Retrieve clinic policies, generate a response with registered tools, and execute requested tool calls. section 2.1.7
  • Retry failed services, handle flagged responses, preserve workflow state, and expose step-level timing, failures, and cost. section 2.1.7

Patient-intake coordination

A patient question passes through input safety checks, session retrieval, knowledge-base search, model generation, tool execution, output validation, and persistence. A workflow decorator turns this sequence into a managed process, so a knowledge-base timeout can trigger an automatic retry and a flagged response can be sanitized or regenerated. 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]
    }

Inspect the workflow interface that connects sessions, guardrails, prompts, data retrieval, model calls, tools, and persistence. section 2.1.7

How Designing AI Systems covers it

How deep it goes
Shows a concrete multi-step workflow and operational behavior, but does not detail the coordination engine's internal implementation.
Examples
Uses a patient-intake assistant that validates questions, retrieves policies and history, invokes tools, validates responses, and persists exchanges.
What it assumes
Assumes multiple platform services and dependencies, while teaching how to compose them into one application-level pipeline.
What you can do after
Apply it via a managed workflow that coordinates dependent services and exposes retries, recovery, state, and operational telemetry.
How it connects
Connects workflow orchestration with guardrails, session management, retrieval, tool integration, retries, state management, 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.