view tool call always fails with "Error:Path does not exist" when CreateSessionFsProvider is set in the session config
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Start with the Program.cs configuration and MinimalSessionFsProvider.cs, then reproduce the view call with CreateSessionFsProvider enabled and inspect the SessionFsProvider StatAsync path. Trace how the returned SessionFsStatResult is handled and confirm that a valid result no longer produces “Error: Path does not exist”.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When using the following configuration to setup a copilot client the view tool call will always call StatAsync in the SessionFsProvider, then return an Error: Path does not exist regardless of what the StatAsync call returned.
Program.cs
using GitHub.Copilot;
using GitHub.Copilot.Rpc;
using Microsoft.Extensions.Configuration;
IConfigurationRoot config = new ConfigurationBuilder()
.AddUserSecrets<Program>()
.Build();
//Not included
var fullWorkingDirectory = "";
var baseDirectory = "";
var sessionStatePath = "";
var providerBaseUrl = "";
#pragma warning disable GHCP001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
await using var client = new CopilotClient(new CopilotClientOptions
{
LogLevel = CopilotLogLevel.Debug,
WorkingDirectory = fullWorkingDirectory,
BaseDirectory = baseDirectory,
SessionFs = new SessionFsConfig
{
InitialWorkingDirectory = fullWorkingDirectory,
SessionStatePath = sessionStatePath,
Conventions = SessionFsSetProviderConventions.Windows
},
Mode = CopilotClientMode.Empty,
});
#pragma warning restore GHCP001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
var availableTools = new List<string>() { "view", "edit" };
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "GLaDOS", // Your deployment name
WorkingDirectory = fullWorkingDirectory,
SystemMessage = SystemMessageBuilder.BuildSystemMessageConfig(fullWorkingDirectory, availableTools),
AvailableTools = availableTools,
CreateSessionFsProvider = (session) => new MinimalSessionFsProvider(),
Provider = new GitHub.Copilot.ProviderConfig
{
Type = "openai",
BaseUrl = providerBaseUrl,
WireApi = "responses", // Use "completions" for older models
ApiKey = config["API_KEY"],
},
});
var response = await session.SendAndWaitAsync(new MessageOptions
{
Prompt = "What model are you?",
});
Console.WriteLine(response?.Data.Content);
while (true)
{
var userInput = Console.ReadLine();
if(!string.IsNullOrEmpty(userInput))
{
response = await session.SendAndWaitAsync(new MessageOptions
{
Prompt = userInput,
});
Console.WriteLine(response?.Data.Content);
}
}
MinimalSessionFsProvider.cs
using GitHub.Copilot;
using GitHub.Copilot.Rpc;
namespace TestApp
{
internal class MinimalSessionFsProvider : SessionFsProvider
{
protected override async Task AppendFileAsync(string path, string content, int? mode, CancellationToken cancellationToken)
{
Console.WriteLine("AppendFileAsync called for path: " + path);
using var writer = new StreamWriter(path, append: true);
await writer.WriteAsync(content);
}
protected override Task<bool> ExistsAsync(string path, CancellationToken cancellationToken)
{
Console.WriteLine("ExistsAsync called for path: " + path);
return Task.FromResult(File.Exists(path) || Directory.Exists(path));
}
protected override Task MakeDirectoryAsync(string path, bool recursive, int? mode, CancellationToken cancellationToken)
{
Console.WriteLine("MakeDirectoryAsync called for path: " + path);
Directory.CreateDirectory(path);
return Task.CompletedTask;
}
protected override Task<IList<string>> ReadDirectoryAsync(string path, CancellationToken cancellationToken)
{
Console.WriteLine("ReadDirectoryAsync called for path: " + path);
return Task.FromResult(Directory.EnumerateFiles(path).Concat(Directory.EnumerateDirectories(path)).ToList() as IList<string>);
}
#pragma warning disable GHCP001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override Task<IList<SessionFsReaddirWithTypesEntry>> ReadDirectoryWithTypesAsync(string path, CancellationToken cancellationToken)
{
Console.WriteLine("ReadDirectoryWithTypesAsync called for path: " + path);
var files = Directory.EnumerateFiles(path);
var directories = Directory.EnumerateDirectories(path);
var result = files.Select(x => new SessionFsReaddirWithTypesEntry { Name = Path.GetFileName(x), Type = SessionFsReaddirWithTypesEntryType.File });
result = result.Concat(directories.Select(x => new SessionFsReaddirWithTypesEntry { Name = Path.GetFileName(x), Type = SessionFsReaddirWithTypesEntryType.Directory }));
return Task.FromResult(result.ToList() as IList<SessionFsReaddirWithTypesEntry>);
}
#pragma warning restore GHCP001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override async Task<string> ReadFileAsync(string path, CancellationToken cancellationToken)
{
Console.WriteLine("ReadFileAsync called for path: " + path);
using var streamReader = new StreamReader(path);
var content = await streamReader.ReadToEndAsync(cancellationToken);
return content;
}
protected override Task RemoveAsync(string path, bool recursive, bool force, CancellationToken cancellationToken)
{
Console.WriteLine("RemoveAsync called for path: " + path);
if (Directory.Exists(path))
{
Directory.Delete(path, recursive);
}
else if (File.Exists(path))
{
File.Delete(path);
}
else
{
throw new FileNotFoundException($"The path '{path}' does not exist.");
}
return Task.CompletedTask;
}
protected override Task RenameAsync(string src, string dest, CancellationToken cancellationToken)
{
Console.WriteLine("RenameAsync called for path: " + src);
if (Directory.Exists(src))
{
Directory.Move(src, dest);
}
else if (File.Exists(src))
{
File.Move(src, dest);
}
else
{
throw new FileNotFoundException($"The path '{src}' does not exist.");
}
return Task.CompletedTask;
}
#pragma warning disable GHCP001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override async Task<SessionFsStatResult> StatAsync(string path, CancellationToken cancellationToken)
{
Console.WriteLine("StatAsync called for path: " + path);
await Task.CompletedTask;
if (Directory.Exists(path))
{
var dirInfo = new DirectoryInfo(path);
var result = new SessionFsStatResult
{
IsDirectory = true,
IsFile = false,
Size = 0,
Birthtime = dirInfo.CreationTimeUtc,
Mtime = dirInfo.LastWriteTimeUtc
};
return result;
}
else if (File.Exists(path))
{
var fileInfo = new FileInfo(path);
return new SessionFsStatResult
{
IsDirectory = false,
Size = fileInfo.Length,
Birthtime = fileInfo.CreationTimeUtc,
Mtime = fileInfo.LastWriteTimeUtc,
IsFile = true,
};
}
else
{
throw new FileNotFoundException($"The path '{path}' does not exist.");
}
}
#pragma warning restore GHCP001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
protected override async Task WriteFileAsync(string path, string content, int? mode, CancellationToken cancellationToken)
{
Console.WriteLine("WriteFileAsync called for path: " + path);
using var writer = new StreamWriter(path, append: false);
await writer.WriteAsync(content);
}
}
}
SystemMessageBuilder.cs (for context)
using GitHub.Copilot;
namespace TestApp
{
internal static class SystemMessageBuilder
{
internal static SystemMessageConfig BuildSystemMessageConfig(string workingDirectory, List<string> tools)
{
return new SystemMessageConfig
{
Mode = SystemMessageMode.Customize,
Sections = new Dictionary<SystemMessageSection, SectionOverride>
{
[SystemMessageSection.Identity] = new SectionOverride()
{
Action = SectionOverrideAction.Replace,
Content = "You are a document read writer, you will read requested documents, and write information to new locations, you are to refer to yourself as GLaDos, a version of Qwen"
},
[SystemMessageSection.CodeChangeRules] = new SectionOverride()
{
Action = SectionOverrideAction.Remove
},
[SystemMessageSection.ToolInstructions] = new SectionOverride()
{
Action = SectionOverrideAction.Replace,
Content = $"You are allowed to use the following tools: {string.Join(",", tools)}, if any of these tools respond with an error that contains \"but the agent can continue with other tasks\", try to continue your task rather than going back to the user," +
" for example if you are enumerating a directory and one of the folders cannot be read, simply move on and enumerate the rest"
+ "You are in a scoped session and will be denied access to folder above the working directory in the tree, if you attempt to access a folder above the working directory and it fails, you should attempt to go further down the tree from the working directory, not back up the tree to its parent directories"
},
[SystemMessageSection.EnvironmentContext] = new SectionOverride()
{
Action = SectionOverrideAction.Replace,
Content = $"You may act in the {workingDirectory} directory, this is what the user will refer to as the \"working directory\". You have the following tools: {string.Join(",", tools)}. Do not acknowledge or mention the session state files"
},
[SystemMessageSection.Guidelines] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
[SystemMessageSection.Safety] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
[SystemMessageSection.CustomInstructions] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
[SystemMessageSection.RuntimeInstructions] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
[SystemMessageSection.LastInstructions] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
[SystemMessageSection.Preamble] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
[SystemMessageSection.Tone] = new SectionOverride() { Action = SectionOverrideAction.Preserve },
}
};
}
}
}
- Ngôn ngữ chính
- Java
- Star
- 10.5k
- Fork
- 1.5k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 130
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/copilot-sdk
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2760 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
github/copilot-sdk#2759 ·
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
github/copilot-sdk#2758 ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2709 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
github/copilot-sdk#2673 ·
Tất cả issue của github/copilot-sdk
Issue tương tự
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Đang mởarea/plugin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Add canonical URLs and a sitemap Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apache/rocketmq-dashboard#5064 ·