Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🤖 fix(Assistants): Ensure Required Actions always have Outputs (#3031)

Danny Avila08b8ae120eca
diff --git a/api/server/services/Runs/StreamRunManager.js b/api/server/services/Runs/StreamRunManager.js
index bea8042aef..f19c73d736 100644
--- a/api/server/services/Runs/StreamRunManager.js
+++ b/api/server/services/Runs/StreamRunManager.js
@@ -497,6 +497,34 @@ class StreamRunManager {
return `${stepId}_tool_call_${toolCall.index}_${toolCall.type}`;
}
+ /**
+ * Check Missing Outputs
+ * @param {ToolOutput[]} tool_outputs - The tool outputs.
+ * @param {RequiredAction[]} actions - The required actions.
+ * @returns {ToolOutput[]} completeOutputs - The complete outputs.
+ */
+ checkMissingOutputs(tool_outputs, actions) {
+ const missingOutputs = [];
+
+ for (const item of actions) {
+ const { tool, toolCallId, run_id, thread_id } = item;
+ const outputExists = tool_outputs.some((output) => output.tool_call_id === toolCallId);
+
+ if (!outputExists) {
+ logger.warn(
+ `The "${tool}" tool (ID: ${toolCallId}) failed to produce an output. run_id: ${run_id} thread_id: ${thread_id}`,
+ );
+ missingOutputs.push({
+ tool_call_id: toolCallId,
+ output:
+ 'The tool failed to produce an output. The tool may not be currently available or experienced an unhandled error.',
+ });
+ }
+ }
+
+ return [...tool_outputs, ...missingOutputs];
+ }
+
/* <------------------ Run Event handlers ------------------> */
/**
@@ -519,7 +547,8 @@ class StreamRunManager {
};
});
- const { tool_outputs } = await processRequiredActions(this, actions);
+ const { tool_outputs: preliminaryOutputs } = await processRequiredActions(this, actions);
+ const tool_outputs = this.checkMissingOutputs(preliminaryOutputs, actions);
/** @type {AssistantStream | undefined} */
let toolRun;
try {