Ensure the `"Observation:"` tag is present after stopping, since stopping on that token prevents it from appearing in the output.

#121

When the stop sequence includes "Observation:", the returned text ends before this tag appears in the output. As a result, the final message lacks the "Observation:" prefix, and the model has to generate a new observation that may not align with the actual result of the action. This can lead to hallucinated or incorrect agent behavior. By appending "Observation:" to the prompt manually after the model stops generating, we ensure the observation context is correctly set for the next step and that the model reacts to the actual output of the function.

Hugging Face Agents Course org

Thanks for the PR! It should be already solved

sergiopaniego changed pull request status to closed

Sign up or log in to comment