# BR-AGT-01

When a LangChain agent is called without a conversation identifier, then it stops on No thread_id in the LangGraph config; pass config={'configurable': {'thread_id': ...}} on the agent call, or 'default' if your conversations need no separation.

Defined in [Plug the protection into an agent and its tools](https://docs.piighost.dev/en/domain/integrations/agents-and-tools/#br-agt-01).

## Where the rule lives

- [`_thread_id()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L47)

## Direct tests

- [`tests/integrations/langchain/test_middleware.py::TestThreadId::test_a_missing_id_raises`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware.py#L176)
- [`tests/integrations/langchain/test_middleware.py::TestThreadId::test_reads_the_configured_thread_id`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware.py#L158)
- [`tests/integrations/langchain/test_middleware.py::TestThreadId::test_the_shared_thread_is_named_explicitly`](https://github.com/Athroniaeth/piighost/blob/master/tests/integrations/langchain/test_middleware.py#L183)

## 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_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/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.aafter_model()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L186)
- [`PIIAnonymizationMiddleware.abefore_model()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L153)
- [`PIIAnonymizationMiddleware.awrap_tool_call()`](https://github.com/Athroniaeth/piighost/blob/master/src/piighost/integrations/langchain/middleware.py#L220)

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