refactor: pluginize text cleaning and tool NoMemory control

- SDK: ToolDef.NoMemory field, PluginSDK.RegisterTextCleaner/TextCleaners
- Registry: aggregate text cleaners from plugins, expose CleanText()
- Memory: replace hardcoded QQ regex CleanTemplateText with dynamic CleanText/SetTextCleaner
- StageHost: add ToolDef(name) lookup
- eventloop: check ToolDef.NoMemory before emitMemoryCandidate
- context/Prune: replace hardcoded agentcli/terminal source filter with ToolsUsed NoMemory check
- agentcli/cmd: mark tools with NoMemory: true
- main.go: wire memory.SetTextCleaner(pluginReg.CleanText)
This commit is contained in:
root
2026-07-24 14:49:08 +08:00
parent 40a46c7376
commit f4147f81d7
32 changed files with 2368 additions and 69 deletions

View File

@ -205,7 +205,7 @@ func (a *Agent) processMediaInput(evt *agentIO.InputEvent) {
a.emitResponse(evt, response)
if !stageCtx.NoMemory {
if !stageCtx.NoMemory && !a.hasNoMemoryTool(toolsUsed) {
a.emitMemoryCandidate(evt.Source, fallback, response, toolsUsed)
}
}
@ -334,7 +334,7 @@ func (a *Agent) processTextInput(evt *agentIO.InputEvent, input string) {
a.emitResponse(evt, response)
if !stageCtx.NoMemory {
if !stageCtx.NoMemory && !a.hasNoMemoryTool(toolsUsed) {
a.emitMemoryCandidate(evt.Source, input, response, toolsUsed)
}
}
@ -386,6 +386,15 @@ func (a *Agent) emitResponse(evt *agentIO.InputEvent, response string) {
a.runStage(sdk.StageAfterOutput, stageCtx)
}
func (a *Agent) hasNoMemoryTool(toolsUsed []string) bool {
for _, name := range toolsUsed {
if def := a.stageHost.ToolDef(name); def != nil && def.NoMemory {
return true
}
}
return false
}
func (a *Agent) drainInterrupts() []string {
var out []string
for {