Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/api/mcp/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { registerTools } from "@/lib/tools";
import { withRequestContext } from "@/lib/context";

export const runtime = "nodejs";
// 정독 교정은 Solar를 세 번 부른다. Vercel Hobby는 60초로 잘리므로 그 경우
// depth를 standard 이하로 쓰거나 Pro(최대 300초)로 올려야 한다.
export const maxDuration = 300;
// 정독 교정은 Solar를 세 번(재교정까지 네 번) 부르고 호출당 120초 × 재시도 1회라
// 최악이면 300초를 넘긴다. Pro/Enterprise는 800초까지 올릴 수 있다.
// Hobby는 300초가 상한이라 그 경우 depth를 standard 이하로 써야 한다.
export const maxDuration = 800;

const handler = createMcpHandler(
(server) => {
Expand Down
10 changes: 7 additions & 3 deletions lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export async function proofread(opts: ProofreadOptions): Promise<ProofreadResult
const strength: Strength =
opts.strength ?? (depth === "light" ? "보수" : depth === "deep" ? "적극" : "기본");
const genre: Genre = opts.genre ?? "자동";
// deep은 통독·교정·롤백·보정으로 콜을 최대 네 번 쓴다. 호출당 120초 타임아웃에
// 재시도까지 붙으면 함수 상한(800초)을 넘긴다. 120초를 넘긴 호출은 다시 불러도
// 대개 또 넘기므로, 깊은 교정에서는 재시도를 끄고 상한 안에 가둔다.
const retries = depth === "deep" ? 0 : 1;

await precheck(provider, plannedCalls(depth));

Expand All @@ -143,7 +147,7 @@ export async function proofread(opts: ProofreadOptions): Promise<ProofreadResult
{ role: "system", content: p.system },
{ role: "user", content: p.user },
],
{ temperature: 0.3, maxTokens: 2500 },
{ temperature: 0.3, maxTokens: 2500, retries },
);
budget.record(res);
diagnosis = res.text.trim();
Expand All @@ -167,7 +171,7 @@ export async function proofread(opts: ProofreadOptions): Promise<ProofreadResult
{ role: "system", content: p.system },
{ role: "user", content: p.user },
],
{ temperature: 0.4, maxTokens: Math.min(32000, Math.ceil(text.length * 1.6) + 2000) },
{ temperature: 0.4, maxTokens: Math.min(32000, Math.ceil(text.length * 1.6) + 2000), retries },
);
budget.record(res);
return parsePolished(res.text);
Expand Down Expand Up @@ -248,7 +252,7 @@ export async function proofread(opts: ProofreadOptions): Promise<ProofreadResult
{ role: "system", content: p.system },
{ role: "user", content: p.user },
],
{ temperature: 0.25, maxTokens: Math.min(32000, Math.ceil(text.length * 1.6) + 2000) },
{ temperature: 0.25, maxTokens: Math.min(32000, Math.ceil(text.length * 1.6) + 2000), retries },
);
budget.record(res);
const fixed = parsePolished(res.text);
Expand Down
2 changes: 1 addition & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://openapi.vercel.sh/vercel.json",
"functions": {
"app/api/mcp/route.ts": {
"maxDuration": 300
"maxDuration": 800
}
}
}