Interface: AgencyStreamResult<R>
Defined in: packages/agentos/src/api/types.ts:1244
Public stream result returned by agency().stream(...).
This exposes both low-latency raw streaming and finalized post-processing results so callers can choose the right trade-off for their UI or runtime.
Prefer:
textStreamfor raw token-by-token UXfullStreamfor structured lifecycle eventstextorfinalTextStreamfor the finalized approved answer
textStream may differ from the finalized answer when output guardrails or
beforeReturn HITL rewrite the result. finalTextStream and text always
reflect the finalized post-processing output.
Example
const stream = team.stream('Summarize HTTP/3 rollout risks.');
for await (const chunk of stream.textStream) {
process.stdout.write(chunk); // raw live output
}
for await (const approved of stream.finalTextStream) {
console.log('Approved answer:', approved);
}
console.log(await stream.agentCalls);
console.log(await stream.text);
Type Parameters
R
R extends AgencyResult = AgencyResult
The finalized result type result resolves to: PanelResult for a panel agency.
Properties
agentCalls
agentCalls:
Promise<AgentCallRecord[]>
Defined in: packages/agentos/src/api/types.ts:1267
Final per-agent execution ledger for the streamed run.
finalTextStream
finalTextStream:
AsyncIterable<string>
Defined in: packages/agentos/src/api/types.ts:1281
Finalized approved-only text stream.
Unlike textStream, this yields only the post-guardrail/post-HITL answer.
For most runs it emits a single finalized chunk.
fullStream
fullStream:
AsyncIterable<AgencyStreamPart>
Defined in: packages/agentos/src/api/types.ts:1253
Structured live + finalized event stream.
This includes raw text/tool/lifecycle events and also the finalized
final-output event after post-processing completes.
parsed
parsed:
Promise<unknown>
Defined in: packages/agentos/src/api/types.ts:1274
Final structured payload, parsed from the finalized text (a
beforeReturn approval's replacement when it carries one); resolves to
undefined when structured output was not configured for the run or
that text does not match the schema. A stream runs no validation retry.
result?
optionalresult:Promise<R>
Defined in: packages/agentos/src/api/types.ts:1287
The finalized result with its ledger, the same object generate() would
return. Optional on the interface, so an object typed as it before this
member existed still compiles; AgencyInstance.stream() returns it required.
text
text:
Promise<string>
Defined in: packages/agentos/src/api/types.ts:1255
Finalized scalar text after guardrails, HITL, and parsing hooks.
textStream
textStream:
AsyncIterable<string>
Defined in: packages/agentos/src/api/types.ts:1246
Raw live text chunks from the underlying strategy.
usage
usage:
Promise<{cacheCreationExtendedTokens?:number;cacheCreationTokens?:number;cacheReadTokens?:number;completionTokens:number;costUSD?:number;promptTokens:number;totalTokens:number; }>
Defined in: packages/agentos/src/api/types.ts:1257
Final aggregate usage for the streamed run.