This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-05 07:14:46 -05:00
1 parent 8de0fcee14
commit a7bce2db5b
20 files changed
+239 -222

No files matched your search

+3 -7
View File
@@ -8,7 +8,7 @@ from dataclasses import dataclass
from pathlib import Path
from typing import Any
from cptr.utils.identity import identity_for_user_id
from fastapi import Request
from cptr.utils.runtime import Runtime
from cptr.utils.storage import get_storage
@@ -40,6 +40,7 @@ def _is_image(file_meta: dict[str, Any]) -> bool:
async def prepare_agent_attachments(
request: Request,
*,
workspace: str,
user_id: str | None,
@@ -61,7 +62,6 @@ async def prepare_agent_attachments(
images: list[AgentAttachment] = []
staged_files: list[AgentAttachment] = []
storage = get_storage()
identity = await identity_for_user_id(user_id) if user_id else None
for file_meta in files:
if not isinstance(file_meta, dict):
continue
@@ -76,11 +76,7 @@ async def prepare_agent_attachments(
name = _safe_segment(str(file_meta.get("name") or file_id))
path = root / f"{_safe_segment(file_id)}-{name}"
if identity:
await Runtime.write_file(identity, str(path), data)
else:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(data)
await Runtime.write_file(request, str(path), data)
mime_type = str(
file_meta.get("content_type")
or file_meta.get("mime_type")