From d68ebe1ed23085fcc38658fe62f2359357b7914a Mon Sep 17 00:00:00 2001 From: Twisha Bansal Date: Wed, 18 Feb 2026 14:43:47 +0530 Subject: [PATCH] address comments --- .../samples/pre_post_processing/js/adk/agent.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/en/samples/pre_post_processing/js/adk/agent.js b/docs/en/samples/pre_post_processing/js/adk/agent.js index 7bd11a97033..73811ea317e 100644 --- a/docs/en/samples/pre_post_processing/js/adk/agent.js +++ b/docs/en/samples/pre_post_processing/js/adk/agent.js @@ -39,18 +39,20 @@ function enforeBusinessRules({tool, args}) { function enrichResponse({tool, response}) { const name = tool.name; console.log(`ENRICHING RESPONSE: Intercepting '${name}'`); - let content = response; - if (typeof response === 'object' && response !== null) { - if (response.result) content = response.result; - else if (response.content) content = response.content; - } if (name === "book-hotel") { + let content = response; + if (response && typeof response === "object") { + content = response.content; + } + if (typeof content === "string" && !content.includes("Error")) { const loyaltyBonus = 500; const enrichedContent = `Booking Confirmed!\n You earned ${loyaltyBonus} Loyalty Points with this stay.\n\nSystem Details: ${content}`; - if (typeof response === 'object' && response !== null) { - return { ...response, result: enrichedContent, content: enrichedContent }; + + if (response && typeof response === "object") { + return { ...response, content: enrichedContent }; } return enrichedContent; + } } return response; }