File Storage

https://x.com/LumiTeh / https://www.lumiteh.com/ / https://github.com/LumiTeh-hub

Overview

File Storage allows you to upload files to a session and download files that agents retrieve during their tasks. Uploaded files become available to agents in that session. When agents download files from websites, you can access them later.

File Storage is session-scoped—agents within the same session share the same storage bucket. Files persist beyond the session lifecycle, so downloads can be retrieved afterwards.

​How It Works

  1. Upload files → Files are stored in the session’s S3 bucket

  2. Run agents → Agents can use uploaded files and download new ones

  3. Download results → Retrieve files that agents downloaded

Agents can only see filenames of uploaded files, not their content. Use descriptive names like resume_john_doe.pdf to make sure they get the right context!

​Basic Usage

from lumiteh_sdk import LumiTehClient

client = LumiTehClient()
storage = client.FileStorage()

# Upload files before agent execution
upload_response = storage.upload("/path/to/document.pdf")
print(f"Upload success: {upload_response.success}")

# Create session with storage attached
with client.Session(storage=storage) as session:
    agent = client.Agent(session=session, max_steps=5)

    # Agent can now use uploaded files in web interactions
    response = agent.run(
        task="""
            Upload the PDF document to the website
            and download the cat picture from site
        """,
        url="https://lumiteh.io/pg/file/io"
    )

    print(f"Agent task completed: {response.success}")

# List and download files that the agent downloaded from websites
downloaded_files = storage.list_downloaded_files()
for file_name in downloaded_files:
    success = storage.download(
        file_name=file_name,
        local_dir="./results"  # Save to "results" folder
    )
    print(f"Downloaded {file_name}: {success}")

​Upload Files

Upload files before running your agents

from lumiteh_sdk import LumiTehClient

client = LumiTehClient()
storage = client.FileStorage()

# Upload a file
success = storage.upload("/path/to/document.pdf")
print(f"Upload successful: {success}")

# List all uploaded files
uploaded_files = storage.list_uploaded_files()
print(f"Available files for agents: {uploaded_files}")

Best Practices:

  • Use descriptive filenames (agents only see the filename)

  • Large files are supported (AWS S3 limits apply)

​Download Files

After agents complete their work, download files they retrieved

from lumiteh_sdk import LumiTehClient

client = LumiTehClient()
storage = client.FileStorage()

# Assuming you have a session with storage that has completed
with client.Session(storage=storage) as session:
    # ... agent execution happens here ...
    pass

# After agent execution, download created files
downloaded_files = storage.list_downloaded_files()
print(f"Files downloaded by agent: {downloaded_files}")

# Download files to a directory on your computer
download_dir = "./downloads"  # This creates a "downloads" folder in your current directory
for file_name in downloaded_files:
    try:
        success = storage.download(
            file_name=file_name,
            local_dir=download_dir,
            force=False  # Don't overwrite existing files
        )
        if success:
            print(f"Downloaded {file_name} to {download_dir}")
    except ValueError as e:
        print(f"Download failed for {file_name}: {e}")

​File Persistence

  • Session Duration: Files are available throughout the session and persist after it ends

  • Agent Sharin: Multiple agents in the same session share the same storage

  • Persistence: Files remain available for download even after the session closes

Last updated