fs: pass sessID and uname to LoadAutoLoadTools for tool server env setup
This commit is contained in:
parent
bf80a63e8a
commit
757d81a4ba
|
|
@ -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...)...)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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...)...)
|
||||
})
|
||||
|
||||
|
|
|
|||
16
fs/setup.go
16
fs/setup.go
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue