# BR-AGT-07

Quand la réponse du modèle est diffusée au fil de l'eau, alors l'affichage montre des jetons jusqu'à la fin du message, sauf si l'application branche le décodeur de flux prévu.

Défini dans [Brancher la protection sur un agent et ses outils](https://docs.piighost.dev/fr/domain/integrations/agents-and-tools/#br-agt-07).

## Où vit la règle

- [`PIIAnonymizationMiddleware.deanonymize_stream()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L206)
- [`TextDeidentifier.__init__()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/_deidentify.py#L68)
- [`TextDeidentifier.anonymize()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/_deidentify.py#L102)

## Tests directs

- [`tests/integrations/langchain/test_middleware_stream.py::test_middleware_deanonymize_stream_restores_split_token`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware_stream.py#L33)
- [`tests/integrations/test_deidentify_stream.py::test_invented_token_is_dropped`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify_stream.py#L73)
- [`tests/integrations/test_deidentify_stream.py::test_invented_token_raises`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify_stream.py#L80)
- [`tests/integrations/test_deidentify_stream.py::test_literal_text_streams_through`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify_stream.py#L59)
- [`tests/integrations/test_deidentify_stream.py::test_token_split_across_chunks_is_restored`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify_stream.py#L51)
- [`tests/integrations/test_deidentify_stream.py::test_trailing_incomplete_token_is_flushed`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify_stream.py#L66)
- [`tests/integrations/test_deidentify.py::TestAnonymize::test_replaces_pii_with_a_token`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify.py#L46)
- [`tests/integrations/test_deidentify.py::TestDeanonymize::test_round_trips_a_message`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify.py#L53)
- [`tests/integrations/test_deidentify.py::TestInventedStrategy::test_drop_removes_an_invented_token`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify.py#L66)
- [`tests/integrations/test_deidentify.py::TestInventedStrategy::test_keep_leaves_an_invented_token`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify.py#L61)
- [`tests/integrations/test_deidentify.py::TestInventedStrategy::test_raise_refuses_an_invented_token`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/test_deidentify.py#L71)

## Tests indirects

- [`tests/integrations/langchain/test_middleware_e2e.py::test_second_model_call_never_sees_clear_tool_args`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware_e2e.py#L74)
- [`tests/integrations/langchain/test_middleware.py::TestFactoryContract::test_a_pipeline_without_a_recognizer_is_refused`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware.py#L639)
- [`tests/integrations/langchain/test_middleware.py::TestFactoryContract::test_reads_the_recognizer_from_the_pipeline`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware.py#L610)

## Utilisé par

- [`TextDeidentifier.anonymize_value()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/_deidentify.py#L150)

Lu dans le graphe du code que construit graphify, aux emplacements que donne la documentation métier.
