Preview native LLM runtime stack (#27114)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { NodeFileSystem } from "@effect/platform-node"
|
||||
import { expect } from "bun:test"
|
||||
import { tool } from "ai"
|
||||
import { Cause, Effect, Exit, Fiber, Layer } from "effect"
|
||||
import path from "path"
|
||||
import z from "zod"
|
||||
import type { Agent } from "../../src/agent/agent"
|
||||
import { Agent as AgentSvc } from "../../src/agent/agent"
|
||||
import { Bus } from "../../src/bus"
|
||||
@@ -661,6 +663,71 @@ it.live("session.processor effect tests compact on structured context overflow",
|
||||
),
|
||||
)
|
||||
|
||||
it.live("session.processor effect tests complete AI SDK tool calls when native flag is off", () =>
|
||||
provideTmpdirServer(
|
||||
({ dir, llm }) =>
|
||||
Effect.gen(function* () {
|
||||
const { processors, session, provider } = yield* boot()
|
||||
|
||||
yield* llm.tool("lookup", { query: "weather" })
|
||||
|
||||
const chat = yield* session.create({})
|
||||
const parent = yield* user(chat.id, "tool")
|
||||
const msg = yield* assistant(chat.id, parent.id, path.resolve(dir))
|
||||
const mdl = yield* provider.getModel(ref.providerID, ref.modelID)
|
||||
const handle = yield* processors.create({
|
||||
assistantMessage: msg,
|
||||
sessionID: chat.id,
|
||||
model: mdl,
|
||||
})
|
||||
|
||||
const value = yield* handle.process({
|
||||
user: {
|
||||
id: parent.id,
|
||||
sessionID: chat.id,
|
||||
role: "user",
|
||||
time: parent.time,
|
||||
agent: parent.agent,
|
||||
model: { providerID: ref.providerID, modelID: ref.modelID },
|
||||
} satisfies MessageV2.User,
|
||||
sessionID: chat.id,
|
||||
model: mdl,
|
||||
agent: agent(),
|
||||
system: [],
|
||||
messages: [{ role: "user", content: "tool" }],
|
||||
tools: {
|
||||
lookup: tool({
|
||||
description: "Look up information",
|
||||
inputSchema: z.object({ query: z.string() }),
|
||||
execute: async (input) => ({
|
||||
title: "Weather lookup",
|
||||
output: `result:${input.query}`,
|
||||
metadata: { source: "test" },
|
||||
}),
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
const parts = MessageV2.parts(msg.id)
|
||||
const call = parts.find((part): part is MessageV2.ToolPart => part.type === "tool")
|
||||
|
||||
expect(value).toBe("continue")
|
||||
expect(yield* llm.calls).toBe(1)
|
||||
expect(call?.callID).toBe("call_1")
|
||||
expect(call?.tool).toBe("lookup")
|
||||
expect(call?.state.status).toBe("completed")
|
||||
if (call?.state.status !== "completed") return
|
||||
expect(call.state.input).toEqual({ query: "weather" })
|
||||
expect(call.state.output).toBe("result:weather")
|
||||
expect(call.state.title).toBe("Weather lookup")
|
||||
expect(call.state.metadata).toEqual({ source: "test" })
|
||||
expect(call.state.time.start).toBeDefined()
|
||||
expect(call.state.time.end).toBeDefined()
|
||||
}),
|
||||
{ git: true, config: (url) => providerCfg(url) },
|
||||
),
|
||||
)
|
||||
|
||||
it.live("session.processor effect tests mark pending tools as aborted on cleanup", () =>
|
||||
provideTmpdirServer(
|
||||
({ dir, llm }) =>
|
||||
|
||||
Reference in New Issue
Block a user