import asyncio
from pydantic import BaseModel
from hai_agents import AsyncClient
class Source(BaseModel):
title: str
url: str
excerpt: str
class Sources(BaseModel):
sources: list[Source]
class Brief(BaseModel):
url: str
summary: str
key_facts: list[str]
async def main() -> None:
client = AsyncClient()
scout = await client.run_session(
agent="h/web-surfer-flash",
messages="Find the 5 highest-value sources on EU AI Act enforcement",
answer_schema=Sources,
)
readers = await asyncio.gather(*(
client.run_session(
agent="h/web-surfer-flash",
messages=f"Read this source and extract the key facts: {source.url}",
overrides={"agent.environments[kind=web].start_url": source.url},
answer_schema=Brief,
)
for source in scout.answer.sources
))
for reader in readers:
print(reader.answer.url, reader.answer.key_facts)
asyncio.run(main())