@jaypie/llm 1.2.17 → 1.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,12 @@ export declare class OpenAiAdapter extends BaseProviderAdapter {
26
26
  responseToHistoryItems(response: unknown): LlmHistory;
27
27
  classifyError(error: unknown): ClassifiedError;
28
28
  isComplete(response: unknown): boolean;
29
+ /**
30
+ * Sanitize history items for the OpenAI Responses API.
31
+ * Strips fields not accepted by specific item types (e.g., `name` on
32
+ * function_call_output items) to prevent 400 "Unknown parameter" errors.
33
+ */
34
+ private sanitizeInputItems;
29
35
  private hasToolCalls;
30
36
  private extractContent;
31
37
  }
package/dist/esm/index.js CHANGED
@@ -2227,7 +2227,7 @@ class OpenAiAdapter extends BaseProviderAdapter {
2227
2227
  const model = request.model || this.defaultModel;
2228
2228
  const openaiRequest = {
2229
2229
  model,
2230
- input: request.messages,
2230
+ input: this.sanitizeInputItems(request.messages),
2231
2231
  };
2232
2232
  if (request.user) {
2233
2233
  openaiRequest.user = request.user;
@@ -2575,6 +2575,31 @@ class OpenAiAdapter extends BaseProviderAdapter {
2575
2575
  //
2576
2576
  // Private Helpers
2577
2577
  //
2578
+ /**
2579
+ * Sanitize history items for the OpenAI Responses API.
2580
+ * Strips fields not accepted by specific item types (e.g., `name` on
2581
+ * function_call_output items) to prevent 400 "Unknown parameter" errors.
2582
+ */
2583
+ sanitizeInputItems(messages) {
2584
+ return messages.map((item) => {
2585
+ const typedItem = item;
2586
+ // function_call_output only accepts: type, call_id, output, id, status
2587
+ if (typedItem.type === LlmMessageType.FunctionCallOutput) {
2588
+ const sanitized = {
2589
+ type: typedItem.type,
2590
+ call_id: typedItem.call_id,
2591
+ output: typedItem.output,
2592
+ };
2593
+ if (typedItem.id)
2594
+ sanitized.id = typedItem.id;
2595
+ if (typedItem.status)
2596
+ sanitized.status = typedItem.status;
2597
+ return sanitized;
2598
+ }
2599
+ // All other items pass through as-is
2600
+ return item;
2601
+ });
2602
+ }
2578
2603
  hasToolCalls(response) {
2579
2604
  if (!response.output || !Array.isArray(response.output)) {
2580
2605
  return false;