deepagents 1.10.5 → 1.10.6

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.
@@ -424,16 +424,19 @@ function grepMatchesFromFiles(files, pattern, path = null, glob = null) {
424
424
  /**
425
425
  * Determine MIME type from a file path's extension.
426
426
  *
427
- * Returns "application/octet-stream" for unknown extensions so that
428
- * binary files are not accidentally treated as text (grep, read_file,
429
- * etc. rely on {@link isTextMimeType} which would return true for
430
- * "text/plain").
427
+ * Defaults to "text/plain" for unknown extensions. Only the known non-text
428
+ * formats above (images, audio, video, PDF/PPT) are treated as binary by
429
+ * {@link isTextMimeType}; everything else reads as text, including source files
430
+ * with uncommon extensions (.properties, .scss, .tf) and extension-less files
431
+ * (Dockerfile, mvnw). This avoids base64-encoding text into document blocks,
432
+ * which the model can't read and which the Anthropic provider rejects with a
433
+ * 400.
431
434
  *
432
435
  * @param filePath - File path to inspect
433
- * @returns MIME type string (e.g., "image/png", "application/octet-stream")
436
+ * @returns MIME type string (e.g., "image/png", "text/plain")
434
437
  */
435
438
  function getMimeType(filePath) {
436
- return MIME_TYPES[extname(filePath).toLocaleLowerCase()] || "application/octet-stream";
439
+ return MIME_TYPES[extname(filePath).toLocaleLowerCase()] || "text/plain";
437
440
  }
438
441
  /**
439
442
  * Check whether a MIME type represents text content.
@@ -2336,11 +2339,16 @@ function returnCommandWithStateUpdate(result, toolCallId) {
2336
2339
  let content;
2337
2340
  if (result.structuredResponse != null) content = JSON.stringify(result.structuredResponse);
2338
2341
  else {
2339
- const messages = result.messages;
2340
- content = (messages?.[messages.length - 1])?.content || "Task completed";
2341
- if (Array.isArray(content)) {
2342
- content = content.filter((block) => !INVALID_TOOL_MESSAGE_BLOCK_TYPES.includes(block.type));
2343
- if (content.length === 0) content = "Task completed";
2342
+ const messages = result.messages ?? [];
2343
+ content = "Task completed";
2344
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
2345
+ const message = messages[i];
2346
+ if (!message || !_langchain_core_messages.AIMessage.isInstance(message)) continue;
2347
+ const text = typeof message.content === "string" ? message.content.trim() : message.text?.trim() ?? "";
2348
+ if (text) {
2349
+ content = text;
2350
+ break;
2351
+ }
2344
2352
  }
2345
2353
  }
2346
2354
  return new _langchain_langgraph.Command({ update: {
@@ -2702,6 +2710,30 @@ function isAnthropicModel(model) {
2702
2710
  return model.getName() === "ChatAnthropic";
2703
2711
  }
2704
2712
  /**
2713
+ * Detect whether a model is an AWS Bedrock Converse model.
2714
+ *
2715
+ * Accepts the wider `RunnableInterface` shape (the type of `request.model`
2716
+ * inside `wrapModelCall`, aliased as `AgentLanguageModelLike` in langchain)
2717
+ * because the function only depends on `.getName()`, which is part of the
2718
+ * Runnable contract. `BaseLanguageModel` extends `Runnable`, so existing
2719
+ * call sites still type-check.
2720
+ */
2721
+ function isBedrockConverseModel(model) {
2722
+ if (typeof model === "string") {
2723
+ const colonIdx = model.indexOf(":");
2724
+ if (colonIdx !== -1) {
2725
+ const prefix = model.slice(0, colonIdx);
2726
+ if (prefix === "bedrock" || prefix === "aws") return true;
2727
+ }
2728
+ return model.startsWith("amazon.");
2729
+ }
2730
+ if (model.getName() === "ConfigurableModel") {
2731
+ const provider = model._defaultConfig?.modelProvider;
2732
+ return provider === "bedrock" || provider === "aws";
2733
+ }
2734
+ return model.getName() === "ChatBedrockConverse";
2735
+ }
2736
+ /**
2705
2737
  * Extract the provider name from a model instance for profile lookup.
2706
2738
  *
2707
2739
  * Checks `_defaultConfig.modelProvider` (ConfigurableModel) and falls
@@ -5782,10 +5814,17 @@ function createDeepAgent(params = {}) {
5782
5814
  const toolOverrides = harnessProfile.toolDescriptionOverrides;
5783
5815
  const effectiveTools = Object.keys(toolOverrides).length > 0 ? tools.map((t) => t.name in toolOverrides ? Object.assign(Object.create(Object.getPrototypeOf(t)), t, { description: toolOverrides[t.name] }) : t) : tools;
5784
5816
  const anthropicModel = isAnthropicModel(model);
5785
- const cacheMiddleware = anthropicModel ? [(0, langchain.anthropicPromptCachingMiddleware)({
5786
- unsupportedModelBehavior: "ignore",
5787
- minMessagesToCache: 1
5788
- }), createCacheBreakpointMiddleware()] : [];
5817
+ const bedrockModel = isBedrockConverseModel(model);
5818
+ let cacheMiddleware = [];
5819
+ if (anthropicModel) cacheMiddleware = [
5820
+ ...cacheMiddleware,
5821
+ (0, langchain.anthropicPromptCachingMiddleware)({
5822
+ unsupportedModelBehavior: "ignore",
5823
+ minMessagesToCache: 1
5824
+ }),
5825
+ createCacheBreakpointMiddleware()
5826
+ ];
5827
+ if (bedrockModel) cacheMiddleware = [...cacheMiddleware, (0, langchain.bedrockPromptCachingMiddleware)({ unsupportedModelBehavior: "ignore" })];
5789
5828
  /**
5790
5829
  * Process subagents to add SkillsMiddleware for those with their own skills.
5791
5830
  *
@@ -7636,4 +7675,4 @@ Object.defineProperty(exports, "serializeProfile", {
7636
7675
  }
7637
7676
  });
7638
7677
 
7639
- //# sourceMappingURL=langsmith-ZfNZ_Pyb.cjs.map
7678
+ //# sourceMappingURL=langsmith-Cpzy6cFq.cjs.map