fix(agent): use fallback workspace path for MCP initialization
Use cfg.WorkspacePath() as a fallback when defaultAgent is nil or its Workspace is empty. This ensures MCP servers with relative envFile paths can always resolve them correctly, even when agents haven't been fully initialized yet. Previously, workspacePath would be an empty string in these cases, causing relative envFile paths to fail to resolve. Now the fallback guarantees a valid workspace path is always provided to LoadFromMCPConfig. Addresses Copilot code review feedback.
This commit is contained in:
parent
f1b798434d
commit
a7a4e88fff
1 changed files with 3 additions and 1 deletions
|
|
@ -140,8 +140,10 @@ func (al *AgentLoop) Run(ctx context.Context) error {
|
|||
mcpManager := mcp.NewManager()
|
||||
defaultAgent := al.registry.GetDefaultAgent()
|
||||
workspacePath := ""
|
||||
if defaultAgent != nil {
|
||||
if defaultAgent != nil && defaultAgent.Workspace != "" {
|
||||
workspacePath = defaultAgent.Workspace
|
||||
} else {
|
||||
workspacePath = al.cfg.WorkspacePath()
|
||||
}
|
||||
|
||||
if err := mcpManager.LoadFromMCPConfig(ctx, al.cfg.Tools.MCP, workspacePath); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue