Skip to content

Commit 4153036

Browse files
committed
chore: address reviewer feedback, cleanup unrelated files, and refactor to neutral env keys
1 parent e1f334f commit 4153036

7 files changed

Lines changed: 19 additions & 221 deletions

File tree

src/services/api/utils.ts

Lines changed: 0 additions & 168 deletions
This file was deleted.

src/utils/context.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,10 @@ export function getContextWindowForModel(
8181
betas?: string[],
8282
): number {
8383
// Allow override via environment variable
84-
// OPENAI_CONTEXT_WINDOW_SIZE from the active provider profile takes precedence
85-
if (process.env.OPENAI_CONTEXT_WINDOW_SIZE) {
86-
const override = parseInt(process.env.OPENAI_CONTEXT_WINDOW_SIZE, 10)
87-
if (!isNaN(override) && override > 0) {
88-
return override
89-
}
90-
}
91-
92-
// Allow override via environment variable (internal-only)
9384
// This takes precedence over all other context window resolution, including 1M detection,
9485
// so users can cap the effective context window for local decisions (auto-compact, etc.)
9586
// while still using a 1M-capable endpoint.
96-
if (
97-
process.env.USER_TYPE === 'ant' &&
98-
process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS
99-
) {
87+
if (process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
10088
const override = parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS, 10)
10189
if (!isNaN(override) && override > 0) {
10290
return override
@@ -206,15 +194,6 @@ export function getModelMaxOutputTokens(model: string): {
206194
let defaultTokens: number
207195
let upperLimit: number
208196

209-
// Allow override via environment variable
210-
// OPENAI_MAX_OUTPUT_TOKENS from the active provider profile takes precedence
211-
if (process.env.OPENAI_MAX_OUTPUT_TOKENS) {
212-
const override = parseInt(process.env.OPENAI_MAX_OUTPUT_TOKENS, 10)
213-
if (!isNaN(override) && override > 0) {
214-
return { default: override, upperLimit: override }
215-
}
216-
}
217-
218197
if (process.env.USER_TYPE === 'ant') {
219198
const antModel = resolveAntModel(model.toLowerCase())
220199
if (antModel) {

src/utils/providerProfile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ const PROFILE_ENV_KEYS = [
9393
'XAI_API_KEY',
9494
'VENICE_API_KEY',
9595
'MIMO_API_KEY',
96-
'OPENAI_CONTEXT_WINDOW_SIZE',
97-
'OPENAI_MAX_OUTPUT_TOKENS',
96+
'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
97+
'CLAUDE_CODE_MAX_OUTPUT_TOKENS',
9898
] as const
9999

100100
export type CompatibilityProfileMode =
@@ -175,8 +175,8 @@ export type ProfileEnv = {
175175
XAI_API_KEY?: string
176176
VENICE_API_KEY?: string
177177
MIMO_API_KEY?: string
178-
OPENAI_CONTEXT_WINDOW_SIZE?: string
179-
OPENAI_MAX_OUTPUT_TOKENS?: string
178+
CLAUDE_CODE_MAX_CONTEXT_TOKENS?: string
179+
CLAUDE_CODE_MAX_OUTPUT_TOKENS?: string
180180
}
181181

182182
export type ProfileFile = {

src/utils/providerProfiles.persistence.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const RESTORED_KEYS = [
1313
'CLAUDE_CODE_USE_OPENAI',
1414
'OPENAI_BASE_URL',
1515
'OPENAI_MODEL',
16-
'OPENAI_CONTEXT_WINDOW_SIZE',
17-
'OPENAI_MAX_OUTPUT_TOKENS',
16+
'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
17+
'CLAUDE_CODE_MAX_OUTPUT_TOKENS',
1818
] as const
1919

2020
type MockConfigState = {
@@ -104,8 +104,8 @@ describe('Provider Profile Persistence (Context Window & Max Tokens)', () => {
104104

105105
setActiveProviderProfile('test_params', { configDir: testConfigDir! })
106106

107-
expect(process.env.OPENAI_CONTEXT_WINDOW_SIZE).toBe('200000')
108-
expect(process.env.OPENAI_MAX_OUTPUT_TOKENS).toBe('8192')
107+
expect(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS).toBe('200000')
108+
expect(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS).toBe('8192')
109109
})
110110

111111
test('persists new parameters to .openclaude-profile.json for startup fallback', async () => {
@@ -131,8 +131,8 @@ describe('Provider Profile Persistence (Context Window & Max Tokens)', () => {
131131
const persistedPath = join(testConfigDir!, '.openclaude-profile.json')
132132
const persisted = JSON.parse(readFileSync(persistedPath, 'utf8'))
133133

134-
expect(persisted.env.OPENAI_CONTEXT_WINDOW_SIZE).toBe('64000')
135-
expect(persisted.env.OPENAI_MAX_OUTPUT_TOKENS).toBe('2048')
134+
expect(persisted.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS).toBe('64000')
135+
expect(persisted.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS).toBe('2048')
136136
})
137137

138138
test('uses empty string for unspecified parameters (no default values stored)', async () => {

src/utils/providerProfiles.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ const RESTORED_KEYS = [
6262
'VENICE_API_KEY',
6363
'MIMO_API_KEY',
6464
'HICAP_API_KEY',
65-
'OPENAI_CONTEXT_WINDOW_SIZE',
66-
'OPENAI_MAX_OUTPUT_TOKENS',
65+
'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
66+
'CLAUDE_CODE_MAX_OUTPUT_TOKENS',
6767
] as const
6868

6969
type MockConfigState = {

src/utils/providerProfiles.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,10 @@ export function applyProviderProfileToProcessEnv(profile: ProviderProfile): void
681681
}
682682

683683
if (profile.contextWindowSize) {
684-
profileEnv.OPENAI_CONTEXT_WINDOW_SIZE = String(profile.contextWindowSize)
684+
profileEnv.CLAUDE_CODE_MAX_CONTEXT_TOKENS = String(profile.contextWindowSize)
685685
}
686686
if (profile.maxOutputTokens) {
687-
profileEnv.OPENAI_MAX_OUTPUT_TOKENS = String(profile.maxOutputTokens)
687+
profileEnv.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(profile.maxOutputTokens)
688688
}
689689

690690
profileEnv = applySupportedProfileCustomHeaders(profile, profileEnv)
@@ -990,10 +990,10 @@ function buildOpenAICompatibleStartupEnv(
990990
delete env.OPENAI_API_KEY
991991
}
992992
if (activeProfile.contextWindowSize) {
993-
env.OPENAI_CONTEXT_WINDOW_SIZE = String(activeProfile.contextWindowSize)
993+
env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = String(activeProfile.contextWindowSize)
994994
}
995995
if (activeProfile.maxOutputTokens) {
996-
env.OPENAI_MAX_OUTPUT_TOKENS = String(activeProfile.maxOutputTokens)
996+
env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(activeProfile.maxOutputTokens)
997997
}
998998
return applySupportedProfileCustomHeaders(activeProfile, env)
999999
}
@@ -1159,12 +1159,12 @@ function buildStartupProfileFromActiveProfile(
11591159
}
11601160

11611161
if (activeProfile.contextWindowSize) {
1162-
startup.env.OPENAI_CONTEXT_WINDOW_SIZE = String(
1162+
startup.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = String(
11631163
activeProfile.contextWindowSize,
11641164
)
11651165
}
11661166
if (activeProfile.maxOutputTokens) {
1167-
startup.env.OPENAI_MAX_OUTPUT_TOKENS = String(activeProfile.maxOutputTokens)
1167+
startup.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(activeProfile.maxOutputTokens)
11681168
}
11691169

11701170
return startup

src/utils/ripgrep/errors.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)