feat: Added tutorial and warnings for langchain orchestration template - #572
feat: Added tutorial and warnings for langchain orchestration template#572BrigittaK307 wants to merge 9 commits into
Conversation
| id: langgraph-orchestration-client | ||
| title: Using Orchestration Client in LangGraph Workflows | ||
| sidebar_label: Orchestration Client in LangGraph |
There was a problem hiding this comment.
| id: langgraph-orchestration-client | |
| title: Using Orchestration Client in LangGraph Workflows | |
| sidebar_label: Orchestration Client in LangGraph | |
| id: langgraph-template-orchestration-client | |
| title: Using Orchestration Templates in LangGraph Agents | |
| sidebar_label: Using Orchestration Templates in LangGraph Agents |
| } | ||
| }); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
[pp] As a tutorial, I would prefer if there was something e.g. at the bottom for both that shows how to combine these into an actual LangGraph (or maybe createAgent()...)
| :::warning | ||
| When using `template`, its messages are **always prepended** to every `invoke()` or `stream()` call — reusing the same client across multiple turns causes the template to appear on every request. | ||
| When using `template_ref`, any messages passed are **automatically routed to `messages_history`** and cannot be merged into the remotely stored template. | ||
| In both cases, use the **two-client pattern** from the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client): one client with the template for the first turn, a second without it for follow-up turns. | ||
| ::: |
There was a problem hiding this comment.
| :::warning | |
| When using `template`, its messages are **always prepended** to every `invoke()` or `stream()` call — reusing the same client across multiple turns causes the template to appear on every request. | |
| When using `template_ref`, any messages passed are **automatically routed to `messages_history`** and cannot be merged into the remotely stored template. | |
| In both cases, use the **two-client pattern** from the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client): one client with the template for the first turn, a second without it for follow-up turns. | |
| ::: | |
| When using `template`, its messages are **always prepended** to every `invoke()` or `stream()` call — reusing the same client across multiple turns causes the template to appear on every request. | |
| When using `template_ref`, any messages passed are **automatically routed to `messages_history`** and cannot be merged into the remotely stored template. | |
| In both cases, you can use the **two-client pattern** from the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) to avoid related issues while taking advantage of the prompt registry: one client with the template for the first turn, a second without it for follow-up turns. |
| .addConditionalEdges(START, routeByTurn, [ | ||
| 'firstTurnNode', | ||
| 'conversationNode' | ||
| ]) | ||
| .addEdge('firstTurnNode', END) | ||
| .addEdge('conversationNode', END) |
There was a problem hiding this comment.
[pp] I think there should be edge from START -> firstTurnNode -> conversationNode with a conditional edge from conversationNode to itself or END (in this case perhaps just END).
There was a problem hiding this comment.
The graph re-enters from START on every graph.invoke() call. Adapting the firstTurnNode → conversationNode case would cause both nodes to fire on turn 1, making two LLM calls instead of one.
| When using the `template_ref` property, messages passed to the `chatCompletion()` or `stream()` methods are automatically appended to the `messages_history` array as they cannot be merged into the stored prompt template. | ||
| The `messages` property defined in the `template` array are appended after any existing `messagesHistory` entries. | ||
| :::warning | ||
| Messages passed alongside a `template_ref` are **automatically routed to `messages_history`** and cannot be merged into the remotely stored template. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for the recommended two-client pattern in multi-turn workflows. |
There was a problem hiding this comment.
| Messages passed alongside a `template_ref` are **automatically routed to `messages_history`** and cannot be merged into the remotely stored template. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for the recommended two-client pattern in multi-turn workflows. | |
| Messages passed alongside a `template_ref` are **automatically routed to `messages_history`** and cannot be merged into the remotely stored template. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for the recommended two-client pattern in multi-turn workflows with template references. |
| When initializing the client with an orchestration configuration reference, any messages passed to the `chatCompletion()` or `stream()` methods are automatically appended to the `messages_history` array as they cannot be merged into the stored configuration's prompt template. | ||
| The `messages` property defined in the `template` array are appended after any existing `messagesHistory` entries. | ||
| :::warning | ||
| Messages passed alongside a configuration reference are **automatically routed to `messages_history`** and cannot be merged into the remotely stored configuration's prompt template. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for the recommended two-client pattern in multi-turn workflows. |
There was a problem hiding this comment.
| Messages passed alongside a configuration reference are **automatically routed to `messages_history`** and cannot be merged into the remotely stored configuration's prompt template. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for the recommended two-client pattern in multi-turn workflows. | |
| Messages passed alongside a configuration reference are **automatically routed to `messages_history`** and cannot be merged into the remotely stored configuration's prompt template. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for the recommended two-client pattern in multi-turn workflows with configuration references. |
| The `promptTemplating.prompt.template` messages defined in the client configuration are static - they are always included in every `chatCompletion()` request. | ||
| For more dynamic prompts, i.e., you want to vary the full message list per request without re-initializing the client, use the `messages` property instead. | ||
| :::warning | ||
| Template messages are **always prepended** to every request. Reusing the same client across multiple turns will include the template on every call. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for how to avoid duplication in multi-turn workflows. |
There was a problem hiding this comment.
| Template messages are **always prepended** to every request. Reusing the same client across multiple turns will include the template on every call. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for how to avoid duplication in multi-turn workflows. | |
| Template messages are **always prepended** to every request. Reusing the same client across multiple turns will include the template on every call. See the [LangGraph tutorial](../tutorials/langgraph-template-orchestration-client) for how to avoid duplication in multi-turn workflows with prompt templates. |
| const agent = createAgent({ | ||
| model: clientWithTemplate, | ||
| tools: [], | ||
| checkpointSaver: new MemorySaver() |
There was a problem hiding this comment.
| checkpointSaver: new MemorySaver() | |
| checkpointer: new MemorySaver() |
Related to https://github.com/orgs/SAP/projects/111/views/1?pane=issue&itemId=141534346&issue=SAP%7Cai-sdk-js-backlog%7C438