agent: inject baseLayers (system prompt, operational model, env) into /agent reload path
The operational model was only rendered for new sessions, not for restored sessions or /agent reloads. Store baseLayers on the agent struct and pass them through on rebuild. Also fix pre-existing test failures caused by DiscoverTools reading from the live OLLIE_TOOLS_PATH during tests.
This commit is contained in:
parent
8ff14935b7
commit
88ca0c1842
|
|
@ -177,7 +177,7 @@ func (s *agent) handleCommand(ctx context.Context, input string) bool {
|
|||
d := s.newDispatcher()
|
||||
env := []string{"OLLIE_SESSION_ID=" + s.sessionID, "OLLIE_UNAME=" + s.uname}
|
||||
env = append(env, s.promptEnvExtra...)
|
||||
rt := BuildRuntime(cfg, d, s.cwd, env)
|
||||
rt := BuildRuntime(cfg, d, s.cwd, env, s.baseLayers...)
|
||||
if rt.CfgBackend != "" {
|
||||
newBe, err := s.newBackend(rt.CfgBackend)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -283,13 +283,10 @@ type AgentCoreConfig struct {
|
|||
PromptEnvExtra []string
|
||||
// Remote is the SSH target for remote execution (empty = local).
|
||||
Remote string
|
||||
// OperationalModel is server-injected text describing the 9P/D-Bus
|
||||
// interface available to the agent. Not user-configurable.
|
||||
OperationalModel string
|
||||
// SystemPrompt is the base system prompt text (embedded default or
|
||||
// override from agent config / session creation). If empty, BuildRuntime
|
||||
// uses only the agent config's prompt commands.
|
||||
SystemPrompt string
|
||||
// BaseLayers are the system prompt, operational model, and environment
|
||||
// block prepended to the agent preamble. Stored so /agent reloads
|
||||
// preserve the server-injected context.
|
||||
BaseLayers []string
|
||||
}
|
||||
|
||||
// agent is the Core implementation. It owns all agent and session state
|
||||
|
|
@ -312,6 +309,7 @@ type agent struct {
|
|||
cwd string
|
||||
remote string // SSH target for remote execution
|
||||
promptEnvExtra []string // PRIME_* vars for prompt resolution
|
||||
baseLayers []string // system prompt, operational model, env block — for /agent reloads
|
||||
startupMessages []string
|
||||
currentAction atomic.Pointer[actionHandle]
|
||||
toolCallCount atomic.Int64
|
||||
|
|
@ -479,6 +477,7 @@ func NewAgentCore(cfg AgentCoreConfig) Core {
|
|||
cwd: paths.ExpandHome(cfg.CWD),
|
||||
remote: cfg.Remote,
|
||||
promptEnvExtra: cfg.PromptEnvExtra,
|
||||
baseLayers: cfg.BaseLayers,
|
||||
startupMessages: rt.Messages,
|
||||
newDispatcher: cfg.NewDispatcher,
|
||||
newBackend: cfg.NewBackend,
|
||||
|
|
|
|||
|
|
@ -2321,6 +2321,7 @@ func setupCfgDir(t *testing.T) string {
|
|||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
t.Setenv("OLLIE_CFG_PATH", dir)
|
||||
t.Setenv("OLLIE_TOOLS_PATH", filepath.Join(dir, "tools"))
|
||||
return dir
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue