Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/github-tools/src/evaluation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ function evaluationModel(answer: (options: Experimental_EvaluationModelV4CallOpt
return { model, calls }
}

// ai 7.0.133 hands providers the state as parts, so an object arrives as [{ type: 'json', value }].
function evaluationState({ state }: Experimental_EvaluationModelV4CallOptions): unknown {
if (Array.isArray(state) && state.length === 1 && state[0]?.type === 'json') return state[0].value
return state
}

const messages: ModelMessage[] = [
{ role: 'user', content: 'Label issue 12 as a bug' },
{ role: 'assistant', content: 'Reading the issue.' },
Expand Down Expand Up @@ -60,7 +66,7 @@ describe("requireApproval: 'auto'", () => {
const input = { owner: 'vercel', repo: 'ai', issueNumber: 12, labels: ['bug'] }

await expect((tools.addLabels.needsApproval as NeedsApproval)(input, { toolCallId: '1', messages })).resolves.toBe(false)
expect(calls[0]!.state).toMatchObject({
expect(evaluationState(calls[0]!)).toMatchObject({
request: 'Add the bug label to vercel/ai#12',
toolCall: { tool: 'addLabels', input },
})
Expand Down Expand Up @@ -124,7 +130,7 @@ describe("createGithubAgent({ preset: 'auto' })", () => {
const system = calls[0]!.prompt.find(message => message.role === 'system')
return {
questions: Object.keys(evaluation.calls[0]!.questions),
request: evaluation.calls[0]!.state,
request: evaluationState(evaluation.calls[0]!),
tools: (calls[0]!.tools ?? []).map(tool => tool.name),
system: system?.content,
}
Expand Down
Loading