AX Agent 코워크·코드 흐름과 컨텍스트 관리를 claude-code 기준으로 대폭 정리
- 코워크·코드 프롬프트, 도구 선택, 문서 생성/검증 흐름을 claude-code 동등 품질 기준으로 재정렬함 - OpenAI/vLLM 경로의 오래된 tool history를 평탄화하고 최근 이력만 구조화해 컨텍스트 직렬화를 경량화함 - AX Agent UI를 테마 기준으로 재구성하고 플랜 승인/오버레이/이벤트 렌더링/명령 입력 상호작용을 개선함 - 파일 후보 제안, 반복 경로 정체 복구, LSP 보강, 문서·PPT 처리 개선, 설정/서비스 인터페이스 정리를 함께 반영함 - README.md 및 docs/DEVELOPMENT.md를 작업 시점별로 갱신함 - 검증: dotnet build src/AxCopilot/AxCopilot.csproj -c Release -v minimal -p:OutputPath=bin\\verify\\ -p:IntermediateOutputPath=obj\\verify\\ (경고 0, 오류 0)
This commit is contained in:
@@ -30,10 +30,34 @@ public static class TokenEstimator
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var m in messages)
|
||||
total += Estimate(m.Content) + 4; // 메시지 오버헤드
|
||||
{
|
||||
var content = m.Content;
|
||||
// _tool_use_blocks JSON은 API 전송 시 구조화된 형식으로 변환되므로
|
||||
// 원시 JSON 길이 대비 약 40% 할인 적용 (JSON 래퍼 오버헤드 제거)
|
||||
if (m.Role == "assistant" && content != null && content.StartsWith("{\"_tool_use_blocks\""))
|
||||
total += (int)(Estimate(content) * 0.6) + 4;
|
||||
// tool_result JSON도 구조화 변환됨
|
||||
else if (m.Role == "user" && content != null && content.StartsWith("{\"type\":\"tool_result\""))
|
||||
total += (int)(Estimate(content) * 0.7) + 4;
|
||||
else
|
||||
total += Estimate(content ?? "") + 4;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/// <summary>시스템 프롬프트 + 도구 정의에 의한 기본 오버헤드 토큰을 추정합니다.</summary>
|
||||
/// <param name="systemPromptLength">시스템 프롬프트 문자 수</param>
|
||||
/// <param name="toolCount">등록된 도구 수</param>
|
||||
/// <returns>추정 토큰 수</returns>
|
||||
public static int EstimateBaseOverhead(int systemPromptLength, int toolCount)
|
||||
{
|
||||
// 시스템 프롬프트 토큰
|
||||
var sysTokens = systemPromptLength > 0 ? (int)(systemPromptLength / 3.5) : 0;
|
||||
// 도구 정의: 이름 + 설명 + 파라미터 스키마 ≈ 평균 180토큰/도구
|
||||
var toolTokens = toolCount * 180;
|
||||
return sysTokens + toolTokens;
|
||||
}
|
||||
|
||||
/// <summary>비용을 추정합니다 (USD 기준).</summary>
|
||||
public static (double InputCost, double OutputCost) EstimateCost(
|
||||
int promptTokens, int completionTokens, string service, string model)
|
||||
|
||||
Reference in New Issue
Block a user