Features
Intelligently truncate text to a specified length while maintaining content integrity and semantic coherence.
Use Cases
- Preprocess text that exceeds the length limit so that it meets the input requirements of the agent.
- When displaying text previews or generating summaries, extract key parts to improve efficiency and readability.
- Assist content creation by intelligently trimming generated long text to avoid redundancy.
Core Capabilities
- Semantic-priority truncation: Prioritize truncation at natural semantic boundaries (such as periods, question marks, and exclamation marks) to maximize sentence completeness.
- Paragraph integrity: When semantic boundaries are insufficient, prioritize truncation at the end of a paragraph or at a line break to avoid damaging the paragraph structure.
- Precise length control: Strictly comply with the maximum length limit specified by the user to ensure the output text does not exceed the limit.
- Truncation marker insertion(optional): A custom truncation marker (such as "...") can be automatically added at the end of the truncated text to indicate that content has been omitted.
Input Requirements
- Text content: The original text to be truncated (string).
- Maximum length limit: The maximum length of the truncated text (integer, such as number of characters or tokens).
- Truncation marker(optional): A custom truncation marker, such as "..." or "[content truncated]".
Output Format
【文本截断报告】
- 原始文本长度: [整数] 字/Token
- 截断后长度: [整数] 字/Token
- 截断位置: [位置描述,如 "在第X句末尾"] 或 "未截断"
### 截断后的文本
[截断后的文本内容]
Constraints
- The length of the truncated text must strictly conform to the maximum length limit.
- Ensure that the truncated text is as semantically coherent and complete as possible.
- If the text does not reach the maximum length, do not truncate it; return the original text.
- The output format must be structured, clearly displaying the length information before and after truncation and the truncated text content.
Examples
See {baseDir}/references/examples.md directory for more detailed examples:
examples.md- Truncation examples with different lengths, different truncation markers, and complex text structures.
Detailed Documentation
See {baseDir}/references/examples.md for detailed guidance and cases about the text truncation tool.
Version History
| Version | Date | Changes |
|---|---|---|
| 2.1.0 | 2026-01-11 | Optimized the description field to make it more concise and compliant with imperative language conventions; changed the model to opus; optimized the descriptions of features, core capabilities, input requirements, and output format to make them more compliant with imperative language conventions; added use cases, constraints, examples, and detailed documentation sections. |
| 2.0.0 | 2026-01-11 | Refactored according to official specifications |
| 1.0.0 | 2026-01-10 | Initial version |