AI 개발

OpenAI DevDay 2026 이후 AI Agent에 필요한 JSON 데이터 구조는? 2026 Request·Tool Call·Agent State 완전 해설

약 14분

DevDay는 라우팅(Decisions)과 실행(Responses / Agents)을 나눴지만, 호스트는 여전히 한 체인을 소유한다: 모델이 call을 내고, 당신이 result를 기록하고, response_id와 facts를 state에 저장한 뒤 다음 요청을 만든다. 이 글은 그 다섯 JSON 구간만 다룬다—workflow 층 분담이나 Agents API session 필드표 반복이 아니다.

읽기 전 요약

단계 전형 JSON(Responses 우선) 누가 씀
Request POST /v1/responses: model, input, tools; 이어가기는 previous_response_id state.next가 submit_request일 때 orchestrator가 조립
Tool Call 출력 항 type function_call; call_id + name + arguments 문자열 모델; 호스트가 arguments parse 후 실행
Tool Result 입력 항 function_call_output; 같은 call_id; output은 문자열화 JSON 부작용 후 호스트가 기록
Agent State run_id, phase, ids, facts, raw_tool_outputs, next(호스트 정의) 호스트만 영속; Decisions answers는 facts로 매핑 가능
Next Action 다음 요청: function_call_output만, 또는 새 user 메시지 + previous_response_id 호스트가 state.next.kind에서 선택—모델 산문 아님

사실 기준 2026-10-28: Responses function_call 가이드, Decisions GA input_json, DevDay 2026 recap. A-1042, call_3c91, run_demo_7c는 가상.

최소 다섯 JSON: request, call, result, state, 다음 홉

DevDay 이후 대부분 커스텀 agent는 Responses 도구 루프로 부작용을 돌린다: Decisions는 answers만 반환—lookup을 대신 실행하지 않는다. Agent State로 last response_id, pending call_id, 검증된 facts(order_id, route), next 액션 enum을 분리해 둔다. Agents API 장기 작업은 Call/Result를 session 이벤트 turn_id로 바꾼다—다른 체인, 별도 글.

  • Request: tools와 optional previous_response_id; state 전체를 prompt에 stringify하지 말 것.
  • Call / Result: arguments와 output은 문자열; 실행 전 검증; 같은 call_id로 기록.
  • State + Next: facts는 검증 필드; next는 orchestrator에 result 또는 새 Request 지시.

삼층 workflow: Workflow 실습. Agents API turn_id / required_actions: Agents API 데이터 구조. 레거시 필드 마이그레이션: API 마이그레이션.

Request → call → result → state → next

1. Request. state에 route_choice=lookup일 때, 이전 response_id로 도구 포함 Responses:

{
  "model": "gpt-6-luna",
  "previous_response_id": "resp_8k1a",
  "input": [{
    "role": "user",
    "content": [{
      "type": "input_text",
      "text": "Order A-1042 was routed to lookup. Call the tool if needed."
    }]
  }],
  "tools": [{
    "type": "function",
    "name": "lookup_order",
    "strict": true,
    "parameters": {
      "type": "object",
      "properties": {
        "order_id": { "type": "string", "pattern": "^[A-Z]-\\d{4}$" }
      },
      "required": ["order_id"],
      "additionalProperties": false
    }
  }]
}

2. Tool Call. 응답 output에 function_call; state.phase=awaiting_tool과 pending_call_id 설정:

{
  "type": "function_call",
  "call_id": "call_3c91",
  "name": "lookup_order",
  "arguments": "{\"order_id\":\"A-1042\"}"
}

3. Tool Result. lookup_order 실행 후 기록 항 구성(다음 요청 input 배열에 둔 JSON):

{
  "type": "function_call_output",
  "call_id": "call_3c91",
  "output": "{\"order_id\":\"A-1042\",\"status\":\"paid\",\"amount\":99.00}"
}

4. Agent State. 공식 API는 저장하지 않음; response_id와 업무 facts를 묶고 next 선언:

{
  "run_id": "run_demo_7c",
  "phase": "awaiting_tool",
  "ids": {
    "last_response_id": "resp_9f2b",
    "pending_call_id": "call_3c91"
  },
  "facts": {
    "order_id": "A-1042",
    "route_choice": "lookup"
  },
  "raw_tool_outputs": {},
  "next": { "kind": "submit_tool_output", "call_id": "call_3c91" }
}

