From 8a246c228256deff4b1caf4fd5d84d918e686b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E6=99=BA=E8=B6=850668000959?= Date: Mon, 8 Jun 2026 16:52:00 +0800 Subject: [PATCH] fix(agent): handle os.Getwd error in NewContextBuilder without behavior regression --- pkg/agent/context.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/agent/context.go b/pkg/agent/context.go index 01e9ec0b2..74c278f39 100644 --- a/pkg/agent/context.go +++ b/pkg/agent/context.go @@ -102,7 +102,13 @@ func NewContextBuilder(workspace string) *ContextBuilder { // Use the skills/ directory under the current working directory builtinSkillsDir := strings.TrimSpace(os.Getenv(config.EnvBuiltinSkills)) if builtinSkillsDir == "" { - wd, _ := os.Getwd() + wd, err := os.Getwd() + if err != nil { + // os.Getwd failure is extremely rare; fall back to empty + // string so that filepath.Join produces a relative "skills" + // path, preserving the original lookup behavior. + wd = "" + } builtinSkillsDir = filepath.Join(wd, "skills") } globalSkillsDir := filepath.Join(getGlobalConfigDir(), "skills")