{"record":{"id":"99478cb97bc01fa9","repo":"chenhg5/cc-connect","slug":"create-workspace-agent-for-s-w","errorCode":null,"errorMessage":"create workspace agent for %s: %w","messagePattern":"create workspace agent for (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":3967,"sourceCode":"\t// above, not inherited from the project-level opts that main.go\n\t// already decorated. See cc-connect#496 and the cc-connect/core/runas.go\n\t// preamble for why run_as_user has to survive this copy.\n\tif _, ok := opts[\"run_as_user\"]; !ok {\n\t\tif u := e.runAsUser(); u != \"\" {\n\t\t\topts[\"run_as_user\"] = u\n\t\t}\n\t}\n\tif _, ok := opts[\"run_as_env\"]; !ok {\n\t\tif ma, ok := e.agent.(interface{ GetRunAsEnv() []string }); ok {\n\t\t\tif env := ma.GetRunAsEnv(); len(env) > 0 {\n\t\t\t\topts[\"run_as_env\"] = env\n\t\t\t}\n\t\t}\n\t}\n\n\tagent, err := CreateAgent(e.agent.Name(), opts)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"create workspace agent for %s: %w\", workspace, err)\n\t}\n\n\t// Wire providers if original agent has them\n\tif ps, ok := e.agent.(ProviderSwitcher); ok {\n\t\tif ps2, ok2 := agent.(ProviderSwitcher); ok2 {\n\t\t\tps2.SetProviders(ps.ListProviders())\n\t\t\tif active := ps.GetActiveProvider(); active != nil && active.Name != \"\" {\n\t\t\t\tps2.SetActiveProvider(active.Name)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Create per-workspace session manager\n\th := sha256.Sum256([]byte(workspace))\n\tsessionFile := filepath.Join(filepath.Dir(e.sessions.StorePath()),\n\t\tfmt.Sprintf(\"%s_ws_%s.json\", e.name, hex.EncodeToString(h[:4])))\n\tsessions := NewSessionManager(sessionFile)\n","sourceCodeStart":3949,"sourceCodeEnd":3985,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L3949-L3985","documentation":"Workspace-agent helper: core.CreateAgent(e.agent.Name(), opts) failed while building the per-workspace agent instance (unknown agent name in the registry or invalid merged opts such as bad run_as settings). The caller falls back to the global agent and only logs this error, so it is usually non-fatal.","triggerScenarios":"CreateAgent(e.agent.Name(), opts) fails while creating a workspace-scoped agent — factory lookup fails or constructor validation rejects opts (bad cwd, invalid options).","commonSituations":"Workspace path does not exist or lacks permissions; agent factory misregistered; invalid agent options derived from config.","solutions":["Verify the workspace directory exists and is readable/writable by the process","Check the agent factory is registered for e.agent.Name()","Inspect the wrapped cause for the concrete constructor failure","Validate agent config options (cwd, model, flags) are correct"],"exampleFix":"// before\nworkspace: \"/projects/missing-dir\"\n// after\nworkspace: \"/projects/exists-dir\" // ensure path exists before adding workspace","handlingStrategy":"validation","validationCode":"if st, err := os.Stat(workspace); err != nil || !st.IsDir() { return fmt.Errorf(\"workspace %q unavailable\", workspace) }","typeGuard":null,"tryCatchPattern":"if _, _, err := engine.CreateWorkspaceAgent(ws); err != nil { log.Fatalf(\"workspace agent: %v\", err) } // inspect wrapped cause with errors.Unwrap","preventionTips":["Ensure workspace directories exist with correct permissions before config","Keep agent factories registered for all configured agent names","Validate agent options (cwd, model) against the agent's supported flags"],"tags":["go","workspace","agent"],"backgroundTag":"invalid-config-value","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}