Skip to content

Commit

Permalink
fix: correctly pass through the forceTool option inside `KurtCache.…
Browse files Browse the repository at this point in the history
…generateRawEvents`

Prior to this commit, that option was being silently dropped because it was neglected in the new
object that gets sent to the internal adapter. This commit introduces a usage of the spread operator
to ensure that no such options are dropped (while still allowing the replacement of other options).
  • Loading branch information
jemc committed Dec 10, 2024
1 parent 2ac7233 commit 3de51b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/kurt-cache/spec/KurtCache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ class StubAdapter
}
forceTool?: string
}) {
// If there are tools, expect the forceTool to be set, because these tests
// don't use the "optional tools" feature. This lets us ensure that the
// forceTool is set correctly in the tests that use it.
if (Object.keys(options.tools).length > 0) {
expect(options.forceTool).toBeDefined()
}

// Emit the next canned response.
for (const bytes of this.nextCannedResponse()) {
yield { bytes }
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kurt-cache/src/KurtCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ export class KurtCache<A extends KurtAdapter>
),
},
adapter.generateRawEvents({
...options,
messages: adapter.transformToRawMessages(options.messages),
sampling: options.sampling,
tools: Object.fromEntries(
Object.entries(options.tools).map(([name, tool]) => [
name,
Expand Down

0 comments on commit 3de51b2

Please sign in to comment.