MCPcopy Create free account
hub / github.com/diillson/chatcli / installAgentSystemMessage

Method installAgentSystemMessage

cli/agent_mode.go:922–939  ·  view source on GitHub ↗

installAgentSystemMessage purges stale mode system messages and installs the freshly-built sysMsg for the current mode — replacing a surviving same-mode system message in place, or prepending when none exists.

(sysMsg models.Message, currentModeName string)

Source from the content-addressed store, hash-verified

920// freshly-built sysMsg for the current mode — replacing a surviving same-mode
921// system message in place, or prepending when none exists.
922func (a *AgentMode) installAgentSystemMessage(sysMsg models.Message, currentModeName string) {
923 a.cli.history = purgeStaleModeSystems(a.cli.history, currentModeName)
924
925 if len(a.cli.history) == 0 {
926 a.cli.history = append(a.cli.history, sysMsg)
927 return
928 }
929 // Replace any surviving system message of the CURRENT mode with
930 // the freshly-built sysMsg (workspace/skills/orchestrator blocks
931 // may have changed across turns). Otherwise prepend.
932 for i, msg := range a.cli.history {
933 if msg.Role == "system" && modeOfSystemMessage(msg) == currentModeName {
934 a.cli.history[i] = sysMsg
935 return
936 }
937 }
938 a.cli.history = append([]models.Message{sysMsg}, a.cli.history...)
939}
940
941// composeCoreText builds Block 1 of the agent system prompt (the stable core
942// behavior block): persona/coder/default base plus the language and gateway

Callers 1

RunMethod · 0.95

Calls 2

purgeStaleModeSystemsFunction · 0.85
modeOfSystemMessageFunction · 0.85

Tested by

no test coverage detected