Skip to content

Commit cbfd4f0

Browse files
committed
fix: Improved agent call and vision request checks by using the last input in the body for /response endpoint
1 parent fa25aa4 commit cbfd4f0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

index.mjs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,13 @@ export async function CopilotAuthPlugin({ client }) {
8181
}
8282

8383
if(body?.input) {
84-
isAgentCall = body.input.some(
85-
(input) => (input.role && ["assistant"].includes(input.role)) || (input.type && RESPONSES_API_ALTERNATE_INPUT_TYPES.includes(input.type)),
86-
)
87-
isVisionRequest = body.input.some(
88-
(input) =>
89-
Array.isArray(input.content) &&
90-
input.content.some((part) => part.type === "input_image"),
91-
);
84+
const lastInput = body.input[body.input.length - 1];
85+
86+
const isAssistant = lastInput?.role === "assistant";
87+
const hasAgentType = lastInput?.type ? RESPONSES_API_ALTERNATE_INPUT_TYPES.includes(lastInput.type) : false;
88+
isAgentCall = isAssistant || hasAgentType;
89+
90+
isVisionRequest = Array.isArray(lastInput?.content) && lastInput.content.some((part) => part.type === "input_image");
9291
}
9392
} catch {}
9493
const headers = {

0 commit comments

Comments
 (0)