AfterCorrection

org.llm4s.testkit.AfterCorrection

Matches a conversation whose last message is the agent's correction request: the retry of a structured answer (AgentBuilder.withOutput) that did not match its schema. It extracts nothing, so a rule writes it with parentheses - case AfterCorrection() =>. Without them the pattern compares the conversation with this object and never matches.

ScriptedLLMClient.respondingTo {
 case AfterCorrection()  => Reply.text("""{"customer":"Acme","total":12.5}""")
 case EndsWithUser(_)    => Reply.text("""{"customer":"Acme","total":"lots"}""")
}

The request is recognised by how its text starts, with the constant the agent runtime writes it with: a user message has nothing else to mark it. A user message of the test's own that starts the same way matches too.

Attributes

Source
RuleExtractors.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def unapply(conversation: Conversation): Boolean

True when the last message is the agent's correction request.

True when the last message is the agent's correction request.

Attributes

Source
RuleExtractors.scala