session: move uname to Agent, remove peers from core
- uname is the agent's principal/UID, not a session property - peers removed entirely from core: the concept needs redesign for multi-agent. The 9P layer retains its own inter-session routing at the Manager level. Core Session now holds only: id, bus, env, plan, prevPrompt. Agent holds all execution + identity state.
This commit is contained in:
parent
7592f810a9
commit
4028085914
|
|
@ -31,6 +31,7 @@ type Agent struct {
|
||||||
state string // "idle", "thinking", "calling: <tool>"
|
state string // "idle", "thinking", "calling: <tool>"
|
||||||
reply string // last assistant response
|
reply string // last assistant response
|
||||||
cwd string // working directory for tool execution
|
cwd string // working directory for tool execution
|
||||||
|
uname string // agent principal (numeric UID for 9P identity)
|
||||||
fifo Fifo // prompt queue
|
fifo Fifo // prompt queue
|
||||||
toolCallCount atomic.Int64
|
toolCallCount atomic.Int64
|
||||||
pendingInject atomic.Pointer[string]
|
pendingInject atomic.Pointer[string]
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ func (a *Session) handleCommand(ctx context.Context, input string) bool {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
d := a.r.newDispatcher()
|
d := a.r.newDispatcher()
|
||||||
env := []string{"OLLIE_SESSION_ID=" + a.id, "OLLIE_UNAME=" + a.uname}
|
env := []string{"OLLIE_SESSION_ID=" + a.id, "OLLIE_UNAME=" + a.r.uname}
|
||||||
env = append(env, a.r.promptEnvExtra...)
|
env = append(env, a.r.promptEnvExtra...)
|
||||||
rt := BuildRuntime(cfg, d, a.r.cwd, env, a.r.baseLayers...)
|
rt := BuildRuntime(cfg, d, a.r.cwd, env, a.r.baseLayers...)
|
||||||
if rt.CfgBackend != "" {
|
if rt.CfgBackend != "" {
|
||||||
|
|
|
||||||
|
|
@ -310,13 +310,11 @@ type Config struct {
|
||||||
type Session struct {
|
type Session struct {
|
||||||
// Session-level state
|
// Session-level state
|
||||||
id string
|
id string
|
||||||
uname string
|
|
||||||
bus *pubsub.Bus
|
bus *pubsub.Bus
|
||||||
envMu sync.RWMutex
|
envMu sync.RWMutex
|
||||||
env map[string]string
|
env map[string]string
|
||||||
plan []byte
|
plan []byte
|
||||||
prevPrompt string
|
prevPrompt string
|
||||||
peers map[string]bool
|
|
||||||
|
|
||||||
// Agent
|
// Agent
|
||||||
r *Agent
|
r *Agent
|
||||||
|
|
@ -367,8 +365,8 @@ func (a *Session) pushSessionEnv() {
|
||||||
if srv, ok := a.r.runtime.Dispatcher.GetServer("execute"); ok {
|
if srv, ok := a.r.runtime.Dispatcher.GetServer("execute"); ok {
|
||||||
if es, ok := srv.(tools.EnvSetter); ok {
|
if es, ok := srv.(tools.EnvSetter); ok {
|
||||||
es.SetEnv("OLLIE_SESSION_ID", a.id)
|
es.SetEnv("OLLIE_SESSION_ID", a.id)
|
||||||
if a.uname != "" {
|
if a.r.uname != "" {
|
||||||
es.SetEnv("OLLIE_UNAME", a.uname)
|
es.SetEnv("OLLIE_UNAME", a.r.uname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +457,7 @@ func New(cfg Config) *Session {
|
||||||
|
|
||||||
a := &Session{
|
a := &Session{
|
||||||
id: cfg.SessionID,
|
id: cfg.SessionID,
|
||||||
uname: cfg.Uname,
|
|
||||||
bus: pubsub.NewBus(),
|
bus: pubsub.NewBus(),
|
||||||
env: make(map[string]string),
|
env: make(map[string]string),
|
||||||
r: &Agent{
|
r: &Agent{
|
||||||
|
|
|
||||||
Reference in New Issue