37 lines
983 B
Go
37 lines
983 B
Go
package agent
|
|
|
|
import (
|
|
"sync"
|
|
"sync/atomic"
|
|
|
|
"ollie/backend"
|
|
"ollie/tools"
|
|
)
|
|
|
|
// Agent holds the state of the current Agent entity (the "agent"
|
|
// in the traditional sense). It is swappable: when the user runs /agent,
|
|
// a new Agent is built from the new agent config while the session
|
|
// host remains stable.
|
|
type Agent struct {
|
|
history *History
|
|
runtime *Runtime
|
|
cfg agentConfig // per-turn config built from runtime
|
|
agentName string
|
|
agentsDir string
|
|
baseLayers []string // system prompt layers for /agent reloads
|
|
promptEnvExtra []string // PRIME_* vars for prompt resolution
|
|
newDispatcher func() tools.Dispatcher
|
|
newBackend func(string) (backend.Backend, error)
|
|
currentAction atomic.Pointer[actionHandle]
|
|
warnedContext bool
|
|
resultCache sync.Map
|
|
}
|
|
|
|
// Backend returns the active backend from the runtime.
|
|
func (r *Agent) Backend() backend.Backend {
|
|
if r.runtime == nil {
|
|
return nil
|
|
}
|
|
return r.runtime.Backend
|
|
}
|