runAsync method
Runs the processor with context and mutable request.
Implementation
@override
Stream<Event> runAsync(
InvocationContext invocationContext,
LlmRequest llmRequest,
) async* {
final LlmAgent agent = invocationContext.agent as LlmAgent;
if (agent.mode == 'task' ||
agent.outputSchema == null ||
canSetNativeOutputSchema(agent)) {
return;
}
// Preserve Python parity fallback for unsupported model+tool combinations.
final SetModelResponseTool setResponseTool = SetModelResponseTool(
agent.outputSchema!,
);
llmRequest.appendTools(<SetModelResponseTool>[setResponseTool]);
llmRequest.appendInstructions(<String>[
'IMPORTANT: You have access to other tools, but you must provide '
'your final response using the set_model_response tool with the '
'required structured format. After using any other tools needed '
'to complete the task, always call set_model_response with your '
'final answer in the specified schema format.',
]);
}