feat: inject mode changes into engine conversation history

Engine.InjectMessage() appends messages to history without triggering
a turn. When permission mode or incognito changes, the notification
is injected as a user+assistant pair so the model sees it as context.

Fixes: model now knows permissions changed and will retry tool calls
instead of remembering old denials from previous mode.
This commit is contained in:
2026-04-03 16:42:52 +02:00
parent 9e064e52ad
commit 17bd84d56b
2 changed files with 30 additions and 8 deletions

View File

@@ -107,6 +107,13 @@ func (e *Engine) History() []message.Message {
return e.history
}
// InjectMessage appends a message to conversation history without triggering a turn.
// Used for system notifications (permission mode changes, incognito toggles) that
// the model should see as context in subsequent turns.
func (e *Engine) InjectMessage(msg message.Message) {
e.history = append(e.history, msg)
}
// Usage returns cumulative token usage.
func (e *Engine) Usage() message.Usage {
return e.usage