Learn how Cedar deals with all structured objects returned from the backend.
LLMResponse
interface:
object
field is where Cedar looks for structured responses to process. It can contain:
StructuredResponseType
objectStructuredResponseType
objects for multiple operationsundefined
if no structured output was generatedobject
field are processed by the response processing system. The content
field is always added to the chat by default as a simple text message.
BaseStructuredResponseType
interface:
type
field. This field determines which processor will be used to handle the response.
ResponseProcessor
interface that ensures type safety throughout the processing pipeline:
execute
function receives your narrowly typed custom response (e.g., NotificationResponse
)validate
function receives the broadly typed StructuredResponseType
for runtime validationCustomStructuredResponseType<T, P>
type that allows you to create type-safe custom responses:
createResponseProcessor
factory function to create type-safe processors:
object
fieldtype
fieldexecute
function is called"message"
Typecontent: string
, role?: 'user' | 'assistant' | 'bot'
messageResponseProcessor
adds messages to chat"action"
TypestateKey: string
, setterKey: string
, args?: unknown[]
actionResponseProcessor
executes state actions and adds to chat"progress_update"
Typetext: string
, state: 'in_progress' | 'complete' | 'error'
progressUpdateResponseProcessor
manages progress message lifecyclecedar-os
directory, making it easier to maintain, debug, and ensure consistency across your application. Remember that processors completely override default behavior, so plan your implementations to handle all the functionality you need.