Skip to content

Commit 57e6e74

Browse files
authored
feat(langchain/agents): canJumpTo hook param (#9218)
1 parent 3cfc4fb commit 57e6e74

19 files changed

+739
-670
lines changed

libs/langchain/src/agents/ReactAgent.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import type {
6262
ToAnnotationRoot,
6363
} from "./middleware/types.js";
6464
import { type ResponseFormatUndefined } from "./responses.js";
65+
import { getHookConstraint } from "./middleware/utils.js";
6566

6667
// Helper type to get the state definition with middleware states
6768
type MergedAgentState<
@@ -257,7 +258,7 @@ export class ReactAgent<
257258
beforeAgentNodes.push({
258259
index: i,
259260
name,
260-
allowed: m.beforeAgentJumpTo,
261+
allowed: getHookConstraint(m.beforeAgent),
261262
});
262263
allNodeWorkflows.addNode(
263264
name,
@@ -273,7 +274,7 @@ export class ReactAgent<
273274
beforeModelNodes.push({
274275
index: i,
275276
name,
276-
allowed: m.beforeModelJumpTo,
277+
allowed: getHookConstraint(m.beforeModel),
277278
});
278279
allNodeWorkflows.addNode(
279280
name,
@@ -289,7 +290,7 @@ export class ReactAgent<
289290
afterModelNodes.push({
290291
index: i,
291292
name,
292-
allowed: m.afterModelJumpTo,
293+
allowed: getHookConstraint(m.afterModel),
293294
});
294295
allNodeWorkflows.addNode(
295296
name,
@@ -305,7 +306,7 @@ export class ReactAgent<
305306
afterAgentNodes.push({
306307
index: i,
307308
name,
308-
allowed: m.afterAgentJumpTo,
309+
allowed: getHookConstraint(m.afterAgent),
309310
});
310311
allNodeWorkflows.addNode(
311312
name,

libs/langchain/src/agents/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ export { createMiddleware } from "./middleware.js";
435435
export type {
436436
ToolCallRequest,
437437
ToolCallHandler,
438-
ToolCallWrapper,
438+
WrapToolCallHook,
439439
} from "./middleware/types.js";
440440
export { FakeToolCallingModel } from "./tests/utils.js";
441441
export type { ReactAgent } from "./ReactAgent.js";

0 commit comments

Comments
 (0)