fix: SetWorkDir uses session touch_dir for bootstrap file resolution
EffectiveWorkspace only returns worktree paths, defaulting to workspace root when no worktree is active. This meant project-scoped bootstrap files (AGENTS.md, IDENTITY.md) were always loaded from workspace root. Now uses the tool-detected project directory (touch_dir) from the session tracker, resolved as absolute path under workspace. Falls back to EffectiveWorkspace for the first turn before any tools have run. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
60342d1aca
commit
ca04d7c139
1 changed files with 8 additions and 2 deletions
|
|
@ -811,8 +811,14 @@ func (al *AgentLoop) runAgentLoop(ctx context.Context, agent *AgentInstance, opt
|
||||||
// 1. Update tool contexts
|
// 1. Update tool contexts
|
||||||
al.updateToolContexts(agent, opts.Channel, opts.ChatID)
|
al.updateToolContexts(agent, opts.Channel, opts.ChatID)
|
||||||
|
|
||||||
// 1a. Set session-specific working directory for bootstrap file lookup
|
// 1a. Set session-specific working directory for bootstrap file lookup.
|
||||||
|
// Prefer the tool-detected project directory (touch_dir) from the session tracker,
|
||||||
|
// resolved as an absolute path under workspace. Fall back to worktree or workspace.
|
||||||
|
if active := al.sessions.ListActive(); len(active) > 0 && active[0].SessionKey == opts.SessionKey && active[0].TouchDir != "" {
|
||||||
|
agent.ContextBuilder.SetWorkDir(filepath.Join(agent.Workspace, active[0].TouchDir))
|
||||||
|
} else {
|
||||||
agent.ContextBuilder.SetWorkDir(agent.EffectiveWorkspace(opts.SessionKey))
|
agent.ContextBuilder.SetWorkDir(agent.EffectiveWorkspace(opts.SessionKey))
|
||||||
|
}
|
||||||
|
|
||||||
// 1b. Inject peer session awareness into system prompt
|
// 1b. Inject peer session awareness into system prompt
|
||||||
projectPath := agent.ContextBuilder.GetPlanWorkDir()
|
projectPath := agent.ContextBuilder.GetPlanWorkDir()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue