Module: Protege::ResolverMixin
- Included in:
- Resolver
- Defined in:
- lib/protege/extensions/resolver_mixin.rb
Overview
Contract mixin for resolver classes. A resolver receives a Context and returns an
Array<Protege::ModelMessage> (one or more messages to prepend to the inference request)
or nil to contribute nothing. Resolvers are the Orchestrator's mechanism for assembling
inference context — system prompts, conversation history, retrieved knowledge.
Unlike Tool, resolvers are NOT auto-registered. They are explicitly added to a persona's
ResolverChain at declaration time. Host resolvers subclass Protege::Resolver, which
includes this module.
The role of returned messages is the developer's choice:
role: :system→ contributes to the system promptrole: :user/:assistant→ contributes to conversation history
Build messages with the #message helper rather than constructing Protege::ModelMessage by hand
— the resolver counterpart of +Tool+'s +success+/+failure+ sugar:
Instance Method Summary collapse
-
#message(role:, content:, tool_call_id: nil, tool_calls: nil) ⇒ Protege::ModelMessage
Build one context message to contribute from
#resolve, without constructingProtege::ModelMessageby hand — the resolver counterpart of +Tool+'s +success+/+failure+ sugar. -
#resolve(context:) ⇒ Array<Object>?
Produce context messages for the inference request.
Instance Method Details
#message(role:, content:, tool_call_id: nil, tool_calls: nil) ⇒ Protege::ModelMessage
Build one context message to contribute from #resolve, without constructing
Protege::ModelMessage by hand — the resolver counterpart of +Tool+'s +success+/+failure+ sugar.
Return the message directly (a lone message) or collect several in an array; the ResolverChain
coerces either shape and skips a nil return, so a resolver that contributes nothing just
returns nil.
54 55 56 |
# File 'lib/protege/extensions/resolver_mixin.rb', line 54 def (role:, content:, tool_call_id: nil, tool_calls: nil) Protege::ModelMessage.new(role:, content:, tool_call_id:, tool_calls:) end |
#resolve(context:) ⇒ Array<Object>?
Produce context messages for the inference request. Concrete resolvers must override.
32 33 34 35 |
# File 'lib/protege/extensions/resolver_mixin.rb', line 32 def resolve(context:) raise NotImplementedError, "#{self.class} must implement #resolve(context:) -> Array<ModelMessage> | nil" end |