@hiper2d/ai-agents 0.1.1 → 0.1.3

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.
package/dist/index.d.mts CHANGED
@@ -257,6 +257,19 @@ declare class ModelAuthenticationError extends ModelError {
257
257
  declare class ModelQuotaExceededError extends ModelError {
258
258
  constructor(message: string, modelType: string);
259
259
  }
260
+ /**
261
+ * The model failed to produce a valid response: the output was malformed (unparseable
262
+ * JSON from a structured-output ask) or cut off at the output-token cap before the
263
+ * answer was complete (`status: "incomplete"` on the OpenAI Responses API). Not a
264
+ * transport or availability problem — the request worked, the generation went wrong.
265
+ * A retry with the same prompt often succeeds; `truncated` distinguishes a cap hit
266
+ * (raise maxOutputTokens if legitimate responses genuinely need more room) from a
267
+ * degenerate/runaway generation (a bigger cap only makes failures slower).
268
+ */
269
+ declare class ModelInvalidResponseError extends ModelError {
270
+ truncated: boolean;
271
+ constructor(modelType: string, detail: string, truncated?: boolean);
272
+ }
260
273
  /**
261
274
  * The model declined to answer: Anthropic returns `stop_reason: "refusal"` with no content
262
275
  * blocks when its safety layer rejects the request as a whole. Not retryable as-is — the
@@ -1188,4 +1201,4 @@ declare class MiniMaxAgent extends AbstractAgent {
1188
1201
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1189
1202
  }
1190
1203
 
1191
- export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
1204
+ export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
package/dist/index.d.ts CHANGED
@@ -257,6 +257,19 @@ declare class ModelAuthenticationError extends ModelError {
257
257
  declare class ModelQuotaExceededError extends ModelError {
258
258
  constructor(message: string, modelType: string);
259
259
  }
260
+ /**
261
+ * The model failed to produce a valid response: the output was malformed (unparseable
262
+ * JSON from a structured-output ask) or cut off at the output-token cap before the
263
+ * answer was complete (`status: "incomplete"` on the OpenAI Responses API). Not a
264
+ * transport or availability problem — the request worked, the generation went wrong.
265
+ * A retry with the same prompt often succeeds; `truncated` distinguishes a cap hit
266
+ * (raise maxOutputTokens if legitimate responses genuinely need more room) from a
267
+ * degenerate/runaway generation (a bigger cap only makes failures slower).
268
+ */
269
+ declare class ModelInvalidResponseError extends ModelError {
270
+ truncated: boolean;
271
+ constructor(modelType: string, detail: string, truncated?: boolean);
272
+ }
260
273
  /**
261
274
  * The model declined to answer: Anthropic returns `stop_reason: "refusal"` with no content
262
275
  * blocks when its safety layer rejects the request as a whole. Not retryable as-is — the
@@ -1188,4 +1201,4 @@ declare class MiniMaxAgent extends AbstractAgent {
1188
1201
  doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
1189
1202
  }
1190
1203
 
1191
- export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
1204
+ export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
package/dist/index.js CHANGED
@@ -58,6 +58,7 @@ __export(index_exports, {
58
58
  MistralAgent: () => MistralAgent,
59
59
  ModelAuthenticationError: () => ModelAuthenticationError,
60
60
  ModelError: () => ModelError,
61
+ ModelInvalidResponseError: () => ModelInvalidResponseError,
61
62
  ModelOverloadError: () => ModelOverloadError,
62
63
  ModelQuotaExceededError: () => ModelQuotaExceededError,
63
64
  ModelRateLimitError: () => ModelRateLimitError,
@@ -836,6 +837,14 @@ var ModelQuotaExceededError = class extends ModelError {
836
837
  this.name = "ModelQuotaExceededError";
837
838
  }
838
839
  };
840
+ var ModelInvalidResponseError = class extends ModelError {
841
+ truncated;
842
+ constructor(modelType, detail, truncated = false) {
843
+ super(`${modelType} failed to produce a valid response: ${detail}`, modelType);
844
+ this.name = "ModelInvalidResponseError";
845
+ this.truncated = truncated;
846
+ }
847
+ };
839
848
  var ModelRefusalError = class extends ModelError {
840
849
  constructor(modelType, message = `${modelType} refused to answer (stop_reason: refusal)`) {
841
850
  super(message, modelType);
@@ -1036,10 +1045,11 @@ var SupportedAiModels = {
1036
1045
  tags: ["expensive"]
1037
1046
  },
1038
1047
  [LLM_CONSTANTS.GEMINI_FLASH]: {
1039
- // Repointed from gemini-3.6-flash 2026-08-13 (stable picker id, same pattern as gpt).
1040
- // 3.7 rejects thinkingLevel 'minimal' (low|medium|high only), unlike 3.5/3.6.
1041
- displayName: "Gemini 3.7 Flash",
1042
- modelApiName: "gemini-3.7-flash",
1048
+ // Repointed 3.6 → 3.7 (2026-08-13) → 3.8 (2026-09-02); stable picker id, same pattern as gpt.
1049
+ // 3.7 rejected thinkingLevel 'minimal' (low|medium|high only), unlike 3.5/3.6 — 3.8 untested
1050
+ // on 'minimal', so keep the pin at 'medium' or above.
1051
+ displayName: "Gemini 3.8 Flash",
1052
+ modelApiName: "gemini-3.8-flash",
1043
1053
  apiKeyName: API_KEY_CONSTANTS.GOOGLE,
1044
1054
  hasThinking: true,
1045
1055
  reasoningEffort: "medium",
@@ -1367,9 +1377,9 @@ var MODEL_PRICING = {
1367
1377
  extendedContextThresholdTokens: 2e5
1368
1378
  },
1369
1379
  [SupportedAiModels[LLM_CONSTANTS.GEMINI_FLASH].modelApiName]: {
1370
- // Launch pricing through 2026-12-31; doubles to $1.50/$7.50/$0.15 on 2027-01-01
1371
- // (ai.google.dev pricing page, fetched 2026-08-13) — ACTION NEEDED then: update these
1372
- // rates.
1380
+ // 3.8 Flash (2026-09-02) launched at the same rates as 3.7. 3.7's launch pricing was
1381
+ // scheduled to double to $1.50/$7.50/$0.15 on 2027-01-01 (ai.google.dev pricing page,
1382
+ // fetched 2026-08-13) — ACTION NEEDED then: re-check whether 3.8 follows and update.
1373
1383
  // Cache storage cost ($0.50 / 1M tokens per hour) is not tracked here — the
1374
1384
  // schema only models per-token call costs, not time-based storage.
1375
1385
  inputPrice: 0.75,
@@ -1902,18 +1912,37 @@ var Gpt5Agent = class extends AbstractAgent {
1902
1912
  thinking: import_zod2.z.string().describe("Your internal chain-of-thought reasoning process used to arrive at the final answer.")
1903
1913
  });
1904
1914
  }
1905
- const response = await this.client.responses.parse({
1906
- model: this.model,
1907
- instructions: this.instruction,
1908
- input,
1909
- max_output_tokens: this.maxOutputTokens,
1910
- text: {
1911
- format: (0, import_zod3.zodTextFormat)(schemaToSend, "response_schema")
1915
+ let response;
1916
+ try {
1917
+ response = await this.client.responses.parse({
1918
+ model: this.model,
1919
+ instructions: this.instruction,
1920
+ input,
1921
+ max_output_tokens: this.maxOutputTokens,
1922
+ text: {
1923
+ format: (0, import_zod3.zodTextFormat)(schemaToSend, "response_schema")
1924
+ }
1925
+ });
1926
+ } catch (error) {
1927
+ if (error instanceof SyntaxError) {
1928
+ throw new ModelInvalidResponseError(
1929
+ this.model,
1930
+ `malformed JSON output \u2014 the generation was cut off at the ${this.maxOutputTokens}-token output cap or went off the rails (${error.message})`
1931
+ );
1912
1932
  }
1913
- });
1933
+ throw error;
1934
+ }
1935
+ if (response.status === "incomplete") {
1936
+ const reason = response.incomplete_details?.reason ?? "unknown";
1937
+ throw new ModelInvalidResponseError(
1938
+ this.model,
1939
+ `response incomplete (${reason}) at max_output_tokens=${this.maxOutputTokens}`,
1940
+ reason === "max_output_tokens"
1941
+ );
1942
+ }
1914
1943
  if (!response.output_parsed) {
1915
1944
  this.logger(`Parsing failed. Raw content: ${response.output_text}`);
1916
- throw new Error(this.errorMessages.invalidFormat);
1945
+ throw new ModelInvalidResponseError(this.model, this.errorMessages.invalidFormat);
1917
1946
  }
1918
1947
  let reasoningContent = "";
1919
1948
  if (this.enableThinking && response.output_parsed.thinking) {
@@ -1952,6 +1981,9 @@ var Gpt5Agent = class extends AbstractAgent {
1952
1981
  return [response.output_parsed, reasoningContent, tokenUsage];
1953
1982
  } catch (error) {
1954
1983
  this.logger(this.logTemplates.error(this.name, error));
1984
+ if (error instanceof ModelError) {
1985
+ throw error;
1986
+ }
1955
1987
  throw new Error(this.errorMessages.apiError(error));
1956
1988
  }
1957
1989
  }
@@ -1977,6 +2009,14 @@ var Gpt5Agent = class extends AbstractAgent {
1977
2009
  });
1978
2010
  const content = response.output_text;
1979
2011
  if (!content) {
2012
+ if (response.status === "incomplete") {
2013
+ const reason = response.incomplete_details?.reason ?? "unknown";
2014
+ throw new ModelInvalidResponseError(
2015
+ this.model,
2016
+ `empty response, incomplete (${reason}) at max_output_tokens=${this.maxOutputTokens}`,
2017
+ reason === "max_output_tokens"
2018
+ );
2019
+ }
1980
2020
  throw new Error(this.errorMessages.emptyResponse);
1981
2021
  }
1982
2022
  let tokenUsage;
@@ -2009,6 +2049,9 @@ var Gpt5Agent = class extends AbstractAgent {
2009
2049
  return [content, "", tokenUsage];
2010
2050
  } catch (error) {
2011
2051
  this.logger(this.logTemplates.error(this.name, error));
2052
+ if (error instanceof ModelError) {
2053
+ throw error;
2054
+ }
2012
2055
  throw new Error(this.errorMessages.apiError(error));
2013
2056
  }
2014
2057
  }
@@ -4425,6 +4468,7 @@ var AgentFactory = class {
4425
4468
  MistralAgent,
4426
4469
  ModelAuthenticationError,
4427
4470
  ModelError,
4471
+ ModelInvalidResponseError,
4428
4472
  ModelOverloadError,
4429
4473
  ModelQuotaExceededError,
4430
4474
  ModelRateLimitError,