session: pass PromptEnv to all BuildRuntime calls

Both restore and create paths now include PRIME_* env vars.
Remote path uses HostInfo; local path uses PromptEnv(cwd).
This commit is contained in:
Levi Neely 2026-07-19 20:26:52 +02:00
parent 28232fd833
commit 03a29b0877
1 changed files with 9 additions and 2 deletions

View File

@ -780,7 +780,9 @@ func (s *Manager) restoreSession(ps *agent.PersistedSession) error {
newDisp := tools.NewDispatcherFunc(map[string]func() tools.Server{
"execute": execute.Decl(cwd, execOpts...),
})
rt := agent.BuildRuntime(cfg, newDisp(), cwd, []string{"OLLIE_SESSION_ID=" + sessID, "OLLIE_UNAME=" + uname, "OLLIE=" + MountPathFor(uname)})
env := []string{"OLLIE_SESSION_ID=" + sessID, "OLLIE_UNAME=" + uname, "OLLIE=" + MountPathFor(uname)}
env = append(env, agent.PromptEnv(cwd)...)
rt := agent.BuildRuntime(cfg, newDisp(), cwd, env)
restoredSession := agent.RestoreSession(ps.Messages)
if ps.TaskState != nil {
@ -1025,6 +1027,7 @@ func (s *Manager) CreateSession(args []string) (string, error) {
"execute": func() tools.Server { return rsrv },
})
remoteEnv = []string{
"PRIME_CWD=" + cwd,
"PRIME_PLATFORM=" + rsrv.Info.Platform,
"PRIME_IS_GIT_REPO=" + fmt.Sprintf("%v", rsrv.Info.IsGitRepo),
}
@ -1035,7 +1038,11 @@ func (s *Manager) CreateSession(args []string) (string, error) {
}
env := []string{"OLLIE_SESSION_ID=" + sessID, "OLLIE_UNAME=" + uname, "OLLIE=" + MountPathFor(uname)}
env = append(env, remoteEnv...)
if len(remoteEnv) > 0 {
env = append(env, remoteEnv...)
} else {
env = append(env, agent.PromptEnv(cwd)...)
}
rt := agent.BuildRuntime(cfg, newDisp(), cwd, env)
// sessPtr is set after NewSession; the ReadPlanStep closure captures it.