ChatHistoryTrim
Python template · sinapsis_chat_history.templates.chat_history_trim
Overview
Template to trim fetched chat history to fit a target prompt budget.
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-chat-history==1.0.0uv pip install sinapsis-chat-history==1.0.0uv add sinapsis-chat-history==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Maximum input-plus-output context length supported by the target model.
Required
Default: null
Extra token buffer reserved to absorb formatting and tokenizer-estimation mismatches.
Optional
Default: 256
Hugging Face tokenizer name or path used for prompt-size estimation.
Required
Default: null
Tokens reserved for model generation.
Optional
Default: 1024
Whether history messages with `system` or `developer` roles should be retained whenever possible.
Optional
Default: true
Configuration example
Example from the Python docstring:
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: ChatHistoryTrim
class_name: ChatHistoryTrim
template_input: InputTemplate
attributes:
tokenizer_model_name: 'Qwen/Qwen3.5-9B'
model_max_context: 8192
reserved_output_tokens: 2048Show schema-based configuration skeleton
templates:
- template_name: "ChatHistoryTrim"
class_name: "ChatHistoryTrim"
attributes:
model_max_context: "<required>"
safety_margin_tokens: 256
tokenizer_model_name: "<required>"
reserved_output_tokens: 1024
preserve_system_messages: true
Inheritance
sinapsis_core.template_base.template.TemplateEnvironment variables
Environment definitions belong to their canonical Python modules.
No directly related environment variables listed.