8000 File Retrieval · Issue #849 · openai/openai-agents-python · GitHub
[go: up one dir, main page]

Skip to content
File Retrieval #849
Closed
Closed
@conpaine109

Description

@conpaine109

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).

Image

So:

  1. Is there a better way to grab these files aside from manually going in and getting ids + making request?
  2. Do you have any suggestions for preventing the model from returning these links that point to nothing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0