As it stands, if you use runAs[T] and the loop finishes with FinishReason.MaxIterations or FinishReason.TokenLimit, the finalAnswer, which has a type of Either[AgentParseError, T], will result in an AgentParseError. It makes no sense to attempt parsing in this case so a more graceful handling would be preferred.
As it stands, if you use
runAs[T]and the loop finishes withFinishReason.MaxIterationsorFinishReason.TokenLimit, thefinalAnswer, which has a type ofEither[AgentParseError, T], will result in anAgentParseError. It makes no sense to attempt parsing in this case so a more graceful handling would be preferred.