Prechádzať zdrojové kódy

agi: include execution UUID in script error log messages

Add [<execID>] after the [AGI] / [Remote AGI] prefix so each error line
carries the same UUID that is injected into the script as EXECUTION_ID,
making it straightforward to correlate log entries for a single request.
Also fix the missing separator in the Remote AGI error message
("failed to execute<err>" -> "failed to execute: <err>").

https://claude.ai/code/session_01FHPkX8pCYWbGvh2pL47J8y
Claude 2 týždňov pred
rodič
commit
00c410589e
2 zmenil súbory, kde vykonal 3 pridanie a 3 odobranie
  1. 2 2
      src/mod/agi/agi.go
  2. 1 1
      src/mod/agi/externalReqHandler.go

+ 2 - 2
src/mod/agi/agi.go

@@ -357,7 +357,7 @@ func (g *Gateway) ExecuteAGIScript(scriptContent string, fsh *filesystem.FileSys
 		if thisuser != nil {
 			username = thisuser.Username
 		}
-		logger.PrintAndLog("Agi", fmt.Sprintf("[AGI] Script error in %s (user: %s): %s", scriptFile, username, err.Error()), nil)
+		logger.PrintAndLog("Agi", fmt.Sprintf("[AGI][%s] Script error in %s (user: %s): %s", execID, scriptFile, username, err.Error()), nil)
 
 		if devMode {
 			// Return a detailed JSON error payload for developer inspection
@@ -496,7 +496,7 @@ func (g *Gateway) ExecuteAGIScriptAsUser(fsh *filesystem.FileSystemHandler, scri
 
 	_, err = vm.Run(scriptContent)
 	if err != nil {
-		logger.PrintAndLog("Agi", fmt.Sprintf("[AGI] Script error in %s (user: %s): %s", scriptFile, targetUser.Username, err.Error()), nil)
+		logger.PrintAndLog("Agi", fmt.Sprintf("[AGI][%s] Script error in %s (user: %s): %s", execID, scriptFile, targetUser.Username, err.Error()), nil)
 		return execID, "", err
 	}
 

+ 1 - 1
src/mod/agi/externalReqHandler.go

@@ -228,7 +228,7 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 	g.recordExecution(endpointUUID, pathFromDb, execID, r.Method, durationMs, execErr)
 
 	if execErr != nil {
-		logger.PrintAndLog("Agi", fmt.Sprint("[Remote AGI] ", pathFromDb, " failed to execute", execErr.Error()), nil)
+		logger.PrintAndLog("Agi", fmt.Sprintf("[Remote AGI][%s] %s failed to execute: %s", execID, pathFromDb, execErr.Error()), nil)
 		utils.SendErrorResponse(w, execErr.Error())
 		return
 	}