Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,20 @@ export default {
if (config.autoCapture) {
api.on("agent_end", async (event: any) => {
const messages = event.messages || [];

const contentToText = (content: unknown): string => {
if (typeof content === "string") return content;
if (Array.isArray(content)) {
return content.map((part: any) => (part?.text != null ? String(part.text) : "")).join("");
}
return "";
};

for (const msg of messages) {
if (msg.role === "user" || msg.role === "assistant") {
const text = msg.content || "";

// Skip recalled memory context to prevent feedback loops
const text = contentToText(msg.content);
if (text.includes("<relevant-memories>")) continue;

// Only capture substantial messages
if (text.trim().length < 50) continue;

await client.add(text, event.agentId);
await client.add(text.trim(), event.agentId);
}
}
});
Expand Down