Configuration parameters for the navigation handler.
Configuration parameters for creating a navigation handler to a specific agent. Defines optional messages or functions to handle flush, emission, execution, and tool output scenarios during navigation, incorporating the last user message where applicable.
INavigateToAgentParams
Optional
emitMessage?: Optional message or function to emit when navigation occurs without execution. If a function, it receives the client ID, last user message, and agent name, returning a string or promise of a string.
Optional
executeMessage?: Optional message or function to execute when navigation occurs with execution. If a function, it receives the client ID, last user message, and agent name, returning a string or promise of a string.
Optional
flushMessage?: string | (clientId: string, defaultAgent: string) => string | Promise<string>Optional message or function to emit after flushing the session. If a function, it receives the client ID and agent name, returning a string or promise of a string. Defaults to a generic retry message.
Optional
toolOutput?: string | (clientId: string, agentName: string) => string | Promise<string>Optional message or function for tool output when navigation occurs. If a function, it receives the client ID and agent name, returning a string or promise of a string. Defaults to a message indicating successful navigation.
A promise resolving to a function that handles navigation to the specified agent.
Creates a function to navigate to a specified agent for a given client, handling navigation, message execution, emission, and tool output. The factory generates a handler that checks navigation state, retrieves the last user message, commits tool outputs, and triggers execution or emission based on provided parameters. It validates the presence of either
emitMessage
orexecuteMessage
to ensure proper navigation behavior. Logs the navigation operation if logging is enabled in the global configuration.Throws
If neither
emitMessage
norexecuteMessage
is provided, or if any internal operation (e.g., navigation, commit, or execution) fails.Example
Example