Skip to content
3 min read · 565 words

Interface: PromptAssembledObservation

Defined in: src/batteries/llm/chat_common/types.ts:399

One observation of the fully-assembled request a battery is about to send TO the model, fired the instant assembly completes and BEFORE the engine/HTTP dispatch. It is the mirror of RawGenerationObservation: that seam exposes the raw text coming back FROM the model; this one exposes the raw request going TO it. Together they let you read ground truth at both ends of the wire — e.g. to settle whether a "smart quote" in a rendered answer came from the model itself or from a downstream markdown renderer, you inspect the bytes here, not the DOM.

Remarks

This is a pure observability tap — it returns void, never mutates the request, and never throws into the generation path (the adapter swallows callback errors). It fires once per terminal generation (one per non-streamed turn; one per stream, at dispatch), across ALL five LLM batteries.

Handed back AS-IS — no redaction. The observation carries the request exactly as assembled. The ADK does not scrub credentials, headers, or any other field for you: what you put on the request is what you see here, and if you route this to a persistent sink (a log, localStorage, a file) you may persist secrets that rode the request (an apiKey, Authorization header, etc.). That is your responsibility to handle, not the battery's — the ADK surfaces the truth and lets you decide what to do with it. (In practice the API batteries strip ADK-control keys like apiKey out of the wire body before this fires, but that is incidental to how the body is built, not a guarantee.)

Properties

PropertyTypeDescriptionDefined in
batterystringWhich battery assembled this request (e.g. 'litert_lm', 'openai_chat_completions').src/batteries/llm/chat_common/types.ts:401
kind"rendered-prompt" | "request-body"The shape of the assembled request. 'rendered-prompt' for the on-device batteries (transformers.js, LiteRT-LM), which render a preface string + a messages array for the engine; 'request-body' for the API batteries (OpenAI-compatible, Ollama, WebLLM), which POST a JSON body.src/batteries/llm/chat_common/types.ts:407
messagesunknownThe per-turn messages exactly as handed to the engine (on-device) or placed on the wire (API): the engine's message array, or the request body's messages.src/batteries/llm/chat_common/types.ts:418
preface?unknownOn-device leading/system content rendered ahead of the timeline (e.g. the LiteRT preface object, which carries the assembled system message text and — for native tool delivery — the tool list), when applicable. Its concrete shape is battery-specific; captured verbatim. Absent for the API batteries.src/batteries/llm/chat_common/types.ts:413
requestBody?unknownAPI batteries only: the complete assembled request body, exactly as it will be sent (see the AS-IS / no-redaction note above). Absent for the on-device batteries.src/batteries/llm/chat_common/types.ts:428
streamedbooleanWhether this generation streams its response (vs. a single batch call).src/batteries/llm/chat_common/types.ts:430
streamIdstringThe adapter's stream/message id for this generation, for correlating with other telemetry.src/batteries/llm/chat_common/types.ts:432
tools?unknownThe tool declarations exactly as dispatched: the rendered <tool_definitions> prompt text (on-device prompt-delivery) or the wire tools array (API / native tool delivery). Absent when no tools are sent.src/batteries/llm/chat_common/types.ts:423