The finalized result type result resolves to: PanelResult for a panel agency.
Raw live text chunks from the underlying strategy.
Structured live + finalized event stream.
This includes raw text/tool/lifecycle events and also the finalized
final-output event after post-processing completes.
Finalized scalar text after guardrails, HITL, and parsing hooks.
Final aggregate usage for the streamed run.
Optional costUSD?: numberOptional cacheOptional cacheFinal per-agent execution ledger for the streamed run.
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.
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.
Optional resultThe 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.
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 answertextStreammay differ from the finalized answer when output guardrails orbeforeReturnHITL rewrite the result.finalTextStreamandtextalways reflect the finalized post-processing output.Example