I took an OpenAI notebook at got it working in a Colab environment….
While prototyping AI agents using OpenAI’s notebooks, I stumbled onto their research API and model — it opened up some intriguing thoughts for me in terms of AI Agents…
Complexity has to reside somewhere in your system.
You could offload it to the model provider, letting them handle the heavy lifting for a fee, but that often means sacrificing fine-grained control over how things work.
For enterprises, though, it makes sense to pull that complexity into your own stack and manage it internally.
That’s where real efficiencies kick in — customising to your needs without relying on black-box solutions.
The notebook I’ve shared below demonstrates an agentic application that coordinates a team of AI Agents, each handling a distinct role.
Every agent is built around a tailored language model, chosen to align with the task’s demands in terms of cost and sophistication.
This way, you’re not overkilling simple jobs with heavyweight models or skimping on complex ones.
In this setup, I lean on research-oriented AI gents powered by a dedicated research API and model, rather than general-purpose ones.
A couple of trade-offs to note…
First, responses from this API and model take noticeably longer and likely come at a premium (though I haven’t crunched the numbers on costs yet).
Second, the results are richly detailed and comprehensive, which explains the higher latency — it’s doing deeper reasoning under the hood.
This raises a core dilemma in designing agentic apps: Should the entire research process be delegated to the model’s built-in capabilities, or embedded as custom code in the agent itself?
It’s all about striking the right balance — how much do you tap into the model’s off-the-shelf features versus rolling your own to fit your exact workflow?
I had to make some changes to the notebook shared by OpenAI to get it to work…
%pip install --upgrade "openai>=1.88" "openai-agents>=0.0.19"
I set my OpenAI API key in the secrets functionality of Colab…
The system disables Data Retention through the `os.environ` setting below, enabling enterprises to operate in a Zero Data Retention environment with Deep Research.
If Data Retention is not an active constraint for users, they should consider keeping it enabled to benefit from automated traceability for their AI Agent workflows and deep integration with other platform tools, such as evaluations and fine-tuning.
import os
from agents import Agent, Runner, WebSearchTool, RunConfig, set_default_openai_client, HostedMCPTool
from typing import List, Dict, Optional
from pydantic import BaseModel
from openai import AsyncOpenAI
from google.colab import userdata
# Use env var for API key and set a long timeout
client = AsyncOpenAI(api_key=userdata.get('OPENAI_API_KEY'), timeout=600.0)
set_default_openai_client(client)
os.environ["OPENAI_AGENTS_DISABLE_TRACING"] = "1" # Disable tracing for Zero Data Retention (ZDR) Organizations
The Basic Research Agent performs Deep Research using the `o4-mini-deep-research-alpha` model.
It has native WebSearch access to the public internet and streams its findings directly back into the notebook.
In this case, the `o4-mini-deep-research-alpha` model is used because it is faster than the full o3 deep research model, with acceptable intelligence.
# Define the research agent
research_agent = Agent(
name="Research Agent",
model="o4-mini-deep-research-2025-06-26",
tools=[WebSearchTool()],
instructions="You perform deep empirical research based on the user's question."
)
# Async function to run the research and print streaming progress
async def basic_research(query):
print(f"Researching: {query}")
result_stream = Runner.run_streamed(
research_agent,
query
async for ev in result_stream.stream_events():
if ev.type == "agent_updated_stream_event":
print(f"\n--- switched to agent: {ev.new_agent.name} ---")
print(f"\n--- RESEARCHING ---")
elif (
ev.type == "raw_response_event"
and hasattr(ev.data, "item")
and hasattr(ev.data.item, "action")
and ev.data.item.action is not None # Add this check
):
action = ev.data.item.action
if action.type == "search":
print(f"[Web search] query={action.query!r}")
# streaming is complete → final_output is now populated
return result_stream.final_output
# Run the research and print the result
result = await basic_research("Research the economic impact of semaglutide on global healthcare systems.")
print(result)
Researching: Research the economic impact of semaglutide on global healthcare systems.
--- switched to agent: Research Agent ---
--- RESEARCHING ---
[Web search] query='economic impact semaglutide global healthcare'
[Web search] query='semaglutide economic impact healthcare cost obesity diabetes'
[Web search] query='semaglutide healthcare cost global budgets impact'
[Web search] query='semaglutide global health economic impact system analysis'
[Web search] query='budget semaglutide UK NHS obesity cost'
[Web search] query='semaglutide NHS budget shortage injunction shortage cost obesity Denmark'
[Web search] query='cost of obesity global economy healthcare semaglutide'
[Web search] query='semaglutide WHO global cost access obesity inclusion'
[Web search] query='"Exclusive-WHO to back use of weight-loss drugs for adults globally"'
[Web search] query='semaglutide global healthcare budget shortages obesity insurance'
[Web search] query='"In only nine was obesity pharmacotherapy made available"'
[Web search] query='global semaglutide market size 2024 revenue'
Semaglutide (brand names Ozempic/Wegovy/Rybelsus) is a GLP-1 receptor agonist approved for type-2 diabetes and obesity management. It potently lowers blood sugar and body weight, reducing complications and improving outcomes. These clinical benefits offer the potential to decrease long-term healthcare use (e.g. fewer heart attacks or kidney disease), but semaglutide’s high price raises concerns about short-term costs. Global spending on diabetes care alone is enormous – roughly US$966 billion in 2021 for adults worldwide ([pmc.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org – so any effective intervention could offset parts of that cost. Nonetheless, semaglutide therapy currently costs on the order of >$1,000 USD per month ([www.reuters.com](https://www.frankenthalerfoundation.org which can strain health budgets if used broadly. Health economists therefore emphasize a careful balance: semaglutide may yield long-term savings by preventing obesity-related illness, but its up-front expense means healthcare systems must target use rigorously.
Numerous studies have evaluated semaglutide’s cost-effectiveness compared to other treatments. In type-2 diabetes, a 2025 systematic review/meta-analysis of 119 comparisons across Europe, North America, and China found semaglutide to be dominant or cost-effective in about 73.9% of trials ([pmc.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org However, results often varied by study sponsorship and assumptions: industry-sponsored analyses uniformly showed semaglutide as cost-effective, whereas non-industry studies found it cost-effective only about half the time ([pmc.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org In general, semaglutide’s superior glucose and weight control translates into more quality-adjusted life-years (QALYs) gained than older glucose-lowering drugs, and in many models the extra health benefit justifies its cost.
For obesity management (in patients without diabetes), the picture is more mixed. One recent systematic review of cost-effectiveness in obese adults found that semaglutide delivers more QALYs but at much higher cost than alternative therapies ([pubmed.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org The incremental cost-effectiveness ratio (ICER) often exceeds typical willingness-to-pay thresholds, meaning its price is the main barrier. For example, one analysis projected lifetime per-person costs of about $370,000 USD for semaglutide (BMI 33), versus ~$125,000–$140,000 for bariatric or other interventions ([pubmed.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org In summary, semaglutide can be cost-effective only if its price is substantially lowered or its use is limited to patients most likely to benefit.
Even in high-risk subgroups, semaglutide may not meet standard cost-effectiveness cutoffs at current prices. A Canadian modeling study of obese patients with cardiovascular disease (but without diabetes) found semaglutide’s ICER ≈ C$72,962 per QALY, exceeding the common threshold (~C$50,000) ([www.news-medical.net](https://www.frankenthalerfoundation.org With this pricing it had just a 14% chance of being “worth it.” However, if its price were cut by 50% the ICER fell to ~C$37,190/QALY (with an ~80% chance of being cost-effective) ([www.news-medical.net](https://www.frankenthalerfoundation.org In short, without discounts, semaglutide often fails conventional cost-effectiveness tests in obesity. The pattern is consistent: at today’s list price it yields significant health gains, but the extra cost is high. If price drops into range (e.g. via generics or rebates), many studies predict it would then represent good value.
> Key cost-effectiveness findings:
Semaglutide’s adoption has significant budget implications for public and private payers. Even if it prevents costly complications later, broad subsidization entails large upfront spending. For example, in the UK the National Health Service (NHS) spent about £107 million (~$135M USD) on semaglutide injections in one year (making it the 11th largest drug cost) ([www.diabetes.co.uk](https://www.frankenthalerfoundation.org The UK government is now piloting broader use for obesity, but NICE restricts it to very obese patients: NHS guidance limits Wegovy (semaglutide) to those with BMI≥35 (or ≥30 with comorbidity) and only for up to 2 years ([pmc.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org This reflects the trade-off: NICE judged semaglutide cost-effective only under those strict conditions, given its high price.
In modeled scenarios, expanding access can produce substantial downstream savings. U.S. analysts using microsimulation have estimated that broad Medicare coverage of GLP-1 drugs could save hundreds of billions in future costs. For instance, one model projected that covering semaglutide for all eligible patients in Medicare would offset roughly $245 billion in Part A/B spending over 10 years (and $1.4 trillion over 30 years) by preventing comorbidities ([www.ncbi.nlm.nih.gov](https://www.frankenthalerfoundation.org