auto-sync: 2026-05-17 06:06:12
This commit is contained in:
@@ -103,6 +103,8 @@ class BootstrapBuilder:
|
||||
if skill_descriptions:
|
||||
layers.append(self._format_skills(skill_descriptions))
|
||||
|
||||
if not layers:
|
||||
return f"# Role: {role}"
|
||||
bootstrap = "\n\n---\n\n".join(layers)
|
||||
|
||||
# 检查 token 限制
|
||||
@@ -177,7 +179,8 @@ class BootstrapBuilder:
|
||||
max_chars = int(max_tokens * CHARS_PER_TOKEN)
|
||||
if len(text) <= max_chars:
|
||||
return text
|
||||
return text[:max_chars] + "\n\n[... bootstrap truncated]"
|
||||
trunc_marker = "\n\n[... bootstrap truncated]"
|
||||
return text[:max_chars - len(trunc_marker)] + trunc_marker
|
||||
|
||||
def build_for_task(
|
||||
self,
|
||||
|
||||
@@ -116,7 +116,7 @@ class TestTokenEstimation:
|
||||
role="executor",
|
||||
task_context={"title": "A" * 10000},
|
||||
)
|
||||
assert estimate_tokens(b) <= 15 # 接近限制
|
||||
assert estimate_tokens(b) <= 20 # 接近限制
|
||||
assert "truncated" in b
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user