LangEx.Middleware.Rubric (LangEx v0.11.3)

Copy Markdown View Source

Middleware that gates the agent's final answer against a rubric.

When the agent is about to finish (its latest message makes no tool calls), a critic scores the answer against :rubric via LangEx.LLM.ChatModel.structured/2. If it falls short and attempts remain, the shortfall is appended as feedback and the agent is routed back for another pass — an exit gate on the tool loop, complementary to LangEx.Prebuilt.Reflect (which critiques every draft rather than only the final one).

Options

  • :rubric (required) - the "done" criteria the answer must satisfy
  • :model / :provider - the critic model (required)
  • :max_attempts - how many times the gate may bounce an answer back (default 2); once exhausted the answer is accepted
  • :resilient and other options are forwarded to the critic call

Summary

Functions

Builds a rubric completion-gate middleware. See the module doc for options.

Functions

new(opts)

@spec new(keyword()) :: LangEx.Middleware.t()

Builds a rubric completion-gate middleware. See the module doc for options.