Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## 1.74.0 - tbd

- [ai-anthropic, ai-chat, ai-chat-ui, ai-core, ai-openai] added provider-native server-side compaction for chat sessions, modeled as a model capability (`LanguageModelMetaData.serverSideCompactionSupport`) plus layered activation: a global preference (`ai-features.chat.serverSideCompaction`, default on), a per-provider override, and a per-session override (in the session settings dialog) that wins over both. Honored by the Anthropic Messages API (beta) and the OpenAI Responses API; the compaction marker is persisted in the session, replayed on subsequent requests, surfaced as an inline chat marker, and reflected in the token-usage tooltip (cumulative usage and a "compacted Nx" count). Providers/models without the capability ignore it [#17636](https://github.com/eclipse-theia/theia/issues/17636)

## 1.73.0 - 6/25/2026

- [ai] supported deferred tool loading via provider tool search [#17449](https://github.com/eclipse-theia/theia/pull/17449)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
import { AnthropicLanguageModelsManager, AnthropicModelDescription } from '../common';
import { API_KEY_PREF, CUSTOM_ENDPOINTS_PREF, MODELS_PREF } from '../common/anthropic-preferences';
import { AICorePreferences, PREFERENCE_NAME_MAX_RETRIES } from '@theia/ai-core/lib/common/ai-core-preferences';
import { API_KEY_PREF, CUSTOM_ENDPOINTS_PREF, MODELS_PREF, SERVER_SIDE_COMPACTION_PREF } from '../common/anthropic-preferences';
import { AICorePreferences, PREFERENCE_NAME_MAX_RETRIES, PREFERENCE_NAME_SERVER_SIDE_COMPACTION } from '@theia/ai-core/lib/common/ai-core-preferences';
import { PreferenceService } from '@theia/core';
import { resolveCompactionDefault, ServerSideCompactionSetting } from '@theia/ai-core';

const ANTHROPIC_PROVIDER_ID = 'anthropic';

Expand Down Expand Up @@ -63,6 +64,8 @@ export class AnthropicFrontendApplicationContribution implements FrontendApplica
} else if (event.preferenceName === 'http.proxy') {
this.manager.setProxyUrl(this.preferenceService.get<string>('http.proxy', undefined));
this.updateAllModels();
} else if (event.preferenceName === SERVER_SIDE_COMPACTION_PREF || event.preferenceName === PREFERENCE_NAME_SERVER_SIDE_COMPACTION) {
this.updateAllModels();
} else if (event.preferenceName === CUSTOM_ENDPOINTS_PREF) {
this.handleCustomModelChanges(this.preferenceService.get<Partial<AnthropicModelDescription>[]>(CUSTOM_ENDPOINTS_PREF, []));
}
Expand Down Expand Up @@ -101,6 +104,7 @@ export class AnthropicFrontendApplicationContribution implements FrontendApplica
model.apiKey === newModel.apiKey &&
model.maxRetries === newModel.maxRetries &&
model.useCaching === newModel.useCaching &&
model.serverSideCompactionEnabledByDefault === newModel.serverSideCompactionEnabledByDefault &&
model.enableStreaming === newModel.enableStreaming));

this.manager.removeLanguageModels(...modelsToRemove.map(model => model.id));
Expand All @@ -120,19 +124,26 @@ export class AnthropicFrontendApplicationContribution implements FrontendApplica
protected createAnthropicModelDescription(modelId: string): AnthropicModelDescription {
const id = `${ANTHROPIC_PROVIDER_ID}/${modelId}`;
const maxRetries = this.aiCorePreferences.get(PREFERENCE_NAME_MAX_RETRIES) ?? 3;
const globalCompaction = this.preferenceService.get<boolean>(PREFERENCE_NAME_SERVER_SIDE_COMPACTION, true);
const compactionOverride = this.preferenceService.get<ServerSideCompactionSetting>(SERVER_SIDE_COMPACTION_PREF, 'default');
const serverSideCompactionEnabledByDefault = resolveCompactionDefault(globalCompaction, compactionOverride);

return {
id: id,
model: modelId,
apiKey: true,
enableStreaming: true,
useCaching: true,
maxRetries: maxRetries
maxRetries: maxRetries,
serverSideCompactionEnabledByDefault
};
}

