import { getCompressionConfigForModel } from "../../utils/model-context-utils.js";
import { getSummarizerModel } from "./model-config.js";
import { MidGenerationCompressor } from "../../compression/MidGenerationCompressor.js";

//#region src/domains/run/agents/generation/compression.ts
function setupCompression(ctx, messages, sessionId, contextId, primaryModelSettings) {
	const originalMessageCount = messages.length;
	const compressionConfigResult = getCompressionConfigForModel(primaryModelSettings);
	const compressionConfig = {
		hardLimit: compressionConfigResult.hardLimit,
		safetyBuffer: compressionConfigResult.safetyBuffer,
		enabled: compressionConfigResult.enabled
	};
	const compressor = compressionConfig.enabled ? new MidGenerationCompressor(sessionId, contextId, ctx.config.tenantId, ctx.config.projectId, ctx.config.agentId, compressionConfig, getSummarizerModel(ctx.config), primaryModelSettings) : null;
	ctx.currentCompressor = compressor;
	return {
		originalMessageCount,
		compressor
	};
}

//#endregion
export { setupCompression };