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 fetch, as in the quickstart. Agent files are written as text (files.write); send other kinds as base64 data with the API.Quickstart
run() starts the task and follows it to the end. When the agent asks something, it calls onQuestion and sends back what you return. When the agent wants to do something consequential, it calls onApproval: return true or 'approve' to allow it, false or 'deny' to refuse, or { decision: 'deny', note: 'why' }. If a question or approval comes up and you didn’t pass a handler, run() throws NeedsInputError (with error.task, which stays paused: decide it with gh.conversations) instead of waiting forever, except for questions and approvals the customer can answer or decide on their screen (below).
Questions and approvals
A task never asks. When the agent needs an answer or a yes, the task pauses (status: 'paused'; 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 onQuestion and onApproval. The first decision counts: a later one throws ConflictError with extra.code === 'already_decided' and extra.decided_by ({ type: 'person' } is the customer, { type: 'team', … } you), or 'not_pending' when the task has ended. gh.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. question.customer_can_answer says whether they can answer the open one. The first answer is used, from them or from you.
- Without
onQuestion,run()leaves those questions to the customer and keeps following the task (passtimeoutto give up eventually). It throwsNeedsInputErroronly for a question they can’t answer. - With
onQuestion, returnnullto leave one to them. If they answer while your handler works, your answer is refused with a409andrun()carries on. gh.conversations.answer()after they answered throwsConflictErrorwithextra.code === 'already_decided'andextra.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 approval.customer_can_approve says whether they can decide the open one.
- Without
onApproval,run()leaves those approvals to the customer and keeps following. WithonApproval, returnnullto leave one to them. gh.conversations.decide()after they decided throwsConflictErrorwithextra.code === 'already_decided'andextra.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.
Guardrails
An agent’sguardrails are rules Eager enforces on every step, whatever the model says. Send only the keys to change; null resets one to its default.
blocked event: message says what didn’t happen and why, and data.guardrail (the GuardrailDecision type) has the rule and the decision. The agent plans around it, and a stop decision ends the task. run() needs no handler for any of this.
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.
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:gh.agents.update() still changes the agent right away, as a new version. agent_version also takes a number, to run an earlier version. Each task says which 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.
Cloud browsers
A session can run on a cloud browser Eager hosts instead of a person’s computer: no app, no invite link. It’s connected whencreate() returns.
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
Client
request_id are retried. Other writes are not.
Resources
Every
list() returns one page ({ data, has_more, next_cursor }) and takes limit and cursor (agents, versions, files and runners come whole without either, as before they paged); include: 'total_count' adds total_count, and q searches (see search). listAll() walks every page for you:
Webhooks
verifyWebhook needs the raw body, compares in constant time and rejects deliveries older than 5 minutes ({ tolerance } in seconds). It throws WebhookVerificationError. See Webhooks.
Errors
Every error extendsEagerError, with status, type, message and extra: InvalidRequestError (400), AuthenticationError (401), PaymentRequiredError (402, when the org’s balance can’t pay for the task: extra.code is insufficient_balance, auto_topup_limit_reached or card_needs_attention), PermissionDeniedError (403), NotFoundError (404), ConflictError (409, for example extra.active_task_id when a task is already running, or extra.code: 'already_decided' with extra.decided_by when someone answered a question or decided an approval first, 'not_pending' when its task has ended), RateLimitError (429, including too many tasks running at once in the org, with extra.code: 'concurrency_limit'), APIError (5xx, including 503 with extra.code: 'model_unavailable' when the agent’s model can’t run right now), APIConnectionError, TimeoutError, NeedsInputError and SessionExpiredError.