estimate_context
Estimate token size of a message list before sending to a model, so you can keep requests under the context window and avoid "Prompt is too long" errors.
Instructions
Estimate the current context size in tokens before sending it to the model.
Example call::
estimate_context({
"messages": [{"role": "user", "content": "hello"}],
"max_context_tokens": 32768,
})
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"messages": "<messages>"
},
"name": "estimate_context"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messages | Yes | ||
| max_context_tokens | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |