Enhance error handling for OutputGuardrailTripwireTriggered exception… #338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When CAI generates reports at the end of an assessment with
CAI_STREAM=true, instead of displaying the report cleanly, the terminal output shows corrupted behavior:My assumption is that this is caused by output guardraisl detecting dangerous content (like exploit code or sqli-payloads) and raises an OutputGuardrailTripwireTriggered exception. But this exception is not handled properly by the streaming-system.
Therefore the live display context remains active and is not cleaned up properly
I added this piece of code in cli.py at line 1511 as a workaround / solution
this stops the stream to break but leads to the output of the exception-message found in cli.py at around line 1598
indicating that the guardrail is indeed triggered by the stream (but not blocking the stream)