fix: refresh cached system prompt after LLM iteration
Tool execution during runLLMIteration updates touch_dir, but the cached system prompt was captured before that. Now rebuilds and re-captures after iteration so Mini App shows the prompt with current workDir (correct AGENTS.md). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e0538ef1cc
commit
e824ce8945
1 changed files with 6 additions and 2 deletions
|
|
@ -926,8 +926,12 @@ func (al *AgentLoop) runAgentLoop(ctx context.Context, agent *AgentInstance, opt
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If last tool had ForUser content and we already sent it, we might not need to send final response
|
// 5-post. Refresh cached system prompt: tool execution may have updated touch_dir,
|
||||||
// This is controlled by the tool's Silent flag and ForUser content
|
// so rebuild with current workDir so Mini App shows the up-to-date version.
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
al.lastSystemPrompt.Store(agent.ContextBuilder.BuildSystemPrompt())
|
||||||
|
|
||||||
// 5a. Auto-advance plan phases after LLM iteration
|
// 5a. Auto-advance plan phases after LLM iteration
|
||||||
postStatus := agent.ContextBuilder.GetPlanStatus()
|
postStatus := agent.ContextBuilder.GetPlanStatus()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue