Threads AI

Team

Your code's handle on a team: RunResult.team, or openTeam.

Every request is recorded in the team log as the principal it acts for; only busy, returned before the log could be written, is not.

A handle returned by the library.

Properties

refTeamRefrequired

This team's tenant and id.

Methods

start

Starts a member from an agent the team lists, with task as its first input. Recorded in the team log as an operator request.

start(agent: Name, task: string, options?: {
  label?: string;
  instructions?: string;
  tools?: readonly string[];
  model?: string;
  idempotencyKey?: string;
}): Promise<TeamStartResult>
agentNamerequired

The agent to start, by name.

taskstringrequired

The member's first input; it sees nothing else.

labelstring

A display name for the member, 1-64 characters with no control or format character, not operator. Never hashed and never shown to a model. Omitted: none.

instructionsstring

A dynamic agent only: instructions added after the template's own, in a block marked as written by operator. At most 16 KiB. Omitted: the template's alone.

toolsreadonly string[]

A dynamic agent only: the member's tools, a subset of the template's (the framework tools are always kept). Omitted: all of the template's.

modelstring

A dynamic agent only: a key of the template's models. Omitted: the first key.

idempotencyKey / idempotency_keystring

Makes a retry safe: the same key, principal and body return (or re-attach to) the first request's outcome. Scoped to this team and operation. Omitted: every call is a new request.

send

Sends a message to a member. It arrives as the member's next input and wakes it if idle.

send(to: MemberRef, text: string, options?: {
  idempotencyKey?: string;
}): Promise<TeamSendResult>
toMemberRefrequired

The member, at the generation you know. See MemberRef.

textstringrequired

The message.

idempotencyKey / idempotency_keystring

Makes a retry safe: the same key, principal and body return (or re-attach to) the first request's outcome. Scoped to this team and operation. Omitted: every call is a new request.

ask

Asks a member a question and waits for its reply, its end, or the deadline. Addressed to the team's lead it is refused lead: only members run a turn that could reply.

ask(to: MemberRef, question: string, options?: {
  timeoutMs?: PosInt;
  idempotencyKey?: string;
}): Promise<TeamAskResult>
toMemberRefrequired

The member to ask; the team's lead is refused lead. See MemberRef.

questionstringrequired

The question.

timeoutMs / timeout_msPosInt

How long to wait. Omitted: the host policy, initially 120 s, and never more than it.

idempotencyKey / idempotency_keystring

Makes a retry safe: the same key, principal and body return (or re-attach to) the first request's outcome. Scoped to this team and operation. Omitted: every call is a new request.

Throws StoreCorruptError when the stored log doesn't verify.

wait

Waits until members settle (become idle or end), or the deadline. Settlement is durable evidence: a member that went idle and started again still counts.

wait(members: readonly MemberRef[], options?: {
  mode?: "all" | "any" | PosInt;
  timeoutMs?: PosInt;
  idempotencyKey?: string;
}): Promise<TeamWaitResult>
membersreadonly MemberRef[]required

The members to wait for: frozen at the call. An empty list is refused invalid_request.

mode"all" | "any" | PosIntdefault all

all, any, or how many must settle. any never cancels the others. A number below 1 or above the count of distinct members is refused invalid_request before anything is recorded.

timeoutMs / timeout_msPosInt

How long to wait. Omitted: the host policy, initially 120 s, and never more than it.

idempotencyKey / idempotency_keystring

Makes a retry safe: the same key, principal and body return (or re-attach to) the first request's outcome. Scoped to this team and operation. Omitted: every call is a new request.

Throws StoreCorruptError when the stored log doesn't verify.

cancel

Requests a member's cancel: durable at once, applied at the member's next step.

cancel(member: MemberRef, options?: {
  idempotencyKey?: string;
}): Promise<TeamCancelResult>
memberMemberRefrequired

The member to cancel. See MemberRef.

idempotencyKey / idempotency_keystring

Makes a retry safe: the same key, principal and body return (or re-attach to) the first request's outcome. Scoped to this team and operation. Omitted: every call is a new request.

members

Every member of the team, the lead included, with its state and, once idle or ended, its result. A pure read.

members(): Promise<readonly TeamMember[]>

Throws StoreCorruptError when the stored log doesn't verify.

events

Phase 2, not yet available (lane 29-teams-phase2-29b): Until then a cursor of any other epoch restarts the feed, follow is not supported, and GET /v1/teams/{team}/events is not served. The team's audit feed: every committed event of every team log, as stored (results keep their artifact refs, so this never raises StoreCorruptError). A pure read that drives nothing.

events(options?: {
  after?: TeamCursor;
}): Promise<Result<AsyncIterable<TeamItem>>>
afterTeamCursor

Resume after this cursor. A cursor of an older epoch first yields epoch_restarted; one from a later epoch, or past the head of the current one, is invalid_cursor. Omitted: from the start. See TeamCursor.

Returns an error value with one of these codes: invalid_cursor.

askStatus / ask_status

An ask's state from the team log: open, not_found, or its outcome. A pure read; it never closes an ask.

askStatus(askId: AskId): Promise<AskStatus>
askId / ask_idAskIdrequired

The ask, as team.ask or its outcome names it.

Throws StoreCorruptError when the stored log doesn't verify.

Edit on GitHub

On this page