fix(prompt): priorStages text 가 prompt 에 박힐 때 2500자로 잘리던 마지막 잘림 지점

자기야 발견: 다랑이가 또 'editInput = document.createElement(...)' 에서 잘렸
다고 함. narang junior 의 LLM 출력 원본 (junior-01-*.md) 은 5KB 로 끝까지
정상이고, spawn.ts 의 aggregated/summary 도 64KB 로 OK 였는데, 실제 다랑이
LLM 에 박히는 prompt 텍스트 단계에서 또 잘리고 있었음.

원인: prompts.ts 의 buildPrompt 가 priorStages text 를 prompt 에 박을 때
slice(0, 2500) 로 자르고 있었음. 5KB 짜리 HTML 의 절반 가까이에서 정확히
잘림. prevStageOutput slice(0, 2000) 도 같은 패턴.

수정:
- priorStages text slice: 2500 → 64_000 (upstream 과 일치)
- prevStageOutput slice: 2000 → 32_000
- prompt 헤더에 "잘리지 않은 원본" 명시 추가 — LLM 이 "이게 잘렸나?" 의심
  하지 않게 (다랑이가 잘렸다고 오해할 가능성도 같이 줄임)

LLM context window (200k tokens+) 안에서 안전. priorStages 가 4 stage
누적되어도 256KB 정도면 50k tokens 미만.
This commit is contained in:
2026-04-11 02:21:52 +09:00
parent 294abdbc25
commit fe9ec0d9db

View File

@@ -66,17 +66,23 @@ export function buildPrompt(ctx: PromptContext): string {
}
if (ctx.priorStages && ctx.priorStages.length > 0) {
lines.push("");
lines.push(`# 앞 단계(들)의 결과물 — 반드시 참고해서 일관되게 이어가`);
lines.push(`# 앞 단계(들)의 결과물 — 반드시 처음부터 끝까지 모두 읽고 일관되게 이어가`);
lines.push(
`(아래 각 단계 본문은 잘리지 않은 원본이다. 코드가 중간에 끝난 것처럼 보이면 그것은 잘림이 아니라 진짜 끝이다.)`,
);
for (const ps of ctx.priorStages) {
lines.push("");
lines.push(`## ${STAGE_KOREAN[ps.stage] ?? ps.stage} 단계 결과`);
lines.push(ps.text.slice(0, 2500));
// Cap matches the upstream spawn.ts aggregation (64KB). LLM context
// windows are 200k+ tokens so this fits comfortably even after
// multiple stages accumulate.
lines.push(ps.text.slice(0, 64_000));
}
}
if (ctx.prevStageOutput) {
lines.push("");
lines.push(`# 직전 상위 노드(같은 stage) 의 지시`);
lines.push(ctx.prevStageOutput.slice(0, 2000));
lines.push(ctx.prevStageOutput.slice(0, 32_000));
}
lines.push("");
lines.push(`# 출력 형식`);