콘텐츠로 이동

Editor

ApplyPatchOperation dataclass

Represents a single apply_patch editor operation requested by the model.

Source code in src/agents/editor.py
@dataclass(**_DATACLASS_KWARGS)
class ApplyPatchOperation:
    """Represents a single apply_patch editor operation requested by the model."""

    type: ApplyPatchOperationType
    path: str
    diff: str | None = None
    ctx_wrapper: RunContextWrapper | None = None

ApplyPatchResult dataclass

Optional metadata returned by editor operations.

Source code in src/agents/editor.py
@dataclass(**_DATACLASS_KWARGS)
class ApplyPatchResult:
    """Optional metadata returned by editor operations."""

    status: Literal["completed", "failed"] | None = None
    output: str | None = None

ApplyPatchEditor

Bases: Protocol

Host-defined editor that applies diffs on disk.

Source code in src/agents/editor.py
@runtime_checkable
class ApplyPatchEditor(Protocol):
    """Host-defined editor that applies diffs on disk."""

    def create_file(
        self, operation: ApplyPatchOperation
    ) -> MaybeAwaitable[ApplyPatchResult | str | None]: ...

    def update_file(
        self, operation: ApplyPatchOperation
    ) -> MaybeAwaitable[ApplyPatchResult | str | None]: ...

    def delete_file(
        self, operation: ApplyPatchOperation
    ) -> MaybeAwaitable[ApplyPatchResult | str | None]: ...