# BR-TOOL-09

When the model itself writes a value in clear in an argument, then the LangChain integration masks the history again before the next call.

Defined in [Let a tool act on the real values](https://docs.piighost.dev/en/domain/processes/let-a-tool-act/#br-tool-09).

## Where the rule lives

- [`PIIAnonymizationMiddleware._reanonymize_tool_calls()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L337)
- [`anonymize()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L172)

## Direct tests

- [`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)

## Indirect tests

- [`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)

## Used by

- [`PIIAnonymizationMiddleware.abefore_model()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L153)
- [`PIIAnonymizationMiddleware._anonymize_tool_output()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L253)

Read from the code graph graphify builds, at the places the domain documentation gives.
