Skip to content

@OnAnswer

The @OnAnswer(AgentClass) method decorator ("@agboss/core") marks the per-agent evaluation method inside a DecidedBy.Code @Arbiter class. During a .joinQuorum() or .joinQuorumGroups() step, AGBoss invokes the matching @OnAnswer(AgentClass) method as each parallel branch finishes so your arbiter can return true (count toward quorum) or false (reject the branch answer) in real time.

How @OnAnswer(AgentClass) works inside @Arbiter

Section titled “How @OnAnswer(AgentClass) works inside @Arbiter”
Signature Part Type Description
@OnAnswer(AgentClass) Method decorator Binds the method on a DecidedBy.Code @Arbiter to a specific @Agent class launched by .toParallelAgents(...). Every agent in the launch must have a corresponding @OnAnswer method ([arbiter.unhandled-agent]).
answer parameter ArbiterAnswerOf<typeof AgentClass> The plain validated output DTO produced by that @Agent branch. TypeScript rejects mismatched DTO types at compile time.
Return value boolean | Promise<boolean> Returns true if the branch’s answer counts toward the quorum, or false to reject it.