Clarify contextual user fragment registry docs

Document the contextual user registry with the same level of guidance as the developer registry, including detection-only fragments versus turn-state diff fragments.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-13 03:26:32 -07:00
parent 6b40e2a99d
commit 4f554b902a

View File

@@ -259,9 +259,21 @@ where
/// Canonical contextual-user fragment registry.
///
/// Add new contextual-user fragment types here so injected context is not
/// mistaken for real user intent during event mapping/truncation, and to wire
/// turn-state contextual-user diff fragments in one place.
/// Add new contextual-user fragments by:
/// 1. Defining a typed fragment struct.
/// 2. Implementing `ModelVisibleContextFragment` with
/// `Role = ContextualUserContextRole`.
/// 3. Implementing contextual-user detection via
/// `TaggedContextualUserFragment` or `ContextualUserFragmentDetector`.
/// 4. If the fragment is derived from turn state, implementing
/// `TurnContextDiffFragment::build` and registering it with
/// `Some(build_contextual_user_turn_state_fragment::<YourType>)`.
/// 5. Otherwise registering it with `None` for diffing so it still participates
/// in contextual-user history parsing.
///
/// Register new fragment types here so injected context is not mistaken for
/// real user intent during event mapping/truncation, and to wire turn-state
/// contextual-user diff fragments in one place.
const REGISTERED_CONTEXTUAL_USER_FRAGMENTS: &[ContextualUserFragmentRegistration] = &[
ContextualUserFragmentRegistration::new(
detect_contextual_user_fragment::<crate::instructions::AgentsMdInstructions>,