몬티 (주)

Monty는 제한된 Python 하위 집합의 Rust 기반 인터프리터입니다. MontyCodeActProvider 는 Agent Framework 에이전트에 하나의 execute_code 도구를 제공하고 생성된 코드가 공급자 소유 도구를 형식화된 비동기 함수로 또는 통해 call_tool(...)호출할 수 있도록 합니다.

이 통합에서는 하드웨어 격리 샌드박스가 아닌 제한된 인터프리터에서 CodeAct 패턴을 사용합니다.

Hyperlight의 하이퍼바이저 또는 WASM 게스트 종속성이 없는 플랫폼 간 CodeAct 런타임이 필요한 경우 Monty를 사용합니다.

비고

agent-framework-monty 는 베타 패키지입니다. Monty는 운영 체제, 하위 프로세스 및 직접 네트워크 액세스를 제한하지만 하드웨어로 격리된 가상 머신은 아닙니다.

패키지 설치

pip install agent-framework-monty agent-framework-foundry --pre

MontyCodeActProvider 추가

에이전트에서 직접 호스트 도구를 등록하는 대신 공급자에 호스트 도구를 등록합니다. 모델은 생성된 코드에서 해당 도구를 보고 execute_code 호출합니다.

async def main() -> None:
    """Run the provider-owned Monty CodeAct sample."""
    # 1. Create the Monty-backed provider and register sandbox tools on it.
    codeact = MontyCodeActProvider(
        tools=[compute, fetch_data],
        approval_mode="never_require",
    )

    # 2. Create the client and the agent.
    agent = Agent(
        client=FoundryChatClient(
            project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
            model=os.environ["FOUNDRY_MODEL"],
            credential=AzureCliCredential(),
        ),
        name="MontyCodeActProviderAgent",
        instructions="You are a helpful assistant.",
        context_providers=[codeact],
        middleware=[log_function_calls],
    )

    # 3. Run a request that should use execute_code plus provider-owned tools.
    query = (
        "Fetch all users, find admins, multiply 7*(3*2), and print the users, "
        "admins, and multiplication result. Use a single execute_code call. "
        "You may call the registered tools directly as typed async functions "
        "(`await compute(operation='multiply', a=7, b=6)`) or via "
        "`call_tool('compute', ...)`."
    )
    print(f"{_CYAN}{'=' * 60}")
    print("Monty CodeAct provider sample")
    print(f"{'=' * 60}{_RESET}")
    print(f"{_CYAN}User: {query}{_RESET}")
    result = await agent.run(query)
    print(f"{_CYAN}Agent: {result.text}{_RESET}")

기능 구성

MontyCodeActProviderMontyExecuteCodeTool 지원:

  • 호스트 도구 및 런타임 도구 관리
  • never_require 또는 always_require 다음을 위한 승인 execute_code
  • 작업 영역 루트 및 명시적 파일 탑재
  • 몬티 리소스 제한
  • 읽기/쓰기 탑재에서 에이전트 프레임워크 콘텐츠로 반환된 파일

Monty는 아웃바운드 URL 허용 목록을 제공하지 않습니다. 대상 및 입력의 유효성을 검사하는 좁은 호스트 도구를 통해 네트워크 액세스를 제공합니다.

몬티 또는 하이퍼라이트 선택

Runtime 선택 시기
몬티 (주) 플랫폼 간 실행 및 제한된 인터프리터로 충분합니다.
하이퍼라이트 강화된 샌드박스, 파일 시스템 컨트롤 또는 아웃바운드 도메인 허용 목록이 필요합니다.

다음 단계