Type Alias: AgencyStreamPart
AgencyStreamPart = {
agent?:string;text:string;type:"text"; } | {agent?:string;args:unknown;toolName:string;type:"tool-call"; } | {agent?:string;result:unknown;toolName:string;type:"tool-result"; } | {agent?:string;error:Error;type:"error"; } | {agent:string;input:string;type:"agent-start"; } | {agent:string;durationMs:number;output:string;type:"agent-end"; } | {fromAgent:string;reason:string;toAgent:string;type:"agent-handoff"; } | {chosen:string;original:string;reason:string;type:"strategy-override"; } | {agentName:string;approved:boolean;instructions:string;type:"emergent-forge"; } | {action:string;agent:string;guardrailId:string;passed:boolean;type:"guardrail-result"; } | {request:ApprovalRequest;type:"approval-requested"; } | {approved:boolean;requestId:string;type:"approval-decided"; } | {agentCalls:AgentCallRecord[];chair?:PanelSeatRecord;durationMs:number;parsed?:unknown;quorum?:PanelQuorumRecord;seating?:SeatingRecord;seats?:PanelSeatRecord[];text:string;type:"final-output";usage: {cacheCreationExtendedTokens?:number;cacheCreationTokens?:number;cacheReadTokens?:number;completionTokens:number;costUSD?:number;promptTokens:number;totalTokens:number; }; } | {action:string;agent:string;reason:string;type:"permission-denied"; }
Defined in: packages/agentos/src/api/types.ts:1129
Discriminated union of all streaming events emitted by an agency() stream.
A superset of the base StreamPart type — includes all text/tool events
plus agency-level lifecycle events and the finalized post-processing snapshot.
text parts are low-latency raw stream chunks. The finalized approved answer
is surfaced separately through the final-output part, AgencyStreamResult.text,
and AgencyStreamResult.finalTextStream.
Type Declaration
{ agent?: string; text: string; type: "text"; }
agent?
optionalagent:string
text
text:
string
type
type:
"text"
{ agent?: string; args: unknown; toolName: string; type: "tool-call"; }
agent?
optionalagent:string
args
args:
unknown
toolName
toolName:
string
type
type:
"tool-call"
{ agent?: string; result: unknown; toolName: string; type: "tool-result"; }
agent?
optionalagent:string
result
result:
unknown
toolName
toolName:
string
type
type:
"tool-result"
{ agent?: string; error: Error; type: "error"; }
agent?
optionalagent:string
error
error:
Error
type
type:
"error"
{ agent: string; input: string; type: "agent-start"; }
agent
agent:
string
input
input:
string
type
type:
"agent-start"
{ agent: string; durationMs: number; output: string; type: "agent-end"; }
agent
agent:
string
durationMs
durationMs:
number
output
output:
string
type
type:
"agent-end"
{ fromAgent: string; reason: string; toAgent: string; type: "agent-handoff"; }
fromAgent
fromAgent:
string
reason
reason:
string
toAgent
toAgent:
string
type
type:
"agent-handoff"
{ chosen: string; original: string; reason: string; type: "strategy-override"; }
chosen
chosen:
string
original
original:
string
reason
reason:
string
type
type:
"strategy-override"
{ agentName: string; approved: boolean; instructions: string; type: "emergent-forge"; }
agentName
agentName:
string
approved
approved:
boolean
instructions
instructions:
string
type
type:
"emergent-forge"
{ action: string; agent: string; guardrailId: string; passed: boolean; type: "guardrail-result"; }
action
action:
string
agent
agent:
string
guardrailId
guardrailId:
string
passed
passed:
boolean
type
type:
"guardrail-result"
{ request: ApprovalRequest; type: "approval-requested"; }
request
request:
ApprovalRequest
type
type:
"approval-requested"
{ approved: boolean; requestId: string; type: "approval-decided"; }
approved
approved:
boolean
requestId
requestId:
string
type
type:
"approval-decided"
{ agentCalls: AgentCallRecord[]; chair?: PanelSeatRecord; durationMs: number; parsed?: unknown; quorum?: PanelQuorumRecord; seating?: SeatingRecord; seats?: PanelSeatRecord[]; text: string; type: "final-output"; usage: { cacheCreationExtendedTokens?: number; cacheCreationTokens?: number; cacheReadTokens?: number; completionTokens: number; costUSD?: number; promptTokens: number; totalTokens: number; }; }
agentCalls
agentCalls:
AgentCallRecord[]
chair?
optionalchair:PanelSeatRecord
A panel's chair record, on a panel run with a chair.
durationMs
durationMs:
number
parsed?
optionalparsed:unknown
quorum?
optionalquorum:PanelQuorumRecord
The quorum a panel reached, on a panel run.
seating?
optionalseating:SeatingRecord
The seating that served the run, when a pool seated it.
seats?
optionalseats:PanelSeatRecord[]
A panel's seat records, on a panel run.
text
text:
string
type
type:
"final-output"
usage
usage:
object
usage.cacheCreationExtendedTokens?
optionalcacheCreationExtendedTokens:number
usage.cacheCreationTokens?
optionalcacheCreationTokens:number
usage.cacheReadTokens?
optionalcacheReadTokens:number