feat: improve memory service logging and per-assistant configuration

- Enhance memory search logging with structured context in MemoryProcessor
- Add per-assistant memory configuration support in MemoryService
- Reduce log verbosity in StreamProcessingService (debug to silly)
- Fix memory search to use assistant's memoryUserId when available

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vaayne 2025-08-02 11:42:29 +08:00
parent 7328664edf
commit 3aec08d650
3 changed files with 15 additions and 5 deletions

View File

@ -238,12 +238,10 @@ export class MemoryProcessor {
limit
})
logger.debug(
`Searching memories with query: ${query} for user: ${userId} and assistant: ${assistantId} result: ${result}`
)
logger.debug('Searching memories successful', { query, userId, assistantId, result })
return result.results
} catch (error) {
logger.error('Error searching memories:', error as Error)
logger.error('Searching memories error:', { error })
return []
}
}

View File

@ -12,6 +12,8 @@ import {
MemorySearchResult
} from '@types'
import { getAssistantById } from './AssistantService'
const logger = loggerService.withContext('MemoryService')
// Main process SearchResult type (matches what the IPC actually returns)
@ -186,6 +188,16 @@ class MemoryService {
userId: this.currentUserId
}
// If agentId is provided, resolve userId from assistant's memoryUserId
if (optionsWithUser.agentId) {
const assistant = getAssistantById(optionsWithUser.agentId)
if (assistant) {
optionsWithUser.userId = assistant.memoryUserId || this.currentUserId
}
}
logger.debug('Searching memories start with options', { query: query, options: optionsWithUser })
try {
const result: SearchResult = await window.api.memory.search(query, optionsWithUser)

View File

@ -51,7 +51,7 @@ export function createStreamProcessor(callbacks: StreamProcessorCallbacks = {})
return (chunk: Chunk) => {
try {
const data = chunk
logger.debug('data: ', data)
logger.silly('data: ', data)
switch (data.type) {
case ChunkType.BLOCK_COMPLETE: {
if (callbacks.onComplete) callbacks.onComplete(AssistantMessageStatus.SUCCESS, data?.response)