from agents import Agent, Runner, function_tool
from openai import OpenAI
mirobody = OpenAI(
api_key="mb_live_...",
base_url="https://test-mirobody-api.thetahealth.ai/v1",
)
@function_tool
def health_answers(question: str, user_id: str) -> str:
"""Answer a question from this end user's REAL health records
(labs, vitals, reports). Grounded and citation-backed — use it for
anything about the user's own health data."""
resp = mirobody.chat.completions.create(
model="mirobody-flash",
messages=[{"role": "user", "content": question}],
user=user_id, # the end user's stable id (Subject)
)
return resp.choices[0].message.content
coach = Agent(
name="Wellness coach",
model="gpt-4.1", # your model, your orchestration
instructions=(
"You are a wellness coach. For anything about the user's own labs, "
"vitals or reports, call health_answers with their user_id — never guess."
),
tools=[health_answers],
)
result = Runner.run_sync(coach, "user_id=alice — Should I be worried about my recent glucose?")
print(result.final_output)