# tool_call_buffer_key

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/_tool_stream/tool_call_buffer_key)

Compute a stable key for buffering an in-progress streamed tool call.

Prefers the streaming `index` (stable across fragments of one call), then
the tool-call `id`, falling back to a positional placeholder so unrelated
id-less calls don't collide.

## Signature

```python
tool_call_buffer_key(
    index: int | str | None,
    tool_id: str | None,
    count: int,
) -> ToolCallBufferKey
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `index` | `int \| str \| None` | Yes | The `index` field from the streamed tool-call chunk, if any. Typed loosely because it is read from an untyped content-block dict. |
| `tool_id` | `str \| None` | Yes | The tool-call `id` from the chunk, if any. |
| `count` | `int` | Yes | The current number of buffered calls, used to make the fallback placeholder unique. |

## Returns

`ToolCallBufferKey`

The chunk `index`, else the `tool_id`, else a unique placeholder string.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/e14e0adcbe78565ed3650e7f24b2a775d5437d25/libs/code/deepagents_code/_tool_stream.py#L228)