mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 13:53:02 -07:00
hmm extra response
This commit is contained in:
@@ -16,11 +16,7 @@ import {
|
|||||||
getDirectoryContextString,
|
getDirectoryContextString,
|
||||||
getEnvironmentContext,
|
getEnvironmentContext,
|
||||||
} from '../utils/environmentContext.js';
|
} from '../utils/environmentContext.js';
|
||||||
import {
|
import { Turn, GeminiEventType, type ServerGeminiStreamEvent } from './turn.js';
|
||||||
Turn,
|
|
||||||
GeminiEventType,
|
|
||||||
type ServerGeminiStreamEvent,
|
|
||||||
} from './turn.js';
|
|
||||||
import {
|
import {
|
||||||
CompressionStatus,
|
CompressionStatus,
|
||||||
type ChatCompressionInfo,
|
type ChatCompressionInfo,
|
||||||
@@ -562,7 +558,7 @@ export class GeminiClient {
|
|||||||
if (
|
if (
|
||||||
'type' in hookResult &&
|
'type' in hookResult &&
|
||||||
(hookResult.type === GeminiEventType.AgentExecutionStopped ||
|
(hookResult.type === GeminiEventType.AgentExecutionStopped ||
|
||||||
hookResult.type === GeminiEventType.AgentExecutionBlocked)
|
hookResult.type === GeminiEventType.AgentExecutionBlocked)
|
||||||
) {
|
) {
|
||||||
if (hookResult.type === GeminiEventType.AgentExecutionStopped) {
|
if (hookResult.type === GeminiEventType.AgentExecutionStopped) {
|
||||||
this.getChat().addHistory(createUserContent(request));
|
this.getChat().addHistory(createUserContent(request));
|
||||||
@@ -603,7 +599,7 @@ export class GeminiClient {
|
|||||||
debugLogger.debug('[PROJECT CLARITY] Re-prompt requested.');
|
debugLogger.debug('[PROJECT CLARITY] Re-prompt requested.');
|
||||||
|
|
||||||
yield* this.sendMessageStream(
|
yield* this.sendMessageStream(
|
||||||
[{ text: '[System: State updated. Please continue.]' }],
|
[],
|
||||||
signal,
|
signal,
|
||||||
prompt_id,
|
prompt_id,
|
||||||
boundedTurns - 1,
|
boundedTurns - 1,
|
||||||
|
|||||||
@@ -49,9 +49,13 @@ class CompressInvocation extends BaseToolInvocation<
|
|||||||
callId?: string,
|
callId?: string,
|
||||||
): Promise<ToolResult> {
|
): Promise<ToolResult> {
|
||||||
if (!callId) {
|
if (!callId) {
|
||||||
throw new Error('Critical error: callId is required for context compression elision.');
|
throw new Error(
|
||||||
|
'Critical error: callId is required for context compression elision.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
debugLogger.debug(`[PROJECT CLARITY] Executing CompressTool (callId: ${callId})`);
|
debugLogger.debug(
|
||||||
|
`[PROJECT CLARITY] Executing CompressTool (callId: ${callId})`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
const continuityService = this.config.getContinuityCompressionService();
|
const continuityService = this.config.getContinuityCompressionService();
|
||||||
const snapshot = await continuityService.generateSnapshot(
|
const snapshot = await continuityService.generateSnapshot(
|
||||||
@@ -61,14 +65,10 @@ class CompressInvocation extends BaseToolInvocation<
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Queue the history replacement via SideEffectService
|
// Queue the history replacement via SideEffectService
|
||||||
const sideEffects = this.config.getSideEffectService()
|
const sideEffects = this.config.getSideEffectService();
|
||||||
sideEffects.replaceHistory([]);
|
sideEffects.replaceHistory([]);
|
||||||
sideEffects.setContinuityAnchor(snapshot);
|
sideEffects.setContinuityAnchor(snapshot);
|
||||||
|
sideEffects.elideCall(callId);
|
||||||
if (callId) {
|
|
||||||
sideEffects.elideCall(callId);
|
|
||||||
}
|
|
||||||
sideEffects.reprompt();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
llmContent: `Compression successful.`,
|
llmContent: `Compression successful.`,
|
||||||
|
|||||||
@@ -49,9 +49,14 @@ class DistillResultInvocation extends BaseToolInvocation<
|
|||||||
_shellExecutionConfig?: any,
|
_shellExecutionConfig?: any,
|
||||||
ownCallId?: string,
|
ownCallId?: string,
|
||||||
): Promise<ToolResult> {
|
): Promise<ToolResult> {
|
||||||
|
if (!ownCallId) {
|
||||||
|
throw new Error('Critical error: callId is required for distill result.');
|
||||||
|
}
|
||||||
const revisedText = this.params.revised_text;
|
const revisedText = this.params.revised_text;
|
||||||
|
|
||||||
debugLogger.debug(`[PROJECT CLARITY] Executing DistillResultTool (ownCallId: ${ownCallId})`);
|
debugLogger.debug(
|
||||||
|
`[PROJECT CLARITY] Executing DistillResultTool (ownCallId: ${ownCallId})`,
|
||||||
|
);
|
||||||
|
|
||||||
// 1. Find the target: the last function response in history.
|
// 1. Find the target: the last function response in history.
|
||||||
const history = this.chat.getHistory();
|
const history = this.chat.getHistory();
|
||||||
@@ -82,15 +87,15 @@ class DistillResultInvocation extends BaseToolInvocation<
|
|||||||
throw new Error('Target call ID missing from tool response.');
|
throw new Error('Target call ID missing from tool response.');
|
||||||
}
|
}
|
||||||
|
|
||||||
debugLogger.debug(`[PROJECT CLARITY] Distill target identified: ${targetCallId} at index ${lastToolResponseIndex}`);
|
debugLogger.debug(
|
||||||
|
`[PROJECT CLARITY] Distill target identified: ${targetCallId} at index ${lastToolResponseIndex}`,
|
||||||
|
);
|
||||||
|
|
||||||
const sideEffects = this.config.getSideEffectService();
|
const sideEffects = this.config.getSideEffectService();
|
||||||
|
|
||||||
// 2. Elide all turns between that tool response and the current turn.
|
// 2. Elide all turns between that tool response and the current turn.
|
||||||
if (ownCallId) {
|
sideEffects.elideBetween(targetCallId, ownCallId);
|
||||||
sideEffects.elideBetween(targetCallId, ownCallId);
|
sideEffects.elideCall(ownCallId);
|
||||||
sideEffects.elideCall(ownCallId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Save the raw output to a temp file for safety (to avoid "self-gaslighting")
|
// 3. Save the raw output to a temp file for safety (to avoid "self-gaslighting")
|
||||||
const toolName =
|
const toolName =
|
||||||
@@ -117,7 +122,6 @@ class DistillResultInvocation extends BaseToolInvocation<
|
|||||||
};
|
};
|
||||||
|
|
||||||
sideEffects.distillResult(targetCallId, distilledResponse);
|
sideEffects.distillResult(targetCallId, distilledResponse);
|
||||||
sideEffects.reprompt();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
llmContent: 'Result distilled successfully.',
|
llmContent: 'Result distilled successfully.',
|
||||||
|
|||||||
Reference in New Issue
Block a user