Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e6e7467
fix: Auto-route tool call results to messages_history
emincihangeri Jun 25, 2026
a78b377
Merge branch 'main' into investigate/tool-result-prompt-templating
emincihangeri Jun 25, 2026
02e73cb
chore: Fix lint
emincihangeri Jun 25, 2026
0170e97
Update packages/orchestration/src/util/module-config.ts
emincihangeri Jun 29, 2026
9772061
chore: Add changeset
emincihangeri Jun 29, 2026
4711464
Merge branch 'main' into investigate/tool-result-prompt-templating
emincihangeri Jun 29, 2026
ba033a7
chore: Enable ES2023 array methods in tsconfig
emincihangeri Jun 29, 2026
b733f83
Update tsconfig.json
emincihangeri Jun 29, 2026
06831ae
fix: address review comments and add message order tests
InjunPark-sap Jun 30, 2026
889db2c
fix: Changes from lint
sap-ai-sdk-bot[bot] Jun 30, 2026
00deb0c
Apply suggestions from code review
InjunPark-sap Jul 3, 2026
7c91e68
apply feedbacks from david
InjunPark-sap Jul 3, 2026
1d87214
fix: disable auto-routing when static prompt template is present
InjunPark-sap Jul 6, 2026
3022bfd
fix: also disable auto-routing when prompt has tools but no template
InjunPark-sap Jul 6, 2026
937d6d2
fix: extract split logic, skip routing when placeholder values are set
InjunPark-sap Jul 6, 2026
7615e45
chore: merge main and resolve tsconfig conflict
InjunPark-sap Jul 7, 2026
8f49bad
fix: add missing JSDoc params to getMessageSplitIndex
InjunPark-sap Jul 7, 2026
e02c07d
fix: add lib es2023 to tsconfig.base.json for findLastIndex support
InjunPark-sap Jul 7, 2026
a18ed9b
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 7, 2026
eb5dd48
fix: omit messages key entirely when no remaining messages
InjunPark-sap Jul 7, 2026
6d23c8b
Apply suggestions from code review
InjunPark-sap Jul 8, 2026
92d4897
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 8, 2026
2f31031
fix after david's feedback
InjunPark-sap Jul 8, 2026
22317d3
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 8, 2026
1b2f993
fix for ci
InjunPark-sap Jul 8, 2026
16c7c95
fix ci error
InjunPark-sap Jul 8, 2026
8cf9a2d
fix ci error
InjunPark-sap Jul 8, 2026
6048e39
fix ci error(grammar on yummy-ducks-run
InjunPark-sap Jul 8, 2026
9408eee
Merge branch 'main' into investigate/tool-result-prompt-templating
davidkna-sap Jul 9, 2026
64a6c63
Update packages/orchestration/src/util/module-config.ts
InjunPark-sap Jul 10, 2026
2901e34
fix: replace getMessageSplitIndex with shouldRouteMessagesToHistory b…
InjunPark-sap Jul 10, 2026
dca1ea8
Merge branch 'main' into investigate/tool-result-prompt-templating
InjunPark-sap Jul 10, 2026
424b462
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 10, 2026
f70451d
fix: ensure prompt exists in config when cache_control is used
InjunPark-sap Jul 10, 2026
415e1dd
fix: ensure cache_control messages stay in prompt.template
InjunPark-sap Jul 10, 2026
f15904d
fix: address david feedback on cache_control and TemplateRef routing
InjunPark-sap Jul 13, 2026
1b81ddd
Merge branch 'main' into investigate/tool-result-prompt-templating
InjunPark-sap Jul 13, 2026
780ad79
fix: rename messages to messageList to avoid variable shadowing in ca…
InjunPark-sap Jul 13, 2026
47d835e
Merge branch 'main' into investigate/tool-result-prompt-templating
InjunPark-sap Jul 15, 2026
8dc69d7
Update packages/orchestration/src/util/module-config.ts
InjunPark-sap Jul 15, 2026
2f1c629
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 15, 2026
4ee6f52
fix: prevent message duplication and respect placeholderValues before…
InjunPark-sap Jul 15, 2026
30286d2
fix: restore prompt template initialization and align unit tests with…
InjunPark-sap Jul 15, 2026
2d73010
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 15, 2026
4b4b4b6
fix: restore prompt initialization order and align tests with service…
InjunPark-sap Jul 15, 2026
1320ac5
fix: allow empty messages array, only throw when messages is undefined
InjunPark-sap Jul 15, 2026
2de8093
fix: use splitIndex routing to bypass templating for tool results
InjunPark-sap Jul 15, 2026
96c2af2
fix: Changes from lint
sap-ai-sdk-bot[bot] Jul 15, 2026
2f5d648
fix: pass empty messages array instead of removing when all messages …
InjunPark-sap Jul 15, 2026
831828a
fix: omit empty prompt.template when all messages are routed to history
InjunPark-sap Jul 15, 2026
826f5f6
fix: only route to history when there are messages after the last too…
InjunPark-sap Jul 15, 2026
76a54cd
fix: replace splitIndex with shouldRouteMessagesToHistory and add too…
InjunPark-sap Jul 16, 2026
a2a10e0
fix: fix JSDoc indentation and skip routing when prompt.tools is present
InjunPark-sap Jul 16, 2026
3fe1785
Merge branch 'main' into investigate/tool-result-prompt-templating
InjunPark-sap Jul 17, 2026
cce280b
Apply suggestions from code review
InjunPark-sap Jul 17, 2026
73d0fdd
apply feedbacks
InjunPark-sap Jul 17, 2026
8de127f
fix: Changes from generation
sap-ai-sdk-bot[bot] Jul 17, 2026
cfbaa42
Merge branch 'main' into investigate/tool-result-prompt-templating
InjunPark-sap Jul 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/yummy-ducks-run.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[req] Make sure this is up to date.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sap-ai-sdk/orchestration': patch
---

[Fix] Automatically route `messages` to `messages_history` to bypass prompt templating when no `prompt` is configured or a `TemplateRef` is used.
Routing is skipped when `placeholderValues` are provided or a prompt with `template` or `tools` is set.
187 changes: 25 additions & 162 deletions packages/langchain/src/orchestration/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,14 @@ describe('orchestration service client', () => {
delay?: number;
},
status: number = 200,
isStream?: boolean
isStream?: boolean,
inputMessages = messages
) {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
config,
{ messages: inputMessages },
isStream
)
},
Expand Down Expand Up @@ -169,7 +162,8 @@ describe('orchestration service client', () => {
mockResponseStream,
{ delay: 2000 },
200,
true
true,
[]
);

let finalOutput: AIMessageChunk | undefined;
Expand Down Expand Up @@ -403,19 +397,7 @@ describe('orchestration service client', () => {
it('supports streaming responses', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
true
)
data: constructCompletionPostRequest(config, { messages }, true)
},
{
data: mockResponseStream,
Expand All @@ -437,19 +419,7 @@ describe('orchestration service client', () => {
it('supports auto-streaming responses', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
true
)
data: constructCompletionPostRequest(config, { messages }, true)
},
{
data: mockResponseStream,
Expand All @@ -476,19 +446,7 @@ describe('orchestration service client', () => {
it('has langchain handle disabling streaming via disableStreaming flag in stream', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
false
)
data: constructCompletionPostRequest(config, { messages }, false)
},
{
data: mockResponse,
Expand Down Expand Up @@ -552,19 +510,7 @@ describe('orchestration service client', () => {
it('streams and aborts with a signal', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
true
)
data: constructCompletionPostRequest(config, { messages }, true)
},
{
data: mockResponseStream,
Expand All @@ -588,19 +534,7 @@ describe('orchestration service client', () => {
it('streams with a callback', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
true
)
data: constructCompletionPostRequest(config, { messages }, true)
},
{
data: mockResponseStream,
Expand Down Expand Up @@ -636,19 +570,7 @@ describe('orchestration service client', () => {
it('supports streaming responses with tool calls', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
true
)
data: constructCompletionPostRequest(config, { messages }, true)
},
{
data: mockResponseStreamToolCalls,
Expand Down Expand Up @@ -677,19 +599,7 @@ describe('orchestration service client', () => {
it('streams when invoked in a streaming langgraph', async () => {
mockInference(
{
data: constructCompletionPostRequest(
{
...config,
promptTemplating: {
...config.promptTemplating,
prompt: {
template: messages
}
}
},
{ messages: [] },
true
)
data: constructCompletionPostRequest(config, { messages }, true)
},
{
data: mockResponseStream,
Expand Down Expand Up @@ -755,27 +665,8 @@ describe('orchestration service client', () => {
mockInference(
{
data: constructCompletionPostRequest(
[
{
...primaryConfig,
promptTemplating: {
...primaryConfig.promptTemplating,
prompt: {
template: messages
}
}
},
{
...fallbackConfig,
promptTemplating: {
...fallbackConfig.promptTemplating,
prompt: {
template: messages
}
}
}
],
{ messages: [] }
[primaryConfig, fallbackConfig],
{ messages }
)
},
{
Expand Down Expand Up @@ -812,27 +703,8 @@ describe('orchestration service client', () => {
mockInference(
{
data: constructCompletionPostRequest(
[
{
...primaryConfig,
promptTemplating: {
...primaryConfig.promptTemplating,
prompt: {
template: messages
}
}
},
{
...fallbackConfig,
promptTemplating: {
...fallbackConfig.promptTemplating,
prompt: {
template: messages
}
}
}
],
{ messages: [] },
[primaryConfig, fallbackConfig],
{ messages },
true
)
},
Expand Down Expand Up @@ -891,9 +763,6 @@ describe('orchestration service client', () => {
...primaryConfig.promptTemplating.model.params,
stop: ['PRIMARY_STOP', 'END']
}
},
prompt: {
template: messages
}
}
},
Expand All @@ -907,14 +776,11 @@ describe('orchestration service client', () => {
...fallbackConfig.promptTemplating.model.params,
stop: ['FALLBACK_STOP', 'END']
}
},
prompt: {
template: messages
}
}
}
],
{ messages: [] }
{ messages }
)
},
{
Expand Down Expand Up @@ -1396,12 +1262,13 @@ describe('orchestration service client', () => {
expectedCacheControl: { type: string; ttl?: string }
): (body: any) => boolean {
return (body: any): boolean => {
const template =
const messageList: any[] =
body?.messages_history ??
body?.config?.modules?.prompt_templating?.prompt?.template;
if (!Array.isArray(template) || messageIdx >= template.length) {
if (!Array.isArray(messageList) || messageIdx >= messageList.length) {
return false;
}
const target = template[messageIdx];
const target = messageList[messageIdx];
if (target?.role !== 'user' || !Array.isArray(target.content)) {
return false;
}
Expand All @@ -1413,7 +1280,7 @@ describe('orchestration service client', () => {
block.cache_control?.type === expectedCacheControl.type &&
block.cache_control?.ttl === expectedCacheControl.ttl;

const otherMessagesHaveBreakpoint = template.some(
const otherMessagesHaveBreakpoint = messageList.some(
(msg: any, idx: number) =>
idx !== messageIdx && JSON.stringify(msg).includes('cache_control')
);
Expand Down Expand Up @@ -1445,12 +1312,8 @@ describe('orchestration service client', () => {
mockInference(
{
data: (body: any) => {
const template =
body?.config?.modules?.prompt_templating?.prompt?.template;
return (
Array.isArray(template) &&
!JSON.stringify(template).includes('cache_control')
);
const bodyStr = JSON.stringify(body);
return !bodyStr.includes('cache_control');
}
},
{ data: mockResponse, status: 200 },
Expand Down
Loading
Loading