The SDK (0.16) covers agents (with their versions, files and procedures), sessions, tasks, conversations (reading them, and deciding their requests), webhooks, evals and the audit log. Talking to an agent (
/responses), uploads, and computers and pools aren’t in it yet: call those with httpx or requests, as in the quickstart. Agent files are written as text (files.write); send other kinds as base64 data with the API.Quickstart
Create an org API key in the console under Settings → API. It starts withgh_live_ and is shown once.
TypedDicts (Agent, Session, Task, Event, Recording, Webhook, Page, …), so editors and type checkers know the keys. Field names are the API’s own (session_id, task_id, agent_id, …), and so are the parameter names.
The client
AuthenticationError. The client holds a connection pool: use it as a context manager or call client.close() when you are done.
AsyncEager has the same resources and methods, and you await them. See Async.
Agents
An agent holds your instructions, the AI model it runs on and its reasoning effort, its greeting, tools, browser and computers, and what a customer at their computer sees and may do. See Agents.model sets what the agent’s tokens cost; each model’s price per million tokens is in Model. effort has no price of its own; a higher level thinks more, so uses more tokens. Tasks carry the model and effort they ran at, the tokens they used (usage), and cost_cents once they end. agent["invite_url_template"] is the agent’s invite link with a {code} placeholder. Creating an agent_id that already exists raises ConflictError.
guardrails are rules Eager enforces on every step the agent takes, whatever the model says (Guardrails). Pass a partial dict: only the keys you give change, a key set to None goes back to its default, and guardrails=None resets them all. The agent always has the whole object, with defaults filled in.
blocked event: message says what didn’t happen and why, and data["guardrail"] (a GuardrailDecision) has the rule and the decision. The agent plans around it, and a stop decision ends the task.
Versions
Save changes to an agent’s draft without changing what runs, try the draft on a task, then publish it as the next version:agents.update still changes the agent right away, as a new version. agent_version also takes a number, to run an earlier version. Publishing with no draft raises ConflictError. Each task says which version it ran (agent_version, agent_draft) and who started it (created_by).
Tools and files
An agent has its own file system (on by default), and can call your HTTP tools:GET of https://api.acme.com/v1/orders/42, unsigned. Each call is a tool event in the task. See HTTP tools for open calls (methods) and headers.
Sessions
A session is one pairing code (session_id, e.g. K7QM-24XP) for one computer. Codes expire after 72 hours without use.
wait_for_connection returns the session once status is connected and device is set. It raises SessionExpired if the code expires first, and EagerTimeout after timeout seconds (timeout=None waits indefinitely). As an alternative to polling, a webhook sends session.connected.
Cloud browsers
A session can run on a cloud browser Eager hosts instead of a person’s computer: no app, no invite link (invite_url is None). It’s connected when create returns.
Tasks
A task is a prompt carried out on the session’s computer. Each computer runs one task at a time.Run a task to the end
tasks.run starts a task and follows it until it is done, then returns the finished task.
on_question returns the answer as a string (or None to leave it to the customer, below). on_approval returns True or False, "approve" or "deny", or {"decision": "deny", "note": "Not on a Friday"} to pass a note to the agent (or None to leave it to the customer). With Eager the handlers are plain functions: an async def handler raises TypeError, so use AsyncEager for those. If the agent needs a handler you didn’t pass, run raises NeedsInput instead of hanging. The task stays paused on the server, so you can answer it yourself, in its conversation:
Questions and approvals
A task never asks. When the agent needs an answer or a yes, the task pauses (task["status"] == "paused"; task["paused_for"] says which request) and the request is put to its conversation (task["conversation_id"]; every task has one). Whoever may decide it does so there, and the same task carries on. task["pending"] is the open request, with its conversation_id.
run does this for you with on_question and on_approval. The first decision counts: a later one raises ConflictError with e.extra["code"] == "already_decided" and e.extra["decided_by"] ({"type": "person"} is the customer, {"type": "team", ...} you), or "not_pending" when the task has ended. AsyncEager has the same methods. tasks.respond is gone: POST /v1/tasks/{task_id}/respond answers 409 with code: "decide_in_conversation".
The customer answers too
Unless the agent turns it off (customer_answers=False), the agent’s questions also appear on the customer’s screen, and they can answer them there. pending["customer_can_answer"] says whether they can answer the open one. The first answer is used, from them or from you.
- Without
on_question,runleaves those questions to the customer and keeps following the task (passtimeoutto give up eventually). It raisesNeedsInputonly for a question they can’t answer. - With
on_question, returnNoneto leave one to them. If they answer while your handler works, your answer is refused with a 409 andruncarries on. conversations.answerafter they answered raisesConflictErrorwithe.extra["code"] == "already_decided"ande.extra["decided_by"]["type"] == "person".- The
answerevent hasdata["answered_by"]("customer"or"operator"), and theconversation.question_answeredwebhook carries the question as answered and who gave it (question["answer"]["by"]).
customer_approvals=False), the customer can approve or deny the agent’s approval requests on their screen, and pending["customer_can_approve"] says whether they can decide the open one.
- Without
on_approval,runleaves those approvals to the customer and keeps following. Withon_approval, returnNoneto leave one to them. conversations.decideafter they decided raisesConflictErrorwithe.extra["code"] == "already_decided"ande.extra["decided_by"]["type"] == "person".- The
approvedanddeniedevents havedata["answered_by"], and theconversation.approval_decidedwebhook carries the approval as decided and who made the decision (approval["decision"]["by"]).answered_byis"timeout"when nobody decided within the agent’sapproval_timeout_minutes, so it was denied.
Follow a task yourself
tasks.events long-polls GET /v1/tasks/{id}/events. Each page has the new events and the task as it is now, so you can answer what it is waiting on:
task["pending"], not the question and approval_required events: the events start from the beginning, so a re-run (the same request_id returns the same task) sees questions that were already answered.
To only watch, stream(task_id, after=0) yields each event once and ends when the task is done. To resume from a known point, pass the last cursor you have as after.
Everything else
task["replay_url"] opens the replay in the console: every screen the agent saw, with its cursor and clicks.
Pagination
Every list returns one page of up tolimit items (1 to 100, default 20). Agents, an agent’s versions and files, and runners come whole when you pass neither limit nor cursor, as they did before they paged. Most lists are newest first; agents by name, an agent’s files by path, and runners Eager’s first.
list_all(...) (for a run’s attempts, test_runs.list_all_attempts(...)). It takes the same filters and q, and fetches pages as you iterate; limit= sets the page size.
q searches a list’s text, ignoring case: an agent’s name, id and display name; a session’s code, computer name and metadata; a task’s prompt, id, session code and metadata; a file’s path; an audit event’s action, details and who did it; a test case’s name, key and prompt; a test set’s name and description; a start state’s name, description and id; a test run’s or runner’s name and id; a conversation’s title. include="total_count" adds total_count. On test_cases.list, include="facets" adds every category and tag in use, with counts (include=["total_count", "facets"] for both).
Conversations
Chats with your agents (in the console, your website’s widget or over the API), to read:Escalations
What needs your team: approvals and questions only your team can decide, procedure runs that failed, and runs that worked another way, with the procedure rewritten to match:dismiss and reject resolve one without changing anything. Approvals and questions are decided in their conversation.
Audit log
Who did what in the org: people, API keys, agents (their file writes) and Eager itself. It needs an API key or the admin role.Webhooks
Instead of polling, Eager can POST events to your endpoint:session.connected, session.disconnected, task.started, task.completed, task.failed and task.stopped; conversation.approval_required, conversation.approval_decided, conversation.question_asked and conversation.question_answered (every question and approval, a task’s included, is asked in a conversation); escalation.created, escalation.updated and escalation.resolved (what needs your team); and for evals test_run.completed, start_state.ready and start_state.failed.
update changes only what you pass: leave out url or events to keep them (the first call needs a url). events limits which events are sent, and [] means all of them (a new endpoint starts with all). An unknown event type raises InvalidRequestError. The URL must be a public https:// address.
Each delivery carries a Eager-Signature: t=<unix>,v1=<hex> header. Verify it against the raw request body before trusting the event:
verify_webhook(payload, signature_header, secret, tolerance=300) compares signatures in constant time. It rejects timestamps more than tolerance seconds from now (tolerance=None turns that check off) and returns the parsed event: {"id", "type", "created_at", "org_id", "data": {"task": ...} | {"session": ...} | {"conversation": ..., "approval" | "question": ...}} (data["conversation"] with data["approval"] or data["question"] for the conversation.* events, data["test_run"] for test_run.completed and data["start_state"] for start_state.ready and start_state.failed). Deliveries that don’t get a 2xx are retried up to 4 times over about 3 minutes, so use event["id"] to ignore repeats.
Evals
Measure how often an agent fixes a problem: a test case is a problem on a fresh machine and a way to tell it’s fixed (a check script that printsTrue, a rubric a model judges, or both). Group cases into a test set, run it against your agents with a few tries each, and read the pass rates. See Evals.
win10-22h2, or one you build by script, by instruction (an Eager task sets it up), or by hand. Runners are the processes that host the machines: Eager’s, or your own.
AsyncEager has the same test_cases, test_sets, test_runs, attempts, start_states and runners, with await (and async for over list_all and list_all_attempts).
Errors
Every exception is aEagerError, with message, status (the HTTP status, or None), type (the API’s error type), body (the parsed response) and extra (the error’s other fields). Exceptions can be pickled, e.g. to pass them between processes.
Retries
Requests that are safe to repeat are retried up tomax_retries times (default 2) on connection errors, 429 and 5xx. The waits grow 0.5 s, 1 s, 2 s, and so on, and a Retry-After header takes precedence. Safe requests are GET and DELETE, plus POSTs that carry a request_id (starting a task with request_id is idempotent). Other POSTs, PATCH and PUT are never retried. To make starting a task safe to retry, pass a request_id. If a DELETE’s answer is lost and the retry finds the session or agent already gone, the delete returns its usual {"deleted": True} result.
Async
AsyncEager mirrors Eager. stream and list_all are async iterators, and tasks.run accepts both plain functions and coroutine functions as handlers.
Development
The tests start the real server (node server/src/index.js with an in-memory database), a fake OpenAI, a webhook receiver and fake computers on the WebSocket bridge. They need Node 18+ and server/node_modules.
NODE=/path/to/node to choose the Node binary.