Files
thu-maic--openmaic/tests/pbl/v2/runtime-thinking.test.ts
wehub-resource-sync c48612c494
CI / E2E Tests (push) Has been cancelled
CI / Lint, Typecheck & Unit Tests (push) Has been cancelled
Docs Build / Build docs site (push) Has been cancelled
Publish @openmaic packages / Build, validate & publish (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:23 +08:00

29 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { thinkingContext } from '@/lib/ai/thinking-context';
import { withThinkingDisabled } from '@/lib/pbl/v2/agents/runtime-thinking';
/**
* #669: PBL v2 runtime LLM calls must run with thinking disabled so a pinned
* model whose thinking defaults on (e.g. DeepSeek) doesn't reject the forced
* `begin_turn` tool_choice. The provider fetch wrapper reads the disabled
* config from this AsyncLocalStorage, so the contract is "the store reads
* disabled inside the wrapped call".
*/
describe('withThinkingDisabled (#669)', () => {
it('seeds the thinking AsyncLocalStorage with a disabled config', () => {
const seen = withThinkingDisabled(() => thinkingContext.getStore());
expect(seen).toEqual({ mode: 'disabled', enabled: false });
});
it('returns the wrapped callable result (so streamText/generateText pass through)', () => {
const result = withThinkingDisabled(() => 'sentinel');
expect(result).toBe('sentinel');
});
it('does not leak the disabled config outside the wrapped call', () => {
withThinkingDisabled(() => undefined);
expect(thinkingContext.getStore()).toBeUndefined();
});
});