chore: Debug-Log aus send_to_session entfernen
This commit is contained in:
1 parent
e374c70c89
commit
c5f2ed54fd
1 file changed
+1
-16
+1
-16
@@ -729,19 +729,11 @@ public class ToolService
|
||||
}
|
||||
case "send_to_session":
|
||||
{
|
||||
var debugLog = "/tmp/gott_send_to_session.log";
|
||||
void Log(string msg) { try { File.AppendAllText(debugLog, $"[{DateTime.Now:HH:mm:ss}] {msg}\n"); } catch {} }
|
||||
Log($"Tool aufgerufen – sessionId={sessionId}, agentId={agentId}, userId={userId}");
|
||||
Log($"db={db != null}, chatService={chatService != null}, anthropicService={anthropicService != null}, telegramService={telegramService != null}");
|
||||
|
||||
if (db == null || chatService == null || anthropicService == null)
|
||||
{
|
||||
Log("ABBRUCH: db/chatService/anthropicService ist null");
|
||||
return "Fehler: send_to_session nicht verfügbar";
|
||||
}
|
||||
|
||||
var sessionIdOrName = input.GetProperty("session_id_or_name").GetString() ?? "";
|
||||
var message = input.GetProperty("message").GetString() ?? "";
|
||||
Log($"sessionIdOrName={sessionIdOrName}, message={message}");
|
||||
if (string.IsNullOrEmpty(sessionIdOrName))
|
||||
return "Fehler: session_id_or_name fehlt";
|
||||
if (string.IsNullOrEmpty(message))
|
||||
@@ -749,10 +741,8 @@ public class ToolService
|
||||
|
||||
// Ziel-Session per ID oder Name suchen (instanzweit, kein User-Check)
|
||||
var targetSession = await db.GetSession(sessionIdOrName);
|
||||
Log($"GetSession={targetSession?.SessionId ?? "null"}");
|
||||
if (targetSession == null)
|
||||
targetSession = await db.GetSessionByName(sessionIdOrName);
|
||||
Log($"GetSessionByName={targetSession?.SessionId ?? "null"}");
|
||||
if (targetSession == null)
|
||||
return $"Fehler: Session '{sessionIdOrName}' nicht gefunden";
|
||||
|
||||
@@ -762,14 +752,12 @@ public class ToolService
|
||||
|
||||
// Context für Ziel-Session vorbereiten (analog zu CronjobService)
|
||||
var ctx = await chatService.PrepareContext(targetSessionId, userId: null);
|
||||
Log($"PrepareContext={ctx != null}");
|
||||
if (ctx == null)
|
||||
return $"Fehler: Session '{targetSession.Name}' ist nicht konfiguriert (kein Agent zugewiesen?)";
|
||||
|
||||
// History aufbauen – User-Message NICHT in DB speichern (wie Cronjob)
|
||||
// Stattdessen als kontextualisierte Nachricht in die History injizieren
|
||||
var history = await chatService.BuildHistoryFromDb(targetSessionId, promptBlocks: ctx.PromptBlocks);
|
||||
Log($"History geladen, {history.Count} Einträge");
|
||||
var senderAgent = agentId != null ? await db.GetAgent(agentId) : null;
|
||||
var senderName = senderAgent?.Name ?? agentId ?? "Unbekannter Agent";
|
||||
var senderInfo = $"[Nachricht von Agent \"{senderName}\"]: {message}";
|
||||
@@ -778,13 +766,10 @@ public class ToolService
|
||||
|
||||
try
|
||||
{
|
||||
Log("Rufe ChatNonStreaming auf...");
|
||||
await anthropicService.ChatNonStreaming(ctx, history);
|
||||
Log("ChatNonStreaming erfolgreich");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log($"ChatNonStreaming FEHLER: {ex}");
|
||||
Console.WriteLine($"[send_to_session] ChatNonStreaming Fehler: {ex}");
|
||||
return $"Fehler beim Senden an Session \"{targetSession.Name}\": {ex.Message}";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user