@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
26 lines • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureToolCallerAllowed = ensureToolCallerAllowed;
const errors_1 = require("../errors.js");
const context_1 = require("../tracing/context.js");
function ensureToolCallerAllowed(toolCall, allowedCallers, toolName, agent) {
const caller = 'caller' in toolCall && toolCall.caller?.type === 'program'
? 'programmatic'
: 'direct';
const effectiveAllowedCallers = allowedCallers ?? ['direct'];
if (effectiveAllowedCallers.includes(caller)) {
return;
}
const message = `Model invoked tool ${toolName} with caller ${caller}, but the tool allows only ${JSON.stringify(effectiveAllowedCallers)}.`;
(0, context_1.addErrorToCurrentSpan)({
message,
data: {
agent_name: agent.name,
tool_name: toolName,
tool_call_id: 'callId' in toolCall ? toolCall.callId : undefined,
tool_caller: caller,
},
});
throw new errors_1.ModelBehaviorError(message);
}
//# sourceMappingURL=toolCaller.js.map