fix(openai-adapters): Fix multi-turn tools test API initialization timing

Same issue as vercel-sdk.test.ts - the beforeAll() hook runs too late.
Feature flag must be set at describe-time so the API instance is created
with the flag already active.

Fixes: Multi-turn Tool Call Test (Anthropic) failure with duplicate tool_use IDs

The test was hitting the wrong code path (non-Vercel) because the flag
wasn't set when API was constructed, causing Anthropic API errors about
duplicate tool_use blocks.

Co-authored-by: nate <nate@continue.dev>

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
continue[bot] 2025-12-10 19:19:33 +00:00
parent aaa973ab7a
commit 75044d4cdc

View file

@ -10,15 +10,15 @@ dotenv.config();
if (process.env.ANTHROPIC_API_KEY) {
describe("Multi-turn Tool Call Test (Anthropic)", () => {
beforeAll(() => {
process.env.USE_VERCEL_AI_SDK_ANTHROPIC = "true";
});
// Set feature flag at describe-time (before test collection)
process.env.USE_VERCEL_AI_SDK_ANTHROPIC = "true";
afterAll(() => {
delete process.env.USE_VERCEL_AI_SDK_ANTHROPIC;
});
test("should handle multi-turn conversation with tool calls and tool results", async () => {
// Create fresh API instance with flag already set
const api = getLlmApi({
provider: "anthropic",
apiKey: process.env.ANTHROPIC_API_KEY!,