From 4d3708fbdfbd507bc53e2fc5508c1265b17851c6 Mon Sep 17 00:00:00 2001 From: musistudio Date: Thu, 25 Sep 2025 23:11:33 +0800 Subject: [PATCH] fix log bug --- src/agents/image.agent.ts | 9 ++++++++- src/index.ts | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/agents/image.agent.ts b/src/agents/image.agent.ts index 7df4718..e25db29 100644 --- a/src/agents/image.agent.ts +++ b/src/agents/image.agent.ts @@ -13,7 +13,7 @@ class ImageCache { constructor(maxSize = 100) { this.cache = new LRUCache({ max: maxSize, - ttl: 24 * 60 * 60 * 1000, + ttl: 5 * 60 * 1000, }); } @@ -130,6 +130,12 @@ export class ImageAgent implements IAgent { delete args.imageId; } + const userMessage = context.req.body.messages[context.req.body.messages.length - 1] + if (userMessage.role === 'user' && Array.isArray(userMessage.content)) { + const msgs = userMessage.content.filter(item => item.type === 'text' && !item.text.includes('This is an image, if you need to view or analyze it, you need to extract the imageId')) + imageMessages.push(...msgs) + } + if (Object.keys(args).length > 0) { imageMessages.push({ type: "text", @@ -137,6 +143,7 @@ export class ImageAgent implements IAgent { }); } + // Send to analysis agent and get response const agentResponse = await fetch(`http://127.0.0.1:${context.config.PORT}/v1/messages`, { method: "POST", diff --git a/src/index.ts b/src/index.ts index 7ffdadc..67148b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -139,11 +139,11 @@ async function run(options: RunOptions = {}) { // Add global error handlers to prevent the service from crashing process.on("uncaughtException", (err) => { - server.log.error("Uncaught exception:", err); + server.logger.error("Uncaught exception:", err); }); process.on("unhandledRejection", (reason, promise) => { - server.log.error("Unhandled rejection at:", promise, "reason:", reason); + server.logger.error("Unhandled rejection at:", promise, "reason:", reason); }); // Add async preHandler hook for authentication server.addHook("preHandler", async (req, reply) => {