Files
genai-toolbox/docs/en/samples/pre_post_processing/js.md
Twisha Bansal e88e29b602 add docs link
2026-02-09 12:31:33 +05:30

1.7 KiB

title, type, weight, description
title type weight description
Javascript docs 2 How to add pre- and post- processing to your Agents using JS.

Prerequisites

This tutorial assumes that you have set up Toolbox with a basic agent as described in the local quickstart.

This guide demonstrates how to implement these patterns in your Toolbox applications.

Implementation

{{< tabpane persist=header >}} {{% tab header="ADK" text=true %}} Coming soon. {{% /tab %}} {{% tab header="Langchain" text=true %}} The following example demonstrates how to use ToolboxClient with LangChain's middleware to implement pre- and post- processing for tool calls.

{{< include "js/langchain/agent.js" >}}

You can also use the wrapModel hook to intercept messages before and after model calls. You can also use node-style hooks to intercept messages at the agent and model level. See the LangChain Middleware documentation for details on these additional hook types.

For more information, see the LangChain Middleware documentation. {{% /tab %}} {{< /tabpane >}}

Results

The output should look similar to the following. Note that exact responses may vary due to the non-deterministic nature of LLMs and differences between orchestration frameworks.

AI: Booking Confirmed! You earned 500 Loyalty Points with this stay.

AI: Error: Maximum stay duration is 14 days.