Skip to content

/docs/context/compaction.mdx 第二层的SessionMemory存在错误 #186

@yongzheJIN

Description

@yongzheJIN

SessionMemory

在文档中,这边声明了在第二层摘要模型中 bold几个关键词不需要调用摘要模型,但根据这边的提示他是去异步队列中获取了一个已经summary出来的结果然后替换内容。他并不是不调用摘要模型来形成摘要,只是非同步卡顿。而是通过异步的subagent队列去发起任务,来完成对主线程的人物来进行摘要

根据第一部分sessionMemomy 357行到375行

export function initSessionMemory(): void {
	if (getIsRemoteMode()) return
	// Session memory is used for compaction, so respect auto-compact settings
	const autoCompactEnabled = isAutoCompactEnabled()

	// Log initialization state (ant-only to avoid noise in external logs)
	if (process.env.USER_TYPE === 'ant') {
		logEvent('tengu_session_memory_init', {
			auto_compact_enabled: autoCompactEnabled,
		})
	}

	if (!autoCompactEnabled) {
		return
	}

	// Register hook unconditionally - gate check happens lazily when hook runs
	registerPostSamplingHook(extractSessionMemory)
}

他开启了registerPostSamplingHook,然后根据extractSessionMemory的源码
typescript 272行到350行 关键行如下

	const setupContext = createSubagentContext(toolUseContext)
       ....
	await runForkedAgent({
		promptMessages: [createUserMessage({content: userPrompt})],
		cacheSafeParams: createCacheSafeParams(context),
		canUseTool: createMemoryFileCanUseTool(memoryPath),
		querySource: 'session_memory',
		forkLabel: 'session_memory',
		overrides: {readFileState: setupContext.readFileState},
	})

是开启了一个异步线程来跑摘要模型而非不调用摘要模型

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions