Skip to main content
What this builds. A two-turn session where turn 1 hands the agent a .txt file and turn 2 asks for a summary. You’ll end up with. A streamed acknowledgement of the file, followed by a streamed answer that cites figures from inside it. Creates a temp text file, sends it via send(), then asks about its contents.
import asyncio
import tempfile
from pathlib import Path

from vectorshift.agent import Agent, AgentType, LlmInfo, MemoryConfig
from vectorshift.events import SessionEventType


async def main() -> None:
    tmp = Path(tempfile.mktemp(suffix=".txt"))
    tmp.write_text(
        "Q3 2025 Financial Summary\n"
        "=========================\n"
        "Revenue: $4.2M (up 18% YoY)\n"
        "Operating Expenses: $2.8M\n"
        "Net Profit: $1.4M\n"
        "Headcount: 47 employees\n"
        "New customers: 12\n"
        "Churn rate: 3.1%\n"
    )
    print(f"Created temp file: {tmp}\n")

    agent = Agent.new(
        name="Send file demo",
        type=AgentType.CONVERSATIONAL,
        llm_info=LlmInfo(provider="openai", model_id="gpt-4o"),
        tools=[],
        instructions="You are a helpful assistant that can process text and files.",
        memory_config=MemoryConfig(enable_session_memory=True),
    )
    print(f"Created agent: {agent.name}\n")

    async with await agent.create_session() as session:
        print(f"Session connected: {session.session_id}\n")

        # Send the file as a Path
        print("--- Sending file via send(Path) ---")
        await session.send(tmp)

        async for event in session.listen(
            event_types=[
                SessionEventType.MESSAGE_DELTA,
                SessionEventType.MESSAGE_COMPLETE,
            ]
        ):
            if event.delta:
                print(event.delta, end="", flush=True)
            if event.is_complete:
                break
        print("\n")

        # Now ask about the file
        print("--- Asking about the file ---")
        await session.send(
            "What was the revenue and churn rate in that file? Summarize it."
        )

        async for event in session.listen(
            event_types=[
                SessionEventType.MESSAGE_DELTA,
                SessionEventType.MESSAGE_COMPLETE,
            ]
        ):
            if event.delta:
                print(event.delta, end="", flush=True)
            if event.is_complete:
                break
        print()

    tmp.unlink(missing_ok=True)
    agent.delete()
    print("\nDone.")


if __name__ == "__main__":
    asyncio.run(main())

Expected output

Created temp file: /tmp/...txt

Created agent: Send file demo

Session connected: ...

--- Sending file via send(Path) ---
I've received the Q3 2025 financial summary...

--- Asking about the file ---
Revenue was $4.2M (up 18% YoY) and the churn rate was 3.1%...

Done.
session.send(Path) uploads the file as part of the next turn — the agent answers based on its contents on the follow-up question because session memory keeps it in context.
See Session overview for what file payloads look like over the wire.

See also

Multimodal send_many

Send file bytes plus a question in a single batched turn.

Multi-turn session

The memory mechanic that makes the follow-up question work.

Session reference

send() overloads and supported content types.