refactor: add context blurbs before <user_message> tags for XML protocol

Per user feedback, keep the explanatory blurbs before the user content:
- toolDeniedWithFeedback: 'The user denied this operation and responded with the message:'
- toolApprovedWithFeedback: 'The user approved this operation and responded with the message:'
- tooManyMistakes: 'You seem to be having trouble proceeding...'

Native protocol still uses status field in JSON for context.
This commit is contained in:
Hannes Rudolph 2025-12-03 21:57:45 -07:00
parent a23f1ea98a
commit 7c83546f75
2 changed files with 11 additions and 5 deletions

View file

@ -23,7 +23,7 @@ export const formatResponse = {
feedback: feedback,
})
}
return `<user_message>\n${feedback}\n</user_message>`
return `The user denied this operation and responded with the message:\n<user_message>\n${feedback}\n</user_message>`
},
toolApprovedWithFeedback: (feedback?: string, protocol?: ToolProtocol) => {
@ -33,7 +33,7 @@ export const formatResponse = {
feedback: feedback,
})
}
return `<user_message>\n${feedback}\n</user_message>`
return `The user approved this operation and responded with the message:\n<user_message>\n${feedback}\n</user_message>`
},
toolError: (error?: string, protocol?: ToolProtocol) => {
@ -82,7 +82,7 @@ Otherwise, if you have not completed the task and do not need additional informa
feedback: feedback,
})
}
return `<user_message>\n${feedback}\n</user_message>`
return `You seem to be having trouble proceeding. The user has provided the following feedback to help guide you:\n<user_message>\n${feedback}\n</user_message>`
},
missingToolParameterError: (paramName: string, protocol?: ToolProtocol) => {

View file

@ -86,8 +86,14 @@ const { toolResultMock, imageBlocksMock } = vi.hoisted(() => {
vi.mock("../../prompts/responses", () => ({
formatResponse: {
toolDenied: vi.fn(() => "The user denied this operation."),
toolDeniedWithFeedback: vi.fn((feedback?: string) => `<user_message>\n${feedback}\n</user_message>`),
toolApprovedWithFeedback: vi.fn((feedback?: string) => `<user_message>\n${feedback}\n</user_message>`),
toolDeniedWithFeedback: vi.fn(
(feedback?: string) =>
`The user denied this operation and responded with the message:\n<user_message>\n${feedback}\n</user_message>`,
),
toolApprovedWithFeedback: vi.fn(
(feedback?: string) =>
`The user approved this operation and responded with the message:\n<user_message>\n${feedback}\n</user_message>`,
),
rooIgnoreError: vi.fn(
(path: string) =>
`Access to ${path} is blocked by the .rooignore file settings. You must try to continue in the task without using this file, or ask the user to update the .rooignore file.`,