vibe.assistant.context

Model context management for the assistant.

ModelContextManager

Orchestrates conversation context management for the assistant model.

Composes specialized components: - HistoryPruner: Prunes conversation history based on strategy - UserInputProcessor: Applies security protection to user messages - SystemPromptBuilder: Builds system prompts from templates

The class coordinates these components to construct the messages list sent to the LLM, handling different strategies for context management.

__init__

__init__(provider: LLMProvider) -> None

Initialize the context manager.

Parameters:

build_prompt_messages

build_prompt_messages(session_state: dict[str, Any]) -> list[Message]

Construct the full messages list based on the configured strategy.

Parameters:
  • session_state (dict[str, Any]) –

    Session state containing history, draft_blocks, etc.

Returns:
  • list[Message]

    List of Message objects ready for the LLM

update_with_turn_result

update_with_turn_result(session_state: dict[str, Any], user_message: UserMessage, assistant_response: AssistantMessage) -> None

Update session state's history after a turn is complete.

Parameters:
  • session_state (dict[str, Any]) –

    Session state to update

  • user_message (UserMessage) –

    The user's message for this turn

  • assistant_response (AssistantMessage) –

    The assistant's response