fix(mindspace): use UUIDs for repair replies
This commit is contained in:
@@ -235,7 +235,9 @@ export async function maybeRepairH5HtmlAfterFinish({
|
|||||||
repairAttemptsBySession.set(key, attempts + 1);
|
repairAttemptsBySession.set(key, attempts + 1);
|
||||||
|
|
||||||
const prompt = buildH5HtmlRepairPrompt(evaluation);
|
const prompt = buildH5HtmlRepairPrompt(evaluation);
|
||||||
const requestId = `h5-html-repair-${crypto.randomUUID()}`;
|
// goosed validates request_id as a UUID, so repair metadata must not be
|
||||||
|
// encoded by prefixing the id. The message metadata below carries the type.
|
||||||
|
const requestId = crypto.randomUUID();
|
||||||
const userMessage = {
|
const userMessage = {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: [{ type: 'text', text: prompt }],
|
content: [{ type: 'text', text: prompt }],
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ test('maybeRepairH5HtmlAfterFinish triggers proxy reply when enabled', async ()
|
|||||||
});
|
});
|
||||||
assert.equal(result.repaired, true);
|
assert.equal(result.repaired, true);
|
||||||
assert.equal(calls.length, 1);
|
assert.equal(calls.length, 1);
|
||||||
|
assert.match(calls[0].requestId, /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
||||||
assert.match(calls[0].userMessage.content[0].text, /icon\.svg/);
|
assert.match(calls[0].userMessage.content[0].text, /icon\.svg/);
|
||||||
} finally {
|
} finally {
|
||||||
if (previous == null) delete process.env.MEMIND_H5_HTML_FINISH_GUARD;
|
if (previous == null) delete process.env.MEMIND_H5_HTML_FINISH_GUARD;
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ test('integration: H5 finish guard triggers repair prompt for invalid survey htm
|
|||||||
assert.equal(result.repaired, true);
|
assert.equal(result.repaired, true);
|
||||||
assert.equal(result.triggered, true);
|
assert.equal(result.triggered, true);
|
||||||
assert.equal(submitCalls.length, 1);
|
assert.equal(submitCalls.length, 1);
|
||||||
|
assert.match(submitCalls[0].requestId, /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
||||||
assert.match(submitCalls[0].userMessage.content[0].text, /localStorage/);
|
assert.match(submitCalls[0].userMessage.content[0].text, /localStorage/);
|
||||||
assert.match(submitCalls[0].userMessage.content[0].text, /private_data_bind_workspace_page/);
|
assert.match(submitCalls[0].userMessage.content[0].text, /private_data_bind_workspace_page/);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -646,7 +646,9 @@ export async function maybeRepairPageDataAfterFinish({
|
|||||||
repairAttemptsBySession.set(key, attempts + 1);
|
repairAttemptsBySession.set(key, attempts + 1);
|
||||||
|
|
||||||
const prompt = buildPageDataCollectRepairPrompt(afterBind);
|
const prompt = buildPageDataCollectRepairPrompt(afterBind);
|
||||||
const requestId = `page-data-repair-${crypto.randomUUID()}`;
|
// goosed validates request_id as a UUID. Keep the repair classification in
|
||||||
|
// message metadata rather than making the request id non-conformant.
|
||||||
|
const requestId = crypto.randomUUID();
|
||||||
const userMessage = {
|
const userMessage = {
|
||||||
role: 'user',
|
role: 'user',
|
||||||
content: [{ type: 'text', text: prompt }],
|
content: [{ type: 'text', text: prompt }],
|
||||||
|
|||||||
Reference in New Issue
Block a user