C.W.K.
Stream
Lesson 02 of 07 · published

Strict Mode — schema-enforced 호출

~22 min · strict, schema-validation

Level 0Tokenizer
0 XP0/54 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

strict=True 는 production default 야. Strict 없이는 모델이 가끔 schema 와 거의 매칭하는 parameters 를 돌려줘 — almost. Strict 에선 API 가 모델의 첫 시도를 거부하고 corrected 시도 강제. Cost 살짝 더, defensive 파싱이 영원히 사라짐.

additionalProperties: false 필수

Strict mode 는 모든 object schema 에 additionalProperties: false 요구. 빠뜨리면 API 가 tool 정의 자체를 reject — 모델 호출 전.

Failure case 직접 봐

enum field 가진 tool, strict 없이 invalid enum 유도하는 prompt 보내. 가끔 invalid 값 돌아옴. Strict 켜고 같은 prompt — API 가 bad call 을 dev 에 도달 전 reject. 한 번 보면 strict 없는 tool 못 박아.

Trade-off

Strict 는 모델의 첫 시도가 거부될 때 internally retry — slightly higher latency, slightly higher cost. 그 cost 를 내고 'JSON output 에 쓰레기 끼는 사고' 가 통째로 사라지는 게 거래.

Code

Tool with strict=True·python
{
    "type": "function",
    "name": "create_event",
    "description": "Create a calendar event",
    "parameters": {
        "type": "object",
        "properties": {
            "title": {"type": "string"},
            "date": {"type": "string", "description": "ISO 8601 date"},
            "description": {"type": ["string", "null"]},  # optional via null union
        },
        "required": ["title", "date", "description"],     # ALL fields required
        "additionalProperties": False,                     # mandatory for strict
    },
    "strict": True,
}

External links

Exercise

Enum field 가진 tool. Strict 없이 invalid enum 유도하는 prompt — 모델이 invalid 값 반환하는 거 관찰. Strict=True 로 flip, API 가 bad call 을 reject 하는 거 관찰.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.