Throw ToolException with kind

throw new ToolException(ToolErrorKind.NOT_FOUND, "No user with id " + userId);
Advertisement

Error kinds

  • NOT_FOUND — LLM can try a different arg.
  • PERMISSION_DENIED — LLM should stop trying.
  • TRANSIENT — LLM may retry.
  • VALIDATION — LLM should reformat.
Advertisement

Message clarity

Write messages the LLM will parse: 'The user_id must start with u_. Got: 12345.' Model will retry with the correct format.