summaryrefslogtreecommitdiff
path: root/tools.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-03-03 14:51:36 +0300
committerGrail Finder <wohilas@gmail.com>2026-03-03 14:51:36 +0300
commit8974d2f52c68352446a417e922590237c618ef9f (patch)
tree48ca436c213bb0b541c37387e657abe313ebcb7e /tools.go
parent6b0d03f2d632597a75e63d03a9932d189d354a2b (diff)
Fix: remove panics from code
Diffstat (limited to 'tools.go')
-rw-r--r--tools.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/tools.go b/tools.go
index dfa8d7b..84ef23d 100644
--- a/tools.go
+++ b/tools.go
@@ -212,9 +212,13 @@ func init() {
roleToID["assistant"] = basicCard.ID
sa, err := searcher.NewWebSurfer(searcher.SearcherTypeScraper, "")
if err != nil {
- panic("failed to init seachagent; error: " + err.Error())
+ if logger != nil {
+ logger.Warn("search agent unavailable; web_search tool disabled", "error", err)
+ }
+ WebSearcher = nil
+ } else {
+ WebSearcher = sa
}
- WebSearcher = sa
if err := rag.Init(cfg, logger, store); err != nil {
logger.Warn("failed to init rag; rag_search tool will not be available", "error", err)
}
@@ -275,10 +279,16 @@ func updateToolCapabilities() {
func getWebAgentClient() *agent.AgentClient {
webAgentClientOnce.Do(func() {
if cfg == nil {
- panic("cfg not initialized")
+ if logger != nil {
+ logger.Warn("web agent client unavailable: config not initialized")
+ }
+ return
}
if logger == nil {
- panic("logger not initialized")
+ if logger != nil {
+ logger.Warn("web agent client unavailable: logger not initialized")
+ }
+ return
}
getToken := func() string {
if chunkParser == nil {