Mistral Vibe: Hooks Can Now Run Before and After Every Model Call

Mistral VibeView original changelog

Mistral Vibe 3.1.3 added two new hook types, pre_llm and post_llm, that fire around each call to the model. A pre_llm hook can stop the turn before the call is made. A post_llm hook can ask the model to try again, within a shared budget of 3 retries per turn.

Key Takeaways

  • Two new hook types, pre_llm and post_llm, now fire before and after each individual model call in Mistral Vibe.
  • A pre_llm hook can stop the turn before the model is called, which allows rule enforcement ahead of any token spend.
  • A post_llm hook can ask the model to try again after reviewing a response, including responses that contain tool calls.
  • Retries are bounded by a shared budget of 3 per turn between post_llm and post_agent hooks.
  • When the budget is exhausted, the turn now fails with the hook's name instead of an opaque internal error.
  • The post_agent payload gained turn_id and response_text, and vibe -p prints why a hook ended a turn, which helps scripting and CI use.

Hooks Move Closer to the Model

Mistral Vibe 3.1.3 widened its hook system with two new event types that fire around the model itself, rather than around tools or whole turns. Until now, hooks attached to tool use (pre_tool) and to the end of an agent turn (post_agent). The new hooks sit at the finest-grained point in the loop: each individual request to the model.

pre_llm: Check Before Each Call

A pre_llm hook runs before every call Mistral Vibe makes to the model. It can stop the turn, so teams can enforce a rule before any tokens are spent. Examples are refusing to continue when a condition is not met, or halting a run that has drifted from its task.

post_llm: Review and Retry After Each Response

A post_llm hook runs after each model response, tool calls included. It can ask the model to try again, which turns a hook into a lightweight quality gate. A script can inspect the response, reject it, and request a new attempt without the user stepping in.

A Shared Retry Budget

Retries are capped. post_llm hooks and post_agent hooks share a budget of 3 retries per turn. If a retry is requested but the turn has no step left for it, the turn fails and names the offending hook. Earlier, this situation surfaced as an internal error that gave no clue about the cause.

Related Hook Improvements

The post_agent hook payload now includes turn_id and response_text, the final answer of the turn. This gives hook scripts what they need to log or validate the result. In non-interactive mode, vibe -p now prints the reason when a hook ends the turn without the model's answer, so a silent stop is no longer a mystery in scripts and CI.

Why It Matters

Together these changes let developers build guardrails, audit trails and automatic self-correction into Mistral Vibe without modifying the tool. The retry limits keep a misbehaving hook from looping forever.