Loading...
  • 빌드
  • 관리
  • 모델 및 가격
  • 클라이언트 SDK
  • API 참조
Search...
⌘K
Log in
파일 추가
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Solutions

  • AI agents
  • Code modernization
  • Coding
  • Customer support
  • Education
  • Financial services
  • Government
  • Life sciences

Partners

  • Amazon Bedrock
  • Google Cloud's Vertex AI

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Company

  • Anthropic
  • Careers
  • Economic Futures
  • Research
  • News
  • Responsible Scaling Policy
  • Security and compliance
  • Transparency

Learn

  • Blog
  • Courses
  • Use cases
  • Connectors
  • Customer stories
  • Engineering at Anthropic
  • Events
  • Powered by Claude
  • Service partners
  • Startups program

Help and security

  • Availability
  • Status
  • Support
  • Discord

Terms and policies

  • Privacy policy
  • Responsible disclosure policy
  • Terms of service: Commercial
  • Terms of service: Consumer
  • Usage policy
빌드/에이전트에 작업 위임

파일 추가

파일을 업로드하고 컨테이너에 마운트하여 읽고 처리합니다.

Was this page helpful?

Files API를 통해 파일을 업로드하고 세션의 컨테이너에 마운트하여 에이전트에 파일을 제공할 수 있습니다.

모든 Managed Agents API 요청에는 managed-agents-2026-04-01 베타 헤더가 필요합니다. SDK는 베타 헤더를 자동으로 설정합니다.

파일 업로드

먼저 Files API를 사용하여 파일을 업로드합니다:

file = client.beta.files.upload(file=Path("data.csv"))
print(f"File ID: {file.id}")

세션에 파일 마운트

세션을 생성할 때 resources 배열에 업로드된 파일을 추가하여 컨테이너에 마운트합니다:

mount_path는 선택 사항이지만, 업로드된 파일에 설명적인 이름이 있는지 확인하여 에이전트가 찾고 있는 파일을 알 수 있도록 하세요.

세션의 파일 인스턴스를 참조하는 새로운 file_id가 생성됩니다. 이러한 복사본은 저장소 제한에 포함되지 않습니다.

여러 파일

resources 배열에 항목을 추가하여 여러 파일을 마운트합니다:

세션당 최대 100개의 파일이 지원됩니다.

실행 중인 세션에서 파일 관리

세션 리소스 API를 사용하여 생성 후 세션에서 파일을 추가하거나 제거할 수 있습니다. 각 리소스에는 추가(또는 나열)될 때 반환되는 id가 있으며, 이를 삭제할 때 사용합니다.

resources.list로 세션의 모든 리소스를 나열합니다. 파일을 제거하려면 리소스 ID와 함께 resources.delete를 호출합니다:

세션 파일 나열 및 다운로드

Files API를 사용하여 세션으로 범위가 지정된 파일을 나열하고 다운로드합니다.

지원되는 파일 유형

에이전트는 다음을 포함한 모든 파일 유형으로 작업할 수 있습니다:

  • 소스 코드 (.py, .js, .ts, .go, .rs 등)
  • 데이터 파일 (.csv, .json, .xml, .yaml)
  • 문서 (.txt, .md)
  • 아카이브 (.zip, .tar.gz) - 에이전트는 bash를 사용하여 이를 추출할 수 있습니다
  • 바이너리 파일 - 에이전트는 적절한 도구로 이를 처리할 수 있습니다

파일 경로

컨테이너에 마운트된 파일은 읽기 전용 복사본입니다. 에이전트는 이를 읽을 수 있지만 원본 업로드된 파일을 수정할 수 없습니다. 수정된 버전으로 작업하려면 에이전트는 컨테이너 내의 새 경로에 씁니다.

  • 파일은 지정한 정확한 경로에 마운트됩니다
  • 상위 디렉토리는 자동으로 생성됩니다
  • 경로는 절대 경로여야 합니다 (/로 시작)
session = client.beta.sessions.create(
    agent=agent.id,
    environment_id=environment.id,
    resources=[
        {
            "type": "file",
            "file_id": file.id,
            "mount_path": "/workspace/data.csv",
        },
    ],
)
resources = [
    {"type": "file", "file_id": "file_abc123", "mount_path": "/workspace/data.csv"},
    {"type": "file", "file_id": "file_def456", "mount_path": "/workspace/config.json"},
    {"type": "file", "file_id": "file_ghi789", "mount_path": "/workspace/src/main.py"},
]
resource = client.beta.sessions.resources.add(
    session.id,
    type="file",
    file_id=file.id,
)
print(resource.id)  # "sesrsc_01ABC..."
listed = client.beta.sessions.resources.list(session.id)
for entry in listed.data:
    print(entry.id, entry.type)

client.beta.sessions.resources.delete(resource.id, session_id=session.id)
# List files associated with a session
files = client.beta.files.list(
    scope_id="sesn_abc123",
    betas=["managed-agents-2026-04-01"],
)
for f in files:
    print(f.id, f.filename)

# Download a file
content = client.beta.files.download(files.data[0].id)
content.write_to_file("output.txt")