count_tokens.py crashes on text containing special tokens like <|endoftext|> (tiktoken disallowed_special default)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Đọc skills/bmad-*-builder/scripts/count_tokens.py để xem count_tokens() tải mã hóa tiktoken và gọi enc.encode(text) như thế nào. Kiểm tra các hàm gọi trong prepass-prompt-metrics.py và prepass.py của agent-builder để hiểu lỗi ảnh hưởng đến từng pre-pass ra sao. Công việc hoàn tất khi các chuỗi special-token được đếm mà không phát sinh ngoại lệ, cấu hình mã hóa được tái sử dụng giữa các tệp, và lệnh cùng các pre-pass chạy xong với đầu vào được mô tả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
count_tokens() in skills/bmad-*-builder/scripts/count_tokens.py guards only import tiktoken and tiktoken.get_encoding(...), then calls enc.encode(text) with tiktoken's default disallowed_special="all". tiktoken raises ValueError ("Encountered text corresponding to disallowed special token '<|endoftext|>'...") when the text contains a special-token string.
Any skill or reference that mentions such a token, for example a skill about tokenizers, prompt formats or LLM evaluation, makes:
count_tokens.py <file>exit with a traceback;prepass-prompt-metrics.pycrash, since it importscount_tokensand calls it on every file, which aborts the Analyze pre-pass.
(The agent-builder prepass.py swallows the exception and silently falls back to chars // 4 for that file.)
This report is from reading the code: the tiktoken encoding download is blocked in my test sandbox, so I couldn't run the tiktoken path. The behaviour is tiktoken's documented default.
Steps to reproduce
printf -- '---\nname: sk\ndescription: Explains tokenizers. Use when asked.\n---\n# sk\n\nModels end documents with the <|endoftext|> marker.\n' > sk/SKILL.md
uv run skills/bmad-workflow-builder/scripts/count_tokens.py sk/SKILL.md
# expected with tiktoken available: ValueError: Encountered text corresponding to disallowed special token '<|endoftext|>'
Expected behavior
Count special-token text as ordinary text: enc.encode(text, disallowed_special=()). Also cache the encoding at module level. Today get_encoding runs per file, and when the encoding can't be downloaded the pre-passes retry the network for every file before falling back, about 0.2 s/file here.
Environment
- Model(s) used: n/a (deterministic script)
- Agentic IDE used: n/a (scripts run directly)
- BMad version: bmad-builder
main@d4a921c(v2.2.2 + #118) - Project language: Python 3.13, Linux
- Ngôn ngữ chính
- Python
- Star
- 220
- Fork
- 54
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bmad-code-org/bmad-builder
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bmad-code-org/bmad-builder#157 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bmad-code-org/bmad-builder#151 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
bmad-code-org/bmad-builder#127 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
bmad-code-org/bmad-builder#123 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
bmad-code-org/bmad-builder#121 ·
Tất cả issue của bmad-code-org/bmad-builder
Issue tương tự
-
Claiming namespace `kliklamala`Đang mởnamespace
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
EclipseFdn/open-vsx.org#15604 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
app: scripts severity: low status: backlog type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
netbox-community/netbox-scripts#164 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 5 ngày
-
Public function to read participants.tsvCó thể đã có người làm @bruAristimunha đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
huggingface/tau#799 ·
Maintainer thường phản hồi trong vòng 2 ngày