Spaces:
Running
Running
Commit ·
2e69b0d
1
Parent(s): 0c7fcef
Restore five nearest action references
Browse files- src/agent-session.ts +1 -1
- tests/agent-chat.test.ts +2 -1
src/agent-session.ts
CHANGED
|
@@ -103,7 +103,7 @@ export async function actionReferences(db: SupabaseClient, current: ActionResult
|
|
| 103 |
score: row.score, notes: (row.annotations_notes ?? []).map((note: { note: string }) => note.note).filter((note: string) => typeof note === "string" && note.trim()) } });
|
| 104 |
}
|
| 105 |
closest.sort((a, b) => a.distance - b.distance || a.reference.action_id.localeCompare(b.reference.action_id));
|
| 106 |
-
closest.splice(
|
| 107 |
if ((examples ?? []).length < 100) break;
|
| 108 |
}
|
| 109 |
return closest.map((item) => item.reference);
|
|
|
|
| 103 |
score: row.score, notes: (row.annotations_notes ?? []).map((note: { note: string }) => note.note).filter((note: string) => typeof note === "string" && note.trim()) } });
|
| 104 |
}
|
| 105 |
closest.sort((a, b) => a.distance - b.distance || a.reference.action_id.localeCompare(b.reference.action_id));
|
| 106 |
+
closest.splice(5);
|
| 107 |
if ((examples ?? []).length < 100) break;
|
| 108 |
}
|
| 109 |
return closest.map((item) => item.reference);
|
tests/agent-chat.test.ts
CHANGED
|
@@ -153,13 +153,14 @@ test("action chat sends measurements and annotated references on every message a
|
|
| 153 |
assert.equal(analysisReads, 1);
|
| 154 |
assert.deepEqual(chats[0].context.action?.results, { metrics: measured.inActionMetrics, analytics });
|
| 155 |
assert.deepEqual(chats[0].context.action?.feedback, []);
|
| 156 |
-
const expectedReferences = ["zz-late"];
|
| 157 |
assert.deepEqual(chats[0].context.action?.references.map((item) => item.action_id), expectedReferences);
|
| 158 |
assert.ok(chats[0].context.action?.references.every((item) => item.action_type === "Pass" && item.player.gender === "female"));
|
| 159 |
const nearest = referenceReport(examples.find((item) => item.action_id === "zz-late")!);
|
| 160 |
assert.deepEqual(chats[0].context.action?.references[0].results, { metrics: nearest.inActionMetrics, analytics: nearest.rawAnalytics });
|
| 161 |
assert.equal(chats[0].context.action?.references[0].session_id, foreignSessionId, "comparisons include other accounts with their real session IDs");
|
| 162 |
assert.equal(chats[0].context.action?.references[0].score, 0);
|
|
|
|
| 163 |
assert.deepEqual(chats[0].context.action?.references[0].notes, ["Reference coach note."]);
|
| 164 |
assert.equal(referenceReads, 2, "each session is fetched once across all candidate pages");
|
| 165 |
assert.deepEqual(referenceUsers, new Set([owner, other]));
|
|
|
|
| 153 |
assert.equal(analysisReads, 1);
|
| 154 |
assert.deepEqual(chats[0].context.action?.results, { metrics: measured.inActionMetrics, analytics });
|
| 155 |
assert.deepEqual(chats[0].context.action?.feedback, []);
|
| 156 |
+
const expectedReferences = ["zz-late", "00-foreign", "08-reference", "07-reference", "06-reference"];
|
| 157 |
assert.deepEqual(chats[0].context.action?.references.map((item) => item.action_id), expectedReferences);
|
| 158 |
assert.ok(chats[0].context.action?.references.every((item) => item.action_type === "Pass" && item.player.gender === "female"));
|
| 159 |
const nearest = referenceReport(examples.find((item) => item.action_id === "zz-late")!);
|
| 160 |
assert.deepEqual(chats[0].context.action?.references[0].results, { metrics: nearest.inActionMetrics, analytics: nearest.rawAnalytics });
|
| 161 |
assert.equal(chats[0].context.action?.references[0].session_id, foreignSessionId, "comparisons include other accounts with their real session IDs");
|
| 162 |
assert.equal(chats[0].context.action?.references[0].score, 0);
|
| 163 |
+
assert.equal(chats[0].context.action?.references[1].score, null);
|
| 164 |
assert.deepEqual(chats[0].context.action?.references[0].notes, ["Reference coach note."]);
|
| 165 |
assert.equal(referenceReads, 2, "each session is fetched once across all candidate pages");
|
| 166 |
assert.deepEqual(referenceUsers, new Set([owner, other]));
|