Skip to content

요청 한도를 넘을 때만 오래된 도구 출력 본문 생략(ADR-0097 1단계) - #171

Draft
SonAIengine wants to merge 3 commits into
mainfrom
design/tool-output-delivery
Draft

SonAIengine wants to merge 3 commits into
mainfrom
design/tool-output-delivery

Conversation

@SonAIengine

Copy link
Copy Markdown
Contributor

배경

Terminal-Bench 2.1 약한 모델 실험(agy gemini-3.8-flash-low)의 89과업 기준선은 34개 통과(38%)다. 실패 55개 중 32개가 model_rejected.request_too_large로 끝났다. 모델은 계속할 수 있었는데 host가 요청을 보내지 못했다.

  • planning 예산(manifest 512 KiB)과 agy prompt 한도(100,000바이트)가 따로 있다.
  • toolOutputs는 packing 대상이 아니라 항상 원문이었다. 넘친 요청의 평균 크기는 74 KB였다.

변경

  • PlannerPort::max_context_bytes: transport 한도를 context builder에 알린다.
    • agy는 prompt_limit()을 쓴다.
    • HTTP는 XGEN_OPENAI_MAX_PROMPT_BYTES(16 KiB~1 MiB)를 줄 때만 켠다. 기본 동작은 그대로다.
  • 넘칠 때만 생략한다.
    • 최근 3개를 뺀 오래된 출력부터 본문을 빼고, elided: true와 고정 elidedMeaning stub을 남긴다.
    • 넘친 양을 예산 1/4 단위로 올림해 생략 범위를 고정한다. 그래서 prefix cache가 유지된다.
  • 원문은 journal과 tool_outputs에 그대로 있다. 바뀌는 건 모델에 보내는 view뿐이다.
  • 문서 추가: ADR-0097, getting-started의 env 설명.

검증

  • cargo test --workspace 실패 0, 새 테스트 3개 추가.
  • clippy --workspace --all-targets -D warnings 통과.
  • scripts/diff-model-requests.py --base <main bin> --head <this bin>: 8개 사례 모두 differences 0, "model requests match". 한도 안의 요청은 바이트가 같다.
  • 실측(진행 중):
    • 대상은 request_too_large 32과업이다. 해시 순서로 설계 16, held-out 16으로 나눴다.
    • 첫 과업에서 24개 요청 중 11개가 생략됐고, 최대 prompt는 85.8K, 413은 0건이었다.
    • 결과가 나오면 이 PR에 붙인 뒤 draft를 해제한다.

🤖 Generated with Claude Code

SonAIengine and others added 3 commits November 29, 2026 21:02
Terminal-Bench 2.1 약한 모델 측정에서 끝난 73과업 중 실패 47개의 57%(27개)가
request_too_large로 Run이 끝났다. 평균 구성은 toolOutputs 74 KB,
capabilities 22 KB, steps 14 KB다. 원인은 둘이다. planning context 예산
(512 KiB)과 agy transport 한도(100,000바이트)가 따로 있다. 그리고 도구 출력은
packing 대상이 아니라 항상 원문 전부가 들어간다.

1단계 제안: planner port 한도를 예산의 단일 출처로 쓰고, 넘칠 때만 오래된
출력 본문을 stub으로 바꾼다(최근 3개 보존, 75%까지 내려 cache 보존). 한도 안의
요청은 바이트가 같다. 생략 순서는 설계 14·held-out 13 과업으로 측정해 고른다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terminal-Bench 2.1 약한 모델 실험에서 실패 47개 중 27개가 request_too_large로 끝났다.
planning 예산(512 KiB)과 agy prompt 한도(100,000바이트)가 따로 있었고, toolOutputs는
packing 대상이 아니라 평균 74 KB가 항상 원문으로 들어갔다.

- PlannerPort::max_context_bytes로 transport 한도를 context builder에 알린다.
  agy는 prompt_limit(), HTTP는 XGEN_OPENAI_MAX_PROMPT_BYTES(16 KiB~1 MiB)로만 켠다.
  한도 = prompt 한도 - system prompt 길이 - envelope 여유 2,048바이트.
- 넘칠 때만 최근 3개를 뺀 오래된 출력부터 본문을 빼고 elided stub과 고정 문장을 남긴다.
  넘친 양을 예산 1/4 단위로 올림해 생략 앞부분을 고정, prefix cache 재사용을 지킨다.
- 원문은 journal·tool_outputs에 그대로 있고 모델에 보내는 view만 바뀐다.

검증: cargo test --workspace 실패 0, clippy -D warnings 통과, 새 테스트 3개.
diff-model-requests base/head 8개 사례 모두 차이 0(한도 안 요청 바이트 동일).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant