diff options
| author | Kujtim Hoxha <[email protected]> | 2025-04-15 11:58:01 +0200 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-21 13:41:27 +0200 |
| commit | 1cdd24fbc7b45693b65b5d55e4f45c2ebc60a556 (patch) | |
| tree | a623be9bdcfb78fca8185d10019c118f4ac00106 /internal/llm/agent/agent.go | |
| parent | f6be348bf704ab3d012eec549357f5acd9c74796 (diff) | |
| download | opencode-1cdd24fbc7b45693b65b5d55e4f45c2ebc60a556.tar.gz opencode-1cdd24fbc7b45693b65b5d55e4f45c2ebc60a556.zip | |
minor fixes
Diffstat (limited to 'internal/llm/agent/agent.go')
| -rw-r--r-- | internal/llm/agent/agent.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/llm/agent/agent.go b/internal/llm/agent/agent.go index 997004e12..1958111a1 100644 --- a/internal/llm/agent/agent.go +++ b/internal/llm/agent/agent.go @@ -4,6 +4,8 @@ import ( "context" "errors" "fmt" + "os" + "runtime/debug" "strings" "sync" @@ -88,6 +90,21 @@ func (a *agent) Generate(ctx context.Context, sessionID string, content string) defer func() { if r := recover(); r != nil { logging.ErrorPersist(fmt.Sprintf("Panic in Generate: %v", r)) + + // dump stack trace into a file + file, err := os.Create("panic.log") + if err != nil { + logging.ErrorPersist(fmt.Sprintf("Failed to create panic log: %v", err)) + return + } + + defer file.Close() + + stackTrace := debug.Stack() + if _, err := file.Write(stackTrace); err != nil { + logging.ErrorPersist(fmt.Sprintf("Failed to write panic log: %v", err)) + } + } }() defer a.activeRequests.Delete(sessionID) |
