fs: pass sessID and uname to LoadAutoLoadTools for tool server env setup

This commit is contained in:
Levi Neely 2026-08-04 13:21:37 +02:00
parent bf80a63e8a
commit 757d81a4ba
3 changed files with 17 additions and 3 deletions

View File

@ -535,7 +535,7 @@ func CreateAgent(rs *RootState, sessName string, args []string) error {
}
// Load configured tools before building the runtime.
LoadAutoLoadTools(cfg, toolSrv, func(f string, a ...any) {
LoadAutoLoadTools(cfg, toolSrv, sessID, uname, func(f string, a ...any) {
rs.Cfg.Log.Error("session %s: "+f, append([]any{sessName}, a...)...)
})

View File

@ -155,7 +155,7 @@ func restoreSession(rs *RootState, ps *agent.PersistedAgent) error {
layers := BuildPromptLayers(cfg, cwd, sessID, uname, infra.PromptEnv, "")
// Load configured tools before building the runtime.
LoadAutoLoadTools(cfg, infra.ToolsConn, func(f string, a ...any) {
LoadAutoLoadTools(cfg, infra.ToolsConn, sessID, uname, func(f string, a ...any) {
rs.Cfg.Log.Error("session %s: "+f, append([]any{sessID}, a...)...)
})

View File

@ -191,10 +191,24 @@ func (p PromptLayers) BaseLayers() []string {
}
// LoadAutoLoadTools loads all tools from the agent config's autoLoad list.
func LoadAutoLoadTools(cfg *agent.AgentConfig, runner toolsrv.Runner, logError func(string, ...any)) {
// It first sends the session ID and uname to the tool server so that
// ollie-remote can attach its tool registry before processing tool_load RPCs.
func LoadAutoLoadTools(cfg *agent.AgentConfig, runner toolsrv.Runner, sessID, uname string, logError func(string, ...any)) {
if cfg == nil || runner == nil {
return
}
// Send session ID to the tool server first — ollie-remote uses this
// to attach its tool registry via the OnEnvSet callback.
if es, ok := runner.(interface{ SetEnv(string, string) }); ok {
if sessID != "" {
es.SetEnv("OLLIE_SESSION_ID", sessID)
}
if uname != "" {
es.SetEnv("OLLIE_UNAME", uname)
}
}
for _, tl := range cfg.AutoLoad {
if err := loadToolOnRunner(runner, tl); err != nil {
if logError != nil {