pub fn prepare_session_for_execution(
session: &mut Session,
system_prompt: Option<&str>,
model: Option<&str>,
)Expand description
Apply the authoritative pre-execution mutations to session.
This encodes the single, authoritative behavior that every execution entry point must share:
- If
system_promptisSome, it is applied as the session’s leading System message. The supplied prompt is authoritative: if the first message is already aRole::Systemmessage it is replaced (never duplicated), otherwise a System message is inserted at index 0. This guarantees a caller-supplied session can’t silently shadow the configured instruction. - If
modelisSome,session.modelis set to it.
Call sites that don’t supply one of these inputs (e.g. the spawn paths, whose
caller already placed the system prompt) pass None for that parameter, so
behavior is identical to the previous inline logic.