Responses will sometimes have a trailing newline

Just reporting this behavior. Sometimes when being asked to produce a summary of some text, gemini-flash-2.0’s response will include a trailing newline. I can’t think of a use case where this wouldn’t be undesirable. The issue seems to be intermittent. I have solved it on my end by strings.TrimSpace(response), but seems like something to investigate in the training data for the future. Trailing newlines could be useful in certain types of responses, such as code completion, but ideally the model would be more careful about trailing newlines in other types of responses.

2 Likes

we see this with vertex search (which uses gemini as a summary model). I’ve also noticed that newlines in prompt inputs will change the output significantly (semantics even). Which seems like a bug.