Class LlmCommandParser

java.lang.Object
com.agentforge4j.runtime.llm.LlmCommandParser

public final class LlmCommandParser extends Object
Parses raw LLM output text into a list of LlmCommands, validating each command's type against the agent's CommandResponseSchema and required fields before binding.
  • Constructor Details

    • LlmCommandParser

      public LlmCommandParser(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • parse

      public List<LlmCommand> parse(String rawResponse, CommandResponseSchema schema)
      Parses rawResponse into commands allowed by schema.
      Parameters:
      rawResponse - raw model output text, expected to contain a JSON array of command objects
      schema - the calling agent's command schema, used to validate types and required fields
      Returns:
      parsed commands in response order
      Throws:
      LlmCommandParseException - if the output is not valid JSON, is not a non-empty JSON array, or any element names an unknown/disallowed type or fails binding