5. Next Action. next.kind가 submit_tool_output이면 다음 홉은 often function_call_output + previous_response_id만:

{
  "model": "gpt-6-luna",
  "previous_response_id": "resp_9f2b",
  "input": [{
    "type": "function_call_output",
    "call_id": "call_3c91",
    "output": "{\"order_id\":\"A-1042\",\"status\":\"paid\",\"amount\":99.00}"
  }]
}

다섯 구간은 call_id와 response_id로 맞춤

DevDay 후 흔한 버그: Decisions choice는 facts에 들어가지만 phase 미갱신으로 function_call 중복. 표로 확인:

구간 안정적이어야 할 키 연결
Request previous_response_id, tools[].name state.ids.last_response_id
Tool Call call_id, arguments state.ids.pending_call_id
Tool Result call_id, output 문자열 Call과 동일 call_id
Agent State facts.*, phase, next.kind Decisions answers → facts; Response id → ids
Next Action input[]는 output 또는 새 user 내용 state.next가 구동, 모델 prose 아님

Decisions GA 후 대화 기록(function_call_output 포함)을 input에 둘 수 있다. 그건증거이지 state 대체가 아님—tool 기록 후 호스트가 facts 갱신.

감사 가능 루프 다섯 단계

staging에서 가상 order_id로 통과한 뒤 Decisions 라우팅 연결:

  1. state 초기화. run_id, 빈 facts, next=submit_request.
  2. Decisions answers 수집. route choice를 facts에; phase=ready_for_tool_request.
  3. Request 전송, call 수신. response_id를 ids에; 실행 전 arguments 검증.
  4. result 기록, state 갱신. raw_tool_outputs에 전량; facts는 하류 안전 필드만.
  5. next로 다음 홉. 요약은 별도 Responses structured output—raw와 객체 혼합 금지.

Agents API에서는 Call/Result를 session 이벤트로 교체; 호스트 state의 facts + next는 동일.

디버깅 시 Request와 State 각 하나 펼치기

「agent 기억 상실」 대부분은 response_id나 call_id drift—약한 추론이 아님.

  • 포맷로 arguments; Schema 검증로 tool 매개변수와 facts 부분 schema.
  • JSON Diff로 state 버전 간, 또는 Call arguments vs facts.order_id.
  • JSONPath로 raw_tool_outputs에서 facts 복사 누락 확인.
  • 작은 state.phase / facts 갱신에 JSON Patch(RFC 6902).
  • JSONSort 로컬—프로덕션 ticket·키 업로드 금지.

다섯 구간 모두 ID로 재구성할 수 있을 때 Agent State 소유—messages 배열을 DB로 쓰지 않음.

흔한 실수

  • messages 배열을 state로. 공식 기록에 phase / next enum 없음.
  • arguments를 객체로 바로 실행. JSON.parse 먼저, Schema 다음.
  • result 기록에 새 call_id. harness 멈춤; async도 원 call_id.
  • facts와 raw_tool_outputs 혼합. 하류는 facts; 감사는 raw.
  • previous_response_id 누락. reasoning 항 손실 또는 tool 정의 중복.
  • Decisions choice를 완료 tool로. choice는 facts; Call은 별도 턴.

FAQ

Agent State는 JSON 파일 필수?

JSON 객체 형태로 Schema 검증·Diff 용이; Redis/SQL도 같은 필드 계약.

function_call id vs call_id—어느 것?

2026 Responses 기록은 call_id로 function_call_output 정렬; 마이그레이션 글에 레거시 별칭.

Decisions answers를 Request에?

answers 전부 stringify 금지; 결론을 state.facts에; Request는 필요 user 텍스트나 input_json 증거만.

Agents API JSON 데이터 구조 글과 차이?

그 글은 session / turn_id / required_actions; 이 글은 DevDay 후 흔한 Responses 호스트 루프.

next.kind 표준화?

팀 enum 고정(submit_tool_output, submit_request, wait_human)—로그·리플레이.

결론

DevDay 2026 이후 agent JSON은 더 큰 prompt가 아니라 다섯 역할: Request 시작, Call로 부작용 선언, Result 기록, State 호스트 소유, Next는 state 구동. Decisions는 facts만, Call/Result 대체 아님.

API 필드보다 state schema 먼저. 모델은 여전히 Call만; 실행과 다음 홉 형태는 항상 호스트 JSON 결정.

더 읽기

변경 이력: 최초 게시