Interface ReplyDecoder

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ReplyDecoder
Turns a model's reply text into the type a typed AgenticHarness.send(String, Class) asked for.

The harness decodes with its own default, which handles records, collections, enums, and java.time. Supply one when a reply type needs handling that default cannot give it — an Ignition interface such as TagPath, a Kotlin data class, anything whose deserializer lives in the calling module. A decoder built by the caller resolves those in the caller's ClassLoader, which the harness's own never sees.

.replyDecoder((text, type) -> gson.fromJson(text, type))
.replyDecoder((text, type) -> mapper.readValue(text, type))

Reject a reply that does not match the requested type rather than filling missing members with defaults. The harness treats a throw as "ask the model again"; a decoder that returns a half-populated object instead hands the caller confident garbage.

  • Method Summary

    Modifier and Type
    Method
    Description
    decode(String text, Class<?> type)
     
  • Method Details

    • decode

      Object decode(String text, Class<?> type) throws Exception
      Parameters:
      text - the model's reply, already stripped of any wrapping markdown fence.
      type - the type the caller asked for; the return value must be an instance of it.
      Throws:
      Exception - if text does not represent a valid type. The message becomes the repair prompt sent back to the model, so it should say what was wrong.