hmm extra response

This commit is contained in:
Your Name
2026-03-09 03:48:29 +00:00
parent 9c7ed5c0b2
commit d8d537cb64
3 changed files with 22 additions and 22 deletions

View File

@@ -16,11 +16,7 @@ import {
getDirectoryContextString,
getEnvironmentContext,
} from '../utils/environmentContext.js';
import {
Turn,
GeminiEventType,
type ServerGeminiStreamEvent,
} from './turn.js';
import { Turn, GeminiEventType, type ServerGeminiStreamEvent } from './turn.js';
import {
CompressionStatus,
type ChatCompressionInfo,
@@ -562,7 +558,7 @@ export class GeminiClient {
if (
'type' in hookResult &&
(hookResult.type === GeminiEventType.AgentExecutionStopped ||
hookResult.type === GeminiEventType.AgentExecutionBlocked)
hookResult.type === GeminiEventType.AgentExecutionBlocked)
) {
if (hookResult.type === GeminiEventType.AgentExecutionStopped) {
this.getChat().addHistory(createUserContent(request));
@@ -603,7 +599,7 @@ export class GeminiClient {
debugLogger.debug('[PROJECT CLARITY] Re-prompt requested.');
yield* this.sendMessageStream(
[{ text: '[System: State updated. Please continue.]' }],
[],
signal,
prompt_id,
boundedTurns - 1,

View File

@@ -49,9 +49,13 @@ class CompressInvocation extends BaseToolInvocation<
callId?: string,
): Promise<ToolResult> {
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 {
const continuityService = this.config.getContinuityCompressionService();
const snapshot = await continuityService.generateSnapshot(
@@ -61,14 +65,10 @@ class CompressInvocation extends BaseToolInvocation<
);
// Queue the history replacement via SideEffectService
const sideEffects = this.config.getSideEffectService()
const sideEffects = this.config.getSideEffectService();
sideEffects.replaceHistory([]);
sideEffects.setContinuityAnchor(snapshot);
if (callId) {
sideEffects.elideCall(callId);
}
sideEffects.reprompt();
sideEffects.elideCall(callId);
return {
llmContent: `Compression successful.`,

View File

@@ -49,9 +49,14 @@ class DistillResultInvocation extends BaseToolInvocation<
_shellExecutionConfig?: any,
ownCallId?: string,
): Promise<ToolResult> {
if (!ownCallId) {
throw new Error('Critical error: callId is required for distill result.');
}
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.
const history = this.chat.getHistory();
@@ -82,15 +87,15 @@ class DistillResultInvocation extends BaseToolInvocation<
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();
// 2. Elide all turns between that tool response and the current turn.
if (ownCallId) {
sideEffects.elideBetween(targetCallId, ownCallId);
sideEffects.elideCall(ownCallId);
}
sideEffects.elideBetween(targetCallId, ownCallId);
sideEffects.elideCall(ownCallId);
// 3. Save the raw output to a temp file for safety (to avoid "self-gaslighting")
const toolName =
@@ -117,7 +122,6 @@ class DistillResultInvocation extends BaseToolInvocation<
};
sideEffects.distillResult(targetCallId, distilledResponse);
sideEffects.reprompt();
return {
llmContent: 'Result distilled successfully.',