Creates a function to navigate to a triage agent for a specific client, handling navigation, message execution, and tool output.
The factory generates a handler that checks navigation state, commits tool outputs with accept/reject messages, and triggers execution or emission based on provided parameters.
It operates outside any existing method or execution contexts to ensure isolation, leveraging beginContext for a clean execution scope.
Logs the navigation operation if logging is enabled in the global configuration.
Throws
If neither flushMessage nor executeMessage is provided, or if any internal operation (e.g., navigation, commit, or execution) fails.
Example
// Create a navigation handler with a static flush message constnavigate = awaitcreateNavigateToTriageAgent({ flushMessage:"Session reset for triage.", toolOutputAccept:"Navigation completed.", }); awaitnavigate("tool-123", "client-456"); // Navigates to default agent, commits custom tool output, and emits the flush message if applicable.
Example
// Create a navigation handler with dynamic messages constnavigate = awaitcreateNavigateToTriageAgent({ executeMessage: (clientId, agent) =>`Processing ${clientId} on ${agent}`, toolOutputReject: (clientId, agent) =>`No navigation needed for ${clientId}`, }); awaitnavigate("tool-789", "client-012"); // Commits dynamic reject message and executes the message if already on the default agent.
Creates a function to navigate to a triage agent for a specific client, handling navigation, message execution, and tool output. The factory generates a handler that checks navigation state, commits tool outputs with accept/reject messages, and triggers execution or emission based on provided parameters. It operates outside any existing method or execution contexts to ensure isolation, leveraging
beginContext
for a clean execution scope. Logs the navigation operation if logging is enabled in the global configuration.Throws
If neither
flushMessage
norexecuteMessage
is provided, or if any internal operation (e.g., navigation, commit, or execution) fails.Example
Example