mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-17 09:40:46 +00:00
fix(qa-lab): harden mock telegram prompt routing
This commit is contained in:
@@ -1853,6 +1853,99 @@ describe("qa mock openai server", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("lets the latest exact marker prompt beat stale Telegram session_status history", async () => {
|
||||
const server = await startQaMockOpenAiServer({
|
||||
host: "127.0.0.1",
|
||||
port: 0,
|
||||
});
|
||||
cleanups.push(async () => {
|
||||
await server.stop();
|
||||
});
|
||||
|
||||
const response = await fetch(`${server.baseUrl}/v1/responses`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
stream: false,
|
||||
input: [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "input_text",
|
||||
text: "Telegram current session_status QA check. Call session_status with sessionKey set to current.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "input_text",
|
||||
text: "Telegram reply-chain marker QA. Reply exactly: QA-TELEGRAM-REPLY-CHAIN-OK",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.json()).toMatchObject({
|
||||
output: [
|
||||
{
|
||||
content: [{ text: "QA-TELEGRAM-REPLY-CHAIN-OK" }],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("does not repeat stale Telegram session_status for later ordinary prompts", async () => {
|
||||
const server = await startQaMockOpenAiServer({
|
||||
host: "127.0.0.1",
|
||||
port: 0,
|
||||
});
|
||||
cleanups.push(async () => {
|
||||
await server.stop();
|
||||
});
|
||||
|
||||
const response = await fetch(`${server.baseUrl}/v1/responses`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
stream: false,
|
||||
input: [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "input_text",
|
||||
text: "Telegram current session_status QA check. Call session_status with sessionKey set to current.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "input_text",
|
||||
text: "@sut Telegram QA mention routing check. Reply with a short acknowledgement.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
const payload = await response.json();
|
||||
expect(JSON.stringify(payload)).not.toContain("QA-TELEGRAM-CURRENT-SESSION");
|
||||
});
|
||||
|
||||
it("uses exact marker directives from request context when the latest user text is generic", async () => {
|
||||
const server = await startQaMockOpenAiServer({
|
||||
host: "127.0.0.1",
|
||||
|
||||
@@ -1421,7 +1421,16 @@ async function buildResponsesPayload(
|
||||
exactMarkerDirective ?? exactReplyDirective ?? "QA-GROUP-FALLBACK-OK",
|
||||
);
|
||||
}
|
||||
if (QA_TELEGRAM_CURRENT_SESSION_STATUS_PROMPT_RE.test(allInputText)) {
|
||||
if (/\bmarker\b/i.test(prompt) && exactReplyDirective) {
|
||||
return buildAssistantEvents(exactReplyDirective);
|
||||
}
|
||||
if (/\bmarker\b/i.test(prompt) && exactMarkerDirective) {
|
||||
return buildAssistantEvents(exactMarkerDirective);
|
||||
}
|
||||
const isTelegramCurrentSessionStatusTurn =
|
||||
QA_TELEGRAM_CURRENT_SESSION_STATUS_PROMPT_RE.test(prompt) ||
|
||||
(Boolean(toolOutput) && QA_TELEGRAM_CURRENT_SESSION_STATUS_PROMPT_RE.test(allInputText));
|
||||
if (isTelegramCurrentSessionStatusTurn) {
|
||||
if (!toolOutput && hasDeclaredTool(body, "session_status")) {
|
||||
return buildToolCallEventsWithArgs("session_status", { sessionKey: "current" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user