A workflow coordinates a sequence of dependent operations, passing results between steps and making decisions as it runs. In a patient assistant, a single request may require session history, safety checks, knowledge retrieval, model generation, tool execution, output validation, and persistence. Any step can fail, so production coordination needs more than a successful prototype path. section 2.1.7
A managed workflow separates business logic from execution infrastructure. The intended platform behavior includes state management, retries, error recovery, and observability. For example, a knowledge search timeout may trigger a retry, while an unsafe output may be sanitized or regenerated. Step duration, failures, and cost make the pipeline operable. section 2.1.7 section 2.6
Listing 9.1 A workflow function decorated with @workflow
from genai_platform import GenAIPlatform, workflow
@workflow(
name="patient_intake_assistant",
api_path="/patient-assistant",
response_mode="sync",
# Scaling
min_replicas=1, #A
max_replicas=10, #A
target_cpu_percent=70, #A
target_memory_percent=80, #A
# Resources
cpu="500m", #B
memory="512Mi", #B
gpu_type=None, #B
num_gpus=0, #B
# Reliability
timeout_seconds=30, #C
max_retries=3, #D
)
def handle_patient_question(question, patient_id):
platform = GenAIPlatform() #E
session = platform.sessions.get_or_create(
patient_id
)
safety = platform.guardrails.validate_input( #F
content=question,
checks=["healthcare_compliance"]
)
if not safety["allowed"]: #F
return {"response": safety["denial_reason"]} #F
relevant_info = platform.data.search(
index_name="patient_procedures",
query=question
)
context = "\n".join(
r.text for r in relevant_info
)
history, _ = platform.sessions.get_messages(
session.session_id
)
response = platform.models.chat(
model="gpt-4o",
system_prompt_name="patient_intake_assistant",
messages=[*history,
{"role": "user",
"content": f"Context:\n{context}"
f"\n\n{question}"}]
)
platform.sessions.add_messages(
session.session_id,
[{"role": "user", "content": question},
{"role": "assistant",
"content": response.content}]
)
return { #G
"response": response.content, #G
"sources": [r.document_id #G
for r in relevant_info] #G
} #GThe decorated patient-assistant function combines ordered service calls with deployment, scaling, resource, and reliability settings. section 9.1.1
A workflow can be expressed as a Python function decorated with @workflow. The function accepts arguments, calls platform services, and returns a dictionary; a runtime server handles HTTP and serialization. The decorator records configuration as function metadata. The shown wrapper calls the original function unchanged, so the metadata alone is not the implementation of retries or recovery. section 2.5.3 section 9.1.1
wrapper._workflow_metadata = {
"name": name,
"api_path": api_path,
"scaling": {
"min_replicas": min_replicas,
"max_replicas": max_replicas,
"target_cpu_percent": target_cpu_percent
},
"response_mode": response_mode
}
return wrapper
return decoratorThe metadata dictionary makes the workflow name, API path, scaling limits, and response mode available to deployment tooling. section 2.5.3
A production deployment gives each workflow its own operational boundary:
- Deploy one workflow as one service so teams can release, scale, and version it independently, including running versions side by side during a traffic shift. section 2.2.3
- Package it in a container with resource limits and security boundaries; a Workflow Service manages lifecycle, health, scaling, and discovery. section 2.2.2 section 2.6
- Expose a stable, explicitly configured API path independently of the internal workflow name. Shared domain conventions reduce API sprawl while preserving path-level control. section 2.3.2
- Select synchronous, asynchronous, or streaming responses to suit the operation's duration and delivery needs. section 2.6










