Skip to content

v0.1.8

Choose a tag to compare

@abonneth abonneth released this 11 Jun 18:50
· 116 commits to main since this release
3e24877

Typed structured output

Pass a Pydantic model via answer_schema=; the SDK sends the matching JSON Schema as the agent's answer format and parses the final answer back into your model.

from pydantic import BaseModel
from hai_agents import Client, run_session

class Job(BaseModel):
    title: str
    company: str

class Jobs(BaseModel):
    jobs: list[Job]

client = Client()
result = run_session(
    client,
    agent="h/web-surfer-holo3-1-35b",
    messages="Find 3 open ML engineering roles in Paris.",
    answer_schema=Jobs,
)
for job in result.answer.jobs:  # result.answer is a Jobs instance
    print(job.title, "@", job.company)

Improvements

  • run_session / wait_for_session now return when a session goes idle after answering, instead of polling until timeout.
  • Fixed environment payload serialization that could reject requests with a discriminator validation error.