diff --git a/packages/cli/src/serve/server/rate-limiter-setup.ts b/packages/cli/src/serve/server/rate-limiter-setup.ts index f1088ec34fd..dd8761e6c2c 100644 --- a/packages/cli/src/serve/server/rate-limiter-setup.ts +++ b/packages/cli/src/serve/server/rate-limiter-setup.ts @@ -25,8 +25,7 @@ export function installRateLimiter( read: { windowMs, max: opts.rateLimitRead ?? 120 }, }, hostname: opts.hostname, - workspaceQualifiedAcpEnabled: - options.workspaceQualifiedAcpEnabled === true, + workspaceQualifiedAcpEnabled: options.workspaceQualifiedAcpEnabled === true, onLimitReached: daemonLog ? (tier, key, suppressed) => { daemonLog.warn( diff --git a/packages/core/src/core/openaiContentGenerator/provider/default.test.ts b/packages/core/src/core/openaiContentGenerator/provider/default.test.ts index 010e9fed8ff..ea1a341ae3e 100644 --- a/packages/core/src/core/openaiContentGenerator/provider/default.test.ts +++ b/packages/core/src/core/openaiContentGenerator/provider/default.test.ts @@ -236,6 +236,20 @@ describe('DefaultOpenAICompatibleProvider', () => { expect(result.max_tokens).toBe(16384); }); + it('should set the 128K output default for Claude Opus 4.8', () => { + const requestWithoutMaxTokens: OpenAI.Chat.ChatCompletionCreateParams = { + model: 'vertex/claude-opus-4-8', + messages: [{ role: 'user', content: 'Hello' }], + }; + + const result = provider.buildRequest( + requestWithoutMaxTokens, + 'prompt-id', + ); + + expect(result.max_tokens).toBe(131072); + }); + it('should ignore malformed QWEN_CODE_MAX_OUTPUT_TOKENS values', () => { const request: OpenAI.Chat.ChatCompletionCreateParams = { model: 'gpt-4', diff --git a/packages/core/src/core/tokenLimits.test.ts b/packages/core/src/core/tokenLimits.test.ts index 64d1c156b78..284a3c1c0ff 100644 --- a/packages/core/src/core/tokenLimits.test.ts +++ b/packages/core/src/core/tokenLimits.test.ts @@ -142,8 +142,13 @@ describe('tokenLimit', () => { }); describe('Anthropic Claude', () => { - it('should return 200K for all Claude models', () => { - expect(tokenLimit('claude-opus-4-6')).toBe(200000); + it('should return 1M for Opus 4.6 through 4.8', () => { + expect(tokenLimit('claude-opus-4-6')).toBe(1_000_000); + expect(tokenLimit('claude-opus-4-7')).toBe(1_000_000); + expect(tokenLimit('vertex/claude-opus-4-8')).toBe(1_000_000); + }); + + it('should return 200K for other Claude models', () => { expect(tokenLimit('claude-sonnet-4-6')).toBe(200000); expect(tokenLimit('claude-sonnet-4')).toBe(200000); expect(tokenLimit('claude-opus-4')).toBe(200000); @@ -303,8 +308,10 @@ describe('tokenLimit with output type', () => { expect(tokenLimit('gemini-3-flash-preview', 'output')).toBe(65536); }); - it('should return correct output limits for Claude 4.6', () => { + it('should return correct output limits for Claude Opus 4.6 through 4.8', () => { expect(tokenLimit('claude-opus-4-6', 'output')).toBe(131072); + expect(tokenLimit('claude-opus-4-7', 'output')).toBe(131072); + expect(tokenLimit('vertex/claude-opus-4-8', 'output')).toBe(131072); expect(tokenLimit('claude-sonnet-4-6', 'output')).toBe(65536); }); }); @@ -461,6 +468,12 @@ describe('defaultOutputCeiling', () => { expect(defaultOutputCeiling('kimi-k2.5')).toBe(32_768); }); + it('allows Claude Opus 4.6 through 4.8 to use the full 128K default', () => { + expect(defaultOutputCeiling('claude-opus-4-6')).toBe(131_072); + expect(defaultOutputCeiling('claude-opus-4-7')).toBe(131_072); + expect(defaultOutputCeiling('vertex/claude-opus-4-8')).toBe(131_072); + }); + it('uses the default output limit for an unknown model', () => { expect(defaultOutputCeiling('some-unknown-model')).toBe( Math.min(DEFAULT_OUTPUT_TOKEN_LIMIT, OUTPUT_TOKEN_CEILING), diff --git a/packages/core/src/core/tokenLimits.ts b/packages/core/src/core/tokenLimits.ts index d6e07f41766..f1a727735c9 100644 --- a/packages/core/src/core/tokenLimits.ts +++ b/packages/core/src/core/tokenLimits.ts @@ -175,6 +175,7 @@ const PATTERNS: Array<[RegExp, TokenCount]> = [ // ------------------- // Anthropic Claude // ------------------- + [/^claude-opus-4-(?:6|7|8)/, LIMITS['1m']], // Opus 4.6-4.8: 1M [/^claude-/, LIMITS['200k']], // All Claude models: 200K // ------------------- @@ -244,7 +245,7 @@ const OUTPUT_PATTERNS: Array<[RegExp, TokenCount]> = [ [/^o\d/, LIMITS['128k']], // o-series: 128K // Anthropic Claude - [/^claude-opus-4-6/, LIMITS['128k']], // Opus 4.6: 128K + [/^claude-opus-4-(?:6|7|8)/, LIMITS['128k']], // Opus 4.6-4.8: 128K [/^claude-sonnet-4-6/, LIMITS['64k']], // Sonnet 4.6: 64K [/^claude-/, LIMITS['64k']], // Claude fallback: 64K @@ -338,7 +339,11 @@ export function tokenLimit( * so a model advertising >64K output is clamped consistently everywhere. */ export function defaultOutputCeiling(model: Model): TokenCount { - return Math.min(tokenLimit(model, 'output'), OUTPUT_TOKEN_CEILING); + const outputLimit = tokenLimit(model, 'output'); + if (/^claude-opus-4-(?:6|7|8)/.test(normalize(model))) { + return outputLimit; + } + return Math.min(outputLimit, OUTPUT_TOKEN_CEILING); } /** diff --git a/packages/core/src/models/modelConfigResolver.test.ts b/packages/core/src/models/modelConfigResolver.test.ts index d1f6eb00a46..dd70adda4ad 100644 --- a/packages/core/src/models/modelConfigResolver.test.ts +++ b/packages/core/src/models/modelConfigResolver.test.ts @@ -974,7 +974,7 @@ describe('modelConfigResolver', () => { }); expect(result.config.model).toBe('claude-opus-4-6'); - expect(result.config.contextWindowSize).toBe(200_000); + expect(result.config.contextWindowSize).toBe(1_000_000); expect(result.sources['contextWindowSize'].kind).toBe('computed'); }); diff --git a/packages/core/src/tools/glob.test.ts b/packages/core/src/tools/glob.test.ts index 41af3990012..33fe1dee68b 100644 --- a/packages/core/src/tools/glob.test.ts +++ b/packages/core/src/tools/glob.test.ts @@ -480,6 +480,39 @@ describe('GlobTool', () => { expect(result.llmContent).toContain('Found 2 file(s)'); }); + it('should not scan later workspace directories after hitting the collection limit', async () => { + const secondDir = await fs.mkdtemp( + path.join(os.tmpdir(), 'glob-tool-second-'), + ); + await fs.writeFile(path.join(secondDir, '.git'), ''); + const globStreamCallsBefore = vi.mocked(glob.globStream).mock.calls + .length; + const stream = mockGlobStreamResults('limit', 10_005); + + const multiDirConfig = { + ...mockConfig, + getWorkspaceContext: () => + createMockWorkspaceContext(tempRootDir, [secondDir]), + } as unknown as Config; + + try { + const invocation = new GlobTool(multiDirConfig).build({ + pattern: '*.streamlimit', + }); + const result = await invocation.execute(abortSignal); + const llmContent = partListUnionToString(result.llmContent); + + expect(vi.mocked(glob.globStream).mock.calls.length).toBe( + globStreamCallsBefore + 1, + ); + expect(stream.getYielded()).toBeLessThan(10_005); + expect(llmContent).toContain('Found at least'); + expect(llmContent).toContain('Narrow the pattern or path'); + } finally { + await fs.rm(secondDir, { recursive: true, force: true }); + } + }); + it('should use single directory description when only one workspace dir', async () => { const params: GlobToolParams = { pattern: '*.txt' }; const invocation = globTool.build(params); diff --git a/packages/core/src/tools/glob.ts b/packages/core/src/tools/glob.ts index bcb325df9c1..dcead54d4be 100644 --- a/packages/core/src/tools/glob.ts +++ b/packages/core/src/tools/glob.ts @@ -33,6 +33,10 @@ const debugLogger = createDebugLogger('GLOB'); const MAX_FILE_COUNT = 100; const MAX_GLOB_COLLECTED_ENTRIES = MAX_FILE_COUNT * 10; +const normalizePathForComparison = (p: string) => + process.platform === 'win32' || process.platform === 'darwin' + ? p.toLowerCase() + : p; // Subset of 'Path' interface provided by 'glob' that we can implement for testing export interface GlobPath { @@ -276,7 +280,7 @@ class GlobToolInvocation extends BaseToolInvocation< hitCollectionLimit ||= hitLimit; for (const entry of entries) { // Deduplicate entries that might appear in overlapping directories - const normalized = entry.fullpath(); + const normalized = normalizePathForComparison(entry.fullpath()); if (!seenPaths.has(normalized)) { seenPaths.add(normalized); allFilteredEntries.push(entry); diff --git a/packages/mobile-mcp/src/utils.ts b/packages/mobile-mcp/src/utils.ts index af019facaf5..16563819a45 100644 --- a/packages/mobile-mcp/src/utils.ts +++ b/packages/mobile-mcp/src/utils.ts @@ -96,5 +96,5 @@ export function validateOutputPath(filePath: string): void { * elements scrolled partially off-screen, so each value allows a leading `-`. */ export function stripUiBounds(xml: string): string { - return xml.replace(/ bounds="\[-?\d+,-?\d+\]\[-?\d+,-?\d+\]"/g, ""); + return xml.replace(/ bounds="\[-?\d+,-?\d+\]\[-?\d+,-?\d+\]"/g, ''); } diff --git a/packages/mobile-mcp/test/strip-ui-bounds.test.ts b/packages/mobile-mcp/test/strip-ui-bounds.test.ts index ce2b976fa23..d56464a9903 100644 --- a/packages/mobile-mcp/test/strip-ui-bounds.test.ts +++ b/packages/mobile-mcp/test/strip-ui-bounds.test.ts @@ -1,35 +1,35 @@ -import { test, expect } from "@playwright/test"; -import { stripUiBounds } from "../src/utils"; +import { test, expect } from '@playwright/test'; +import { stripUiBounds } from '../src/utils'; -test("strips positive bounds attributes", () => { - const xml = ``; - expect(stripUiBounds(xml)).toBe(``); +test('strips positive bounds attributes', () => { + const xml = ``; + expect(stripUiBounds(xml)).toBe(``); }); -test("strips negative bounds for off-screen elements", () => { - // UIAutomator reports negative coordinates for elements scrolled partially - // off-screen; these must be stripped too. - const xml = ``; - expect(stripUiBounds(xml)).toBe(``); +test('strips negative bounds for off-screen elements', () => { + // UIAutomator reports negative coordinates for elements scrolled partially + // off-screen; these must be stripped too. + const xml = ``; + expect(stripUiBounds(xml)).toBe(``); }); -test("strips every bounds attribute in the dump", () => { - const xml = ``; - expect(stripUiBounds(xml)).toBe(``); +test('strips every bounds attribute in the dump', () => { + const xml = ``; + expect(stripUiBounds(xml)).toBe(``); }); -test("leaves XML without bounds untouched", () => { - const xml = ``; - expect(stripUiBounds(xml)).toBe(xml); +test('leaves XML without bounds untouched', () => { + const xml = ``; + expect(stripUiBounds(xml)).toBe(xml); }); -test("preserves malformed bounds-like strings verbatim", () => { - // Only well-formed `[x,y][x,y]` integer pairs are stripped; anything else - // (extra coordinates, decimals, non-numeric) must pass through untouched. - const threeCoords = ``; - const decimal = ``; - const nonNumeric = ``; - expect(stripUiBounds(threeCoords)).toBe(threeCoords); - expect(stripUiBounds(decimal)).toBe(decimal); - expect(stripUiBounds(nonNumeric)).toBe(nonNumeric); +test('preserves malformed bounds-like strings verbatim', () => { + // Only well-formed `[x,y][x,y]` integer pairs are stripped; anything else + // (extra coordinates, decimals, non-numeric) must pass through untouched. + const threeCoords = ``; + const decimal = ``; + const nonNumeric = ``; + expect(stripUiBounds(threeCoords)).toBe(threeCoords); + expect(stripUiBounds(decimal)).toBe(decimal); + expect(stripUiBounds(nonNumeric)).toBe(nonNumeric); });