# PatchToolCallsMiddleware

> **Class** in `deepagents`

📖 [View in docs](https://reference.langchain.com/python/deepagents/middleware/patch_tool_calls/PatchToolCallsMiddleware)

Middleware to patch dangling tool calls in the messages history.

## Signature

```python
PatchToolCallsMiddleware()
```

## Extends

- `AgentMiddleware`

## Methods

- [`before_agent()`](https://reference.langchain.com/python/deepagents/middleware/patch_tool_calls/PatchToolCallsMiddleware/before_agent)

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/829909166606f8a9d9571b00da725845bad08da7/libs/deepagents/deepagents/middleware/patch_tool_calls.py#L11)