메뉴
HN
Hacker News • 15일 전

OpenAI, 에이전트 API 공개

IMP
8/10
핵심 요약

OpenAI가 Codex 하네스를 API로 제공하는 'Agents API'를 발표했습니다. OpenAI가 세션 관리, 오케스트레이션, 컨텍스트 압축, 복구를 담당하고, 개발자는 도구와 실행 환경만 제공하면 에이전트가 샌드박스에서 코드 실행, 파일 편집, MCP 서버 연결 등을 수행할 수 있습니다. 요금은 선택한 모델의 API 요율에 따라 부과됩니다.

번역된 본문

Agents API는 애플리케이션이 OpenAI가 관리하는 API를 통해 Codex 하네스에 접근할 수 있게 해줍니다. OpenAI가 세션, 오케스트레이션, 컨텍스트 압축, 복구를 관리하는 반면, 애플리케이션은 도구를 제공하고 실행 환경을 선택합니다. 에이전트는 코드를 실행하고, 파일을 편집하고, MCP 서버에 연결하고, 결과물(아티팩트)을 생성할 수 있는 샌드박스에서 작동할 수 있습니다.

요금제: 모델 사용량은 선택한 모델의 API 요율로 청구됩니다. OpenAI 도구는 표준 요율이 적용되며, OpenAI 호스팅 샌드박스는 표준 컨테이너 요율이 적용됩니다.

예제 체험하기: 다음 완성된 예제를 사용해 보세요.

  • OpenAI 호스팅 샌드박스에서 디렉터리 트리 스크립트를 생성하고 실행하기
  • 서브에이전트로 릴리스 노트를 비교하고 결과를 하나의 답변으로 통합하기

완성된 애플리케이션 탐험하기:

  • 사고 대응 에이전트: 알림을 조사하고 복구 작업에 대한 승인을 요청
  • Slack 봇: 연결된 직장 도구로 요청을 조사
  • 데이터 분석가: 읽기 전용 SQL로 데이터 웨어하우스 질문에 답변
  • GitHub 이슈 조사자: 보고된 버그를 재현하고 GitHub에서 결과 공유
  • 문서 검토자: 정책 스킬과 전문 에이전트로 문서 검토

핵심 개념: Agents API는 네 가지 주요 개념을 중심으로 구축됩니다.

  • 에이전트(Agent): 모델, 지침, 도구, 에이전트가 사용할 수 있는 MCP 서버
  • 환경(Environment): 에이전트가 파일에 접근하고, 스킬을 로드하고, 명령을 실행하는 선택적 샌드박스 또는 컴퓨터
  • 세션(Session): 작업을 수행하고 입력에 응답하는 내구성 있는 에이전트 인스턴스
  • 이벤트와 항목(Events and items): 에이전트에 보내는 입력과 세션 중 생성되는 출력

세션의 시작부터 끝까지: 퀵스타트에서 OpenAI 호스팅 샌드박스로 시작하세요.

  1. 세션 생성: 에이전트를 구성하면 OpenAI가 환경을 프로비저닝합니다.
  2. 작업 부여: 사용자 입력은 환경이 준비되면 한 턴의 작업을 시작합니다.
  3. 진행 상황 추적: 출력을 스트리밍하거나 웹훅을 사용해 에이전트가 완료되었거나 입력이 필요할 때 알림을 받습니다.
  4. 계속하거나 조정: 같은 세션에 다른 작업을 보내거나, 현재 턴 동안 에이전트를 안내합니다.

OpenAI 호스팅 세션을 사용하면, 애플리케이션은 입력을 보내고 이벤트를 받는 반면, OpenAI가 에이전트를 실행하고 샌드박스를 프로비저닝하고 관리합니다. 설정 및 제한 사항은 환경 옵션을 참조하세요.

관리형 하네스가 제공하는 기능:

  • 샌드박스에서 명령 및 코드 실행
  • 관련 스킬과 지침 적용
  • 도구 또는 MCP를 통한 외부 데이터 연결
  • 작업 중 에이전트 조정(스티어링)
  • 이전 작업 요약을 통한 컨텍스트 윈도우 관리
  • 작업을 서브태스크로 나누고 서브에이전트에 위임
  • 세션을 중단한 지점에서 재개

API 키 권한 및 SDK 설정은 퀵스타트 사전 요구 사항을 확인하세요. 세션을 생성할 때 이러한 기능을 구성할 수 있습니다. 아래는 관리형 하네스 기능을 구성하는 예제 코드입니다(Python/JavaScript). 모델로 'gpt-6-astra'를 지정하고, 프로그래매틱 도구 호출(programmatic_tool_calling), OpenAI 문서 MCP 서버, 웹 검색 도구를 설정하며, 최대 4개의 동시 서브에이전트를 허용하는 멀티 에이전트 설정을 포함합니다. 환경은 셀프 호스팅(self_hosted)으로 지정해 워크스페이스 디렉터리와 스킬 디렉터리를 설정할 수 있으며, 사용자 입력으로 "MCP 서버를 OpenAI 에이전트에 연결하는 방법을 조사하고, 최신 업데이트를 확인하고, 권장 설정을 요약하라"는 작업을 전달하는 예시입니다.

원문 보기
원문 보기 (영어)
The Agents API gives your application access to the Codex harness through an OpenAI-managed API. OpenAI manages sessions, orchestration, context compaction, and recovery while your application provides tools and chooses its execution environment. Agents can operate in a sandbox where they can execute code, edit files, connect to MCP servers, and produce artifacts. Pricing Model usage is billed at the selected model’s API rates . OpenAI tools use their standard rates , and OpenAI-hosted sandboxes use standard container rates . Try an example Try these complete examples: Create and run a directory-tree script in an OpenAI-hosted sandbox. Compare release notes with subagents and combine their findings into one answer. Explore complete applications: Incident response agent : investigate alerts and request approval for recovery actions. Slack bot : investigate requests using connected workplace tools. Data analyst : answer warehouse questions with read-only SQL. GitHub issue investigator : reproduce reported bugs and share findings on GitHub. Document reviewer : review documents with policy skills and specialist agents. Core concepts The Agents API is built around four main concepts: Agent: The model, instructions, tools, and MCP servers available to the agent. Environment: An optional sandbox or computer where the agent accesses files, loads skills, and runs commands. Session: A durable instance of an agent that works on tasks and responds to input. Events and items: The inputs sent to an agent and the output produced during a session. A session from start to finish Start with an OpenAI-hosted sandbox in the quickstart : Create a session. Configure the agent; OpenAI provisions its environment. Give it a task. User input starts a turn of work once the environment is ready. Follow progress. Stream output or use webhooks to learn when the agent finishes or needs input. Continue or steer. Send another task to the same session, or guide the agent during its current turn. With an OpenAI-hosted session, your application sends input and receives events, while OpenAI runs the agent and provisions and manages its sandbox. See environment options for setup and limitations. What the managed harness provides The managed Codex harness supports: Running commands and code in a sandbox. Applying relevant skills and instructions. Connecting to external data through tools or MCP. Steering the agent while it works. Summarizing previous work to manage its context window. Breaking work into subtasks and delegating to subagents. Resuming a session where it left off. Check the quickstart prerequisites for API-key permissions and SDK setup. Configure these capabilities when you create a session: Configure managed-harness capabilities Python 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 import OpenAI from "openai"; const client = new OpenAI(); const session = await client.beta.agents.sessions.create({ agent: { model: "gpt-6-astra", instructions: "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful.", tools: [ { type: "programmatic_tool_calling" }, { type: "mcp", server_label: "openai_docs", transport: { type: "http", server_url: "https://developers.openai.com/mcp", }, }, { type: "web_search" }, ], multi_agent: { enabled: true, max_concurrent_subagents: 4 }, }, environment: { type: "self_hosted", workspace_directory: "/workspace", capability_directories: ["/workspace/capabilities/skills"], }, input: [ { role: "user", content: [ { type: "input_text", text: "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup.", }, ], }, ], }); console.log(session.id); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 from openai import OpenAI client = OpenAI() session = client.beta.agents.sessions.create( agent = { "model" : "gpt-6-astra" , "instructions" : "Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful." , "tools" : [ { "type" : "programmatic_tool_calling" }, { "type" : "mcp" , "server_label" : "openai_docs" , "transport" : { "type" : "http" , "server_url" : "https://developers.openai.com/mcp" , }, }, { "type" : "web_search" }, ], "multi_agent" : { "enabled" : True , "max_concurrent_subagents" : 4 }, }, environment = { "type" : "self_hosted" , "workspace_directory" : "/workspace" , "capability_directories" : [ "/workspace/capabilities/skills" ], }, input = [ { "role" : "user" , "content" : [ { "type" : "input_text" , "text" : "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup." , } ], } ], ) print (session.id) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import ( "context" "fmt" "github.com/openai/openai-go/v3" ) ctx := context.Background() client := openai.NewClient() session, err := client.Beta.Agents.Sessions.New(ctx, openai.BetaAgentSessionNewParams{Agent: openai.BetaAgentSessionNewParamsAgent{Model: openai.String("gpt-6-astra"), Instructions: openai.String("Use the OpenAI documentation MCP and web search to answer technical questions accurately. Delegate independent research tasks to subagents when useful."), Tools: []openai.AgentToolParamUnion{openai.AgentToolParamUnion{OfParamProgrammaticToolCalling: &openai.AgentToolParamProgrammaticToolCalling{}}, openai.AgentToolParamUnion{OfParamMcp: &openai.AgentToolParamMcp{ServerLabel: "openai_docs", Transport: openai.McpTransportParamUnion{OfParamHTTP: &openai.McpTransportParamHTTP{ServerURL: "https://developers.openai.com/mcp"}}}}, openai.AgentToolParamUnion{OfParamWebSearch: &openai.AgentToolParamWebSearch{}}}, MultiAgent: openai.MultiAgentConfigParam{Enabled: true, MaxConcurrentSubagents: openai.Int(4)}}, Environment: openai.EnvironmentParamUnion{OfParamSelfHosted: &openai.EnvironmentParamSelfHosted{WorkspaceDirectory: "/workspace", CapabilityDirectories: []string{"/workspace/capabilities/skills"}}}, Input: openai.BetaAgentSessionNewParamsInputUnion{OfArrayOfInputMessages: []openai.AgentSessionInputMessageParam{openai.AgentSessionInputMessageParam{Content: []openai.InputContentParamUnion{openai.InputContentParamUnion{OfParamInputText: &openai.InputContentParamInputText{Text: "Research how to connect an MCP server to an OpenAI agent, check for recent updates, and summarize the recommended setup."}}}}}}}) if err != nil { panic(err) } fmt.Println(session.ID) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 import com.openai.client.OpenAIClient; import com.openai.client.okhttp.OpenAIOkHttpClient; import com.openai.models.beta.agents.AgentToolParam; import com.openai.models.beta.agents.EnvironmentParam; import com.openai.models.beta.agents.McpTransportParam; import com.openai.models.beta.agents.MultiAgentConfigParam; import com.openai.models.beta.agents.sessions.SessionCreateParams; import java.util.List; OpenAIClient client = OpenAIOkHttpClient.fromEnv(); var session = client .beta() .agents() .sessions() .create( SessionCreateParams.builder() .agent( SessionCreateParams.Agent.builder() .model("gpt-6-astra") .instructions( "Use the OpenAI documentation MCP and web search to answer" + " technical questions accurately. Delegate independent" + " research tasks to subagents when useful.") .addTool(AgentToolParam.ProgrammaticToolCalling.builder().build()) .addTool( AgentToolParam.Mcp.builder() .serverLabel("openai_docs") .transport( McpTransportParam.Http.builder() .serverUrl("https://developers.openai.com/mcp") .build()) .build()) .addTool(AgentToolParam.WebSearch.builder().build()) .multiAgent( MultiAgentConfigParam.builder() .enabled(true) .maxConcurrentSubagents(4L) .build()) .build
관련 소식