adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
50 lines (49 loc) • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExitLoopTool = void 0;
exports.exitLoop = exitLoop;
const FunctionTool_1 = require("./FunctionTool");
/**
* Function to exit a loop in an agent's execution
*
* @param params Parameters for the function (not used)
* @param context The tool context
* @returns A message confirming the loop exit
*/
function exitLoop(params, context) {
// Set the escalate action on the context
if (context.get) {
const actions = (context.get('actions') || {});
actions.escalate = true;
context.set('actions', actions);
}
else if (context.actions) {
context.actions.escalate = true;
}
return Promise.resolve('Exiting the loop as requested');
}
/**
* Tool for exiting loops in an agent's execution
*/
class ExitLoopTool extends FunctionTool_1.FunctionTool {
/**
* Creates a new exit loop tool
*/
constructor() {
super({
name: 'exit_loop',
description: 'Exits the loop. Call this function only when you are instructed to do so.',
fn: exitLoop,
functionDeclaration: {
name: 'exit_loop',
description: 'Exits the loop. Call this function only when you are instructed to do so.',
parameters: {
type: 'object',
properties: {},
required: []
}
}
});
}
}
exports.ExitLoopTool = ExitLoopTool;