protected createCustomModelDescriptionsFromPreferences(preferences: Partial<AnthropicModelDescription>[]): AnthropicModelDescription[] {
const maxRetries = this.aiCorePreferences.get(PREFERENCE_NAME_MAX_RETRIES) ?? 3;
const globalCompaction = this.preferenceService.get<boolean>(PREFERENCE_NAME_SERVER_SIDE_COMPACTION, true);
const compactionOverride = this.preferenceService.get<ServerSideCompactionSetting>(SERVER_SIDE_COMPACTION_PREF, 'default');
const serverSideCompactionEnabledByDefault = resolveCompactionDefault(globalCompaction, compactionOverride);
return preferences.reduce((acc, pref) => {
if (!pref.model || !pref.url || typeof pref.model !== 'string' || typeof pref.url !== 'string') {
return acc;
Expand All @@ -146,7 +157,8 @@ export class AnthropicFrontendApplicationContribution implements FrontendApplica
apiKey: typeof pref.apiKey === 'string' || pref.apiKey === true ? pref.apiKey : undefined,
enableStreaming: pref.enableStreaming ?? true,
useCaching: pref.useCaching ?? true,
maxRetries: pref.maxRetries ?? maxRetries
maxRetries: pref.maxRetries ?? maxRetries,
serverSideCompactionEnabledByDefault
}
];
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

export const ANTHROPIC_LANGUAGE_MODELS_MANAGER_PATH = '/services/anthropic/language-model-manager';
export const AnthropicLanguageModelsManager = Symbol('AnthropicLanguageModelsManager');

Expand All @@ -31,6 +32,8 @@ export interface AnthropicModelDescription {
useCaching: boolean;
/** Maximum number of retry attempts when a request fails. Default is 3. */
maxRetries: number;
/** Resolved default enablement of server-side compaction (global preference folded with the per-provider override). Defaults to disabled when omitted. */
serverSideCompactionEnabledByDefault?: boolean;
}
export interface AnthropicLanguageModelsManager {
apiKey: string | undefined;
Expand Down
19 changes: 18 additions & 1 deletion packages/ai-anthropic/src/common/anthropic-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/common/ai-core-preferences';
import { AI_CORE_PREFERENCES_TITLE, PREFERENCE_NAME_SERVER_SIDE_COMPACTION } from '@theia/ai-core/lib/common/ai-core-preferences';
import { LINUX_ENV_HINT, nls, PreferenceSchema } from '@theia/core';

export const API_KEY_PREF = 'ai-features.anthropic.AnthropicApiKey';
export const MODELS_PREF = 'ai-features.anthropic.AnthropicModels';
export const CUSTOM_ENDPOINTS_PREF = 'ai-features.anthropicCustom.customAnthropicModels';
export const SERVER_SIDE_COMPACTION_PREF = 'ai-features.anthropic.serverSideCompaction';

export const AnthropicPreferencesSchema: PreferenceSchema = {
properties: {
Expand All @@ -46,6 +47,22 @@ export const AnthropicPreferencesSchema: PreferenceSchema = {
type: 'string'
}
},
[SERVER_SIDE_COMPACTION_PREF]: {
type: 'string',
enum: ['default', 'enabled', 'disabled'],
enumDescriptions: [
nls.localize('theia/ai/anthropic/compaction/default', 'Follow the global chat server-side compaction setting.'),
nls.localize('theia/ai/anthropic/compaction/enabled', 'Always request server-side compaction for Anthropic models.'),
nls.localize('theia/ai/anthropic/compaction/disabled', 'Never request server-side compaction for Anthropic models.')
],
default: 'default',
markdownDescription: nls.localize('theia/ai/anthropic/compaction/description',
'Override provider-native server-side compaction for Anthropic models. "default" follows the global chat setting ' +
'({0}). When effectively enabled, the Anthropic Beta Messages API is used so the provider can summarize ' +
'older turns once the conversation grows past its threshold.',
`\`#${PREFERENCE_NAME_SERVER_SIDE_COMPACTION}#\``),
title: AI_CORE_PREFERENCES_TITLE,
},
[CUSTOM_ENDPOINTS_PREF]: {
type: 'array',
title: AI_CORE_PREFERENCES_TITLE,
Expand Down
Loading
Loading