MCPcopy Create free account
hub / github.com/Effect-TS/effect / encodeToolResult

Function encodeToolResult

packages/ai/google/test/GoogleLanguageModel.test.ts:18–47  ·  view source on GitHub ↗
(result: unknown)

Source from the content-addressed store, hash-verified

16})
17
18const encodeToolResult = (result: unknown) =>
19 Effect.gen(function*() {
20 const captured: Array<typeof Generated.GenerateContentRequest.Encoded> = []
21 yield* LanguageModel.generateText({
22 prompt: [{
23 role: "tool",
24 content: [{
25 type: "tool-result",
26 id: "call_1",
27 name: "tool",
28 isFailure: false,
29 providerExecuted: false,
30 result
31 }]
32 }]
33 }).pipe(
34 Effect.provide(GoogleLanguageModel.layer({ model: "gemini-2.5-flash" })),
35 Effect.provide(Layer.succeed(GoogleClient, {
36 client: null as any,
37 streamRequest: null as any,
38 generateContent: (request) =>
39 Effect.sync(() => {
40 captured.push(request)
41 return textResponse
42 }),
43 generateContentStream: null as any
44 }))
45 )
46 return captured[0].contents[0].parts![0].functionResponse!.response
47 })
48
49describe("GoogleLanguageModel", () => {
50 it.effect("wraps non-object tool results in an object", () =>

Callers 1

Calls 3

syncMethod · 0.80
pipeMethod · 0.65
provideMethod · 0.65

Tested by

no test coverage detected