deepagents 1.16.5 → 1.17.0

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.
@@ -32,13 +32,14 @@ let _langchain_core_runnables = require("@langchain/core/runnables");
32
32
  let zod = require("zod");
33
33
  zod = __toESM(zod, 1);
34
34
  let langchain_chat_models_universal = require("langchain/chat_models/universal");
35
+ let _langchain_langgraph_zod = require("@langchain/langgraph/zod");
36
+ let _langchain_core_utils_types = require("@langchain/core/utils/types");
35
37
  let yaml = require("yaml");
36
38
  yaml = __toESM(yaml, 1);
37
39
  let _langchain_core_tools = require("@langchain/core/tools");
38
40
  let _langchain_core_language_models_base = require("@langchain/core/language_models/base");
39
41
  let _langchain_core_utils_function_calling = require("@langchain/core/utils/function_calling");
40
42
  let _langchain_core_utils_json_schema = require("@langchain/core/utils/json_schema");
41
- let _langchain_core_utils_types = require("@langchain/core/utils/types");
42
43
  let _langchain_langgraph_sdk = require("@langchain/langgraph-sdk");
43
44
  let langsmith_traceable = require("langsmith/traceable");
44
45
  let langsmith = require("langsmith");
@@ -5150,6 +5151,45 @@ function createPatchToolCallsMiddleware() {
5150
5151
  * This module provides pre-configured ReducedValue instances that can be
5151
5152
  * reused across different state schemas, similar to LangGraph's messagesValue.
5152
5153
  */
5154
+ const deltaFields = { messages: new _langchain_langgraph.DeltaValue(_langchain_langgraph.MessagesDeltaValue.valueSchema, {
5155
+ inputSchema: _langchain_langgraph.MessagesDeltaValue.inputSchema,
5156
+ reducer: _langchain_langgraph.MessagesDeltaValue.reducer,
5157
+ snapshotFrequency: 50,
5158
+ jsonSchemaExtra: _langchain_langgraph.MessagesDeltaValue.jsonSchemaExtra
5159
+ }) };
5160
+ const defaultStateSchema = new _langchain_langgraph.StateSchema(deltaFields);
5161
+ /**
5162
+ * The state schema of a deep agent or subagent: the caller's fields, plus the
5163
+ * delta channels for every key the caller leaves out.
5164
+ *
5165
+ * A zod schema is copied field by field the way LangChain's `createAgent` reads
5166
+ * one, keeping reducers registered on zod v4 fields, because a StateSchema
5167
+ * cannot hold a zod object. Anything else `createAgent` ignores, so it is
5168
+ * ignored here too. This follows `createAgentState` in langchain 1.6.0
5169
+ * (`dist/agents/annotation.js`); recheck it when langchain changes how it
5170
+ * reads a state schema.
5171
+ */
5172
+ function deepAgentStateSchema(stateSchema) {
5173
+ if (_langchain_langgraph.StateSchema.isInstance(stateSchema)) return new _langchain_langgraph.StateSchema({
5174
+ ...deltaFields,
5175
+ ...stateSchema.fields
5176
+ });
5177
+ if (!(0, _langchain_core_utils_types.isInteropZodObject)(stateSchema)) return defaultStateSchema;
5178
+ const fields = {};
5179
+ for (const [key, field] of Object.entries((0, _langchain_core_utils_types.getInteropZodObjectShape)(stateSchema))) {
5180
+ const reducer = (0, _langchain_core_utils_types.isZodSchemaV4)(field) ? _langchain_langgraph_zod.schemaMetaRegistry.get(field)?.reducer : void 0;
5181
+ if (reducer === void 0) fields[key] = field;
5182
+ else if (reducer.schema === void 0) fields[key] = new _langchain_langgraph.ReducedValue(field, { reducer: reducer.fn });
5183
+ else fields[key] = new _langchain_langgraph.ReducedValue(field, {
5184
+ inputSchema: reducer.schema,
5185
+ reducer: reducer.fn
5186
+ });
5187
+ }
5188
+ return new _langchain_langgraph.StateSchema({
5189
+ ...deltaFields,
5190
+ ...fields
5191
+ });
5192
+ }
5153
5193
  /**
5154
5194
  * Shared ReducedValue for file data state management.
5155
5195
  *
@@ -7239,24 +7279,45 @@ function describeAsyncSubAgent(spec) {
7239
7279
  return `- ${spec.name}: ${spec.description}${suffix}`;
7240
7280
  }
7241
7281
  /**
7282
+ * Streaming for the runs this middleware starts on this deployment.
7283
+ *
7284
+ * An app that shows a subagent's thread, or the parent's thread after a
7285
+ * notification, joins runs it didn't start, and a join gets only what the run
7286
+ * streams. Like an app's own runs, these stream tokens and subgraphs, and keep
7287
+ * their events for a late join.
7288
+ */
7289
+ const STREAM_OPTIONS = {
7290
+ streamMode: [
7291
+ "values",
7292
+ "updates",
7293
+ "messages-tuple",
7294
+ "custom"
7295
+ ],
7296
+ streamSubgraphs: true,
7297
+ streamResumable: true
7298
+ };
7299
+ /**
7242
7300
  * The `runs.create` options that link a run to this agent and set the subagent's webhook.
7243
7301
  *
7244
- * A subagent on this deployment runs with this agent's context. The Agent Server
7245
- * takes `context` or `configurable`, not both, so the parent reference then goes
7246
- * through the thread's metadata.
7302
+ * A subagent on this deployment runs with this agent's context, and streams with
7303
+ * `STREAM_OPTIONS`. The Agent Server takes `context` or `configurable`, not both,
7304
+ * so the parent reference then goes through the thread's metadata.
7247
7305
  */
7248
7306
  function runOptions(spec, runtime) {
7249
- const webhook = spec.webhook ? { webhook: spec.webhook } : {};
7307
+ const options = {
7308
+ ...spec.url ? {} : STREAM_OPTIONS,
7309
+ ...spec.webhook ? { webhook: spec.webhook } : {}
7310
+ };
7250
7311
  const context = spec.url ? void 0 : forwardedContext(runtime.context);
7251
7312
  if (context) return {
7252
- ...webhook,
7313
+ ...options,
7253
7314
  context
7254
7315
  };
7255
7316
  const reference = referenceFor(spec, runtime.config);
7256
7317
  return Object.keys(reference).length > 0 ? {
7257
- ...webhook,
7318
+ ...options,
7258
7319
  config: { configurable: { [PARENT_KEY]: reference } }
7259
- } : webhook;
7320
+ } : options;
7260
7321
  }
7261
7322
  /** A run context as JSON data for another run, without deepagents' parent reference. */
7262
7323
  function forwardedContext(context) {
@@ -7458,6 +7519,7 @@ async function awakeParent(parentThreadId, assistantId, update, context) {
7458
7519
  await client.runs.create(parentThreadId, assistantId, {
7459
7520
  input: { messages: [notificationMessage(update)] },
7460
7521
  multitaskStrategy: "reject",
7522
+ ...STREAM_OPTIONS,
7461
7523
  ...context ? { context } : {}
7462
7524
  });
7463
7525
  } catch {}
@@ -8971,7 +9033,7 @@ function createDeepAgent(params = {}) {
8971
9033
  return (0, langchain.createAgent)({
8972
9034
  model,
8973
9035
  ...finalSystemPrompt !== "" && { systemPrompt: finalSystemPrompt },
8974
- stateSchema,
9036
+ stateSchema: deepAgentStateSchema(stateSchema),
8975
9037
  tools: effectiveTools,
8976
9038
  middleware,
8977
9039
  ...responseFormat !== null && { responseFormat },
@@ -11451,4 +11513,4 @@ Object.defineProperty(exports, "skillsMetadataValue", {
11451
11513
  }
11452
11514
  });
11453
11515
 
11454
- //# sourceMappingURL=langsmith-CR3a2-Z7.cjs.map
11516
+ //# sourceMappingURL=langsmith-Fjf2fY1X.cjs.map