Closed
Description
Please read this first
- Have you read the docs?Agents SDK docs: YES
- Have you searched for related issues? Others may have had similar requests: YES
Question
Our agent generates file in sandbox environment and this is how we currently retrieve:
async def _get_files(self, result: RunResultStreaming) -> Optional[List[str]]:
attachments: List[str] = []
try:
for item in result.new_items:
if isinstance(item.raw_item, ResponseOutputMessage):
for content in item.raw_item.content:
for annotation in content.annotations:
if annotation.container_id and annotation.file_id:
cntr_id = annotation.container_id
file_id = annotation.file_id
file_path = await to_file(
cntr_id,
file_id,
self.context.instance,
self.storage_manager,
)
if file_path:
attachments.append(file_path)
except Exception as e:
print(f"Error processing attachments: {e}")
This works, as we are able to get container and file ids from the MessageOutputItem
. However as you can see below the model is spitting out a junk link (top) and we return the actual converted file that's is ready for download (bottom).
So:
- Is there a better way to grab these files aside from manually going in and getting ids + making request?
- Do you have any suggestions for preventing the model from returning these links that point to nothing?