Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

test: add generate_cover_letter selection rows to the agent chat eval suite

Khuram Niaza7b2364ac51f
diff --git a/evals/agent-chat/assertions.ts b/evals/agent-chat/assertions.ts
index ed2cd8e..90abd4d 100644
--- a/evals/agent-chat/assertions.ts
+++ b/evals/agent-chat/assertions.ts
@@ -141,10 +141,19 @@ export function assertCallsMatchJob(output: unknown): AssertionResult {
return { pass, score: pass ? 1 : 0, reason: pass ? 'called match_job' : `expected one match_job call, got: ${describe(calls)}` };
}
+export function assertCallsCoverLetter(output: unknown): AssertionResult {
+ const calls = parseToolCalls(output);
+ const pass = calls.length === 1 && calls[0].name === 'generate_cover_letter';
+ return { pass, score: pass ? 1 : 0, reason: pass ? 'called generate_cover_letter' : `expected one generate_cover_letter call, got: ${describe(calls)}` };
+}
+
+const NESTED = ['review_resume', 'match_job', 'generate_cover_letter'];
+
// Two nested generations in one step serialize on Ollama past the turn
-// deadline and lose both, so the prompt asks for one per turn. This measures it.
+// deadline; the guard makes the second return busy, and the prompt asks for one
+// per turn so it does not come to that. This measures it.
export function assertOneNestedCall(output: unknown): AssertionResult {
- const nested = parseToolCalls(output).filter((c) => c.name === 'review_resume' || c.name === 'match_job');
+ const nested = parseToolCalls(output).filter((c) => NESTED.includes(c.name));
const pass = nested.length === 1;
return { pass, score: pass ? 1 : 0, reason: pass ? `called ${nested[0].name} alone` : `expected exactly one nested call, got: ${describe(nested)}` };
}
diff --git a/evals/agent-chat/promptfooconfig.yaml b/evals/agent-chat/promptfooconfig.yaml
index 2561da4..11b4283 100644
--- a/evals/agent-chat/promptfooconfig.yaml
+++ b/evals/agent-chat/promptfooconfig.yaml
@@ -259,3 +259,38 @@ tests:
assert:
- type: javascript
value: file://./assertions.ts:assertOneNestedCall
+
+ # The cover letter flow's only step: one tool call, and the app does the rest.
+ - description: Cover letter request - calls generate_cover_letter
+ vars:
+ userMessage: Write me a cover letter for this job.
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertCallsCoverLetter
+
+ # What the job page's Cover Letter button will send once Task 5 rewires it.
+ # It is the primary entry point, so it is measured rather than assumed.
+ - description: Cover letter button phrasing - calls generate_cover_letter
+ vars:
+ userMessage: Write a cover letter for Senior Backend Engineer at Northwind Cloud
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertCallsCoverLetter
+
+ # Different wording for the same intent, and the one most likely to be
+ # answered with prose instead of a tool call.
+ - description: Letter-of-application wording - still generate_cover_letter
+ vars:
+ userMessage: Can you draft a letter of application I can send with this?
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertCallsCoverLetter
+
+ # A letter is not a match. This is the row that catches a tool description
+ # that blurs the two job-page tools.
+ - description: Match and letter at once - exactly one nested tool call
+ vars:
+ userMessage: How well do I match this job, and write me a cover letter.
+ assert:
+ - type: javascript
+ value: file://./assertions.ts:assertOneNestedCall
diff --git a/evals/agent-chat/tools.ts b/evals/agent-chat/tools.ts
index e576fde..6af0ee1 100644
--- a/evals/agent-chat/tools.ts
+++ b/evals/agent-chat/tools.ts
@@ -2,6 +2,7 @@ import { z } from 'zod';
import { AGENT_TOOL_DESCRIPTIONS } from '../../src/lib/agent/prompt';
import {
AgentAddJobSchema,
+ AgentCoverLetterSchema,
AgentGetResumeSchema,
AgentMatchJobSchema,
AgentReviewResumeSchema,
@@ -43,6 +44,14 @@ export function getTools() {
parameters: z.toJSONSchema(AgentMatchJobSchema, { io: 'input' }),
},
},
+ {
+ type: 'function',
+ function: {
+ name: 'generate_cover_letter',
+ description: AGENT_TOOL_DESCRIPTIONS.generate_cover_letter,
+ parameters: z.toJSONSchema(AgentCoverLetterSchema, { io: 'input' }),
+ },
+ },
];
}