Skip to main content

Overview

AgentInput is the input object your agent receives when using the Structured signature ((input_data: AgentInput) -> AgentResponse). It provides the conversation history, session context, and helper methods for accessing user messages. When a test case has structured JSON input (e.g. {"user_message": "hello", "chat_type": "support"}), the SDK splits it: user_message becomes the message content, and the remaining fields (like chat_type) are placed in the first user message’s metadata.

Fields

list[ConversationMessage]
required
The full conversation history up to this turn. Each ConversationMessage has:
  • role (str): "user" or "assistant"
  • content (str): The message text
  • retrieval_context (Optional[str]): Retrieved context (for RAG agents)
  • metadata (Optional[dict[str, Any]]): Additional fields. When the test case uses structured JSON input, non-message fields (e.g. chat_type, priority) appear here on the first user message.
  • input_files (list[InputFile]): The files attached to a user message, ready for galtea.storage.download(). Empty for a message that carries only text.
str
required
The current session identifier. Use this to maintain state in stateful agents.
Optional[dict[str, Any]]
Structured context data from the test case. This comes from the test case’s context / context_data field, not from the input. Use it to pass supplemental information like customer tier, environment, or domain context.
Optional[dict[str, Any]]
Additional metadata for the current execution.
list[InputFile]
The files attached to the last user message, as InputFile objects, empty when it carries none. Derived from messages rather than stored, so an input_files keyword passed to the constructor is ignored; attach files through ConversationMessage(input_files=...). For an earlier turn’s files, read that message’s own input_files. See Reading attached files.
Optional[str]
The trace ID for this execution. Forward this to remote agents so they can attach spans to the correct session via set_context(trace_id=...). See Remote Agent Tracing.

Helper Methods

Optional[str]
Returns the content of the last user message, or None if no user message exists. This is the simplest way to get the user’s message text.
Optional[ConversationMessage]
Returns the full ConversationMessage object for the last user message (with role, content, retrieval_context, metadata, and input_files), or None if not found. Use this when you need access to the message’s metadata.

Basic Usage

Accessing Structured Input Fields

When your test case input is a JSON object (e.g. uploaded via CSV with {"user_message": "hello", "chat_type": "support"} in the input column), the SDK places user_message as the message content and remaining fields in messages[0].metadata:

Accessing Context Data

context_data is separate from the input. It comes from the test case’s context field and is useful for passing supplemental information that is not part of the user message:

Reading attached files

A test case can attach files to its input. When your agent runs through evaluations.run(), simulator.simulate() or traces.generate(), those files reach it as input_data.input_files: one InputFile per attached file, with the same uri, filename and mime_type as test_case.input_files. Pass each one to galtea.storage.download() to get the bytes:
When the document goes straight into a request of your own, read() returns the bytes and never touches the disk:
input_data.input_files is a shortcut for the current turn. Each ConversationMessage keeps its own files, so an earlier turn’s document stays reachable through messages:
A history with files on more than one turn only comes from turns you create yourself with traces.generate(), passing input={"user_message": "...", "content": [...]}. The conversation simulator supports attached files on single-turn runs only, so evaluations.run() and simulator.simulate() put every file on the opening turn.
The metadata split is unchanged: messages[0].metadata["content"] still holds the raw content parts, files included, exactly as the platform stores them.
Only the Structured signature receives files. A (str) -> str or (list[dict]) -> str agent receives the text alone: the SDK logs one warning per agent when a test case also attaches files, and fails the trace with a galtea.FileOnlyTextAgentException (a ValueError subclass) when the test case attaches files and no text, since that agent would receive nothing. Annotate the first parameter as galtea.AgentInput to receive both.

Structured Input on TestCase and Trace

Outside of AgentInput, the TestCase and Trace models provide three fields for accessing input:
  • .input (str): The user_message value as a plain string
  • .input_data (dict): The full structured input object with all fields
  • .input_files (list[InputFile]): The files attached to the input, empty for text
Trace also provides a symmetric pair for the agent output:
  • .actual_output (str | None): The scored output as a plain string. For voice turns this is the assistant_message transcript unwrapped from the content-parts envelope.
  • .actual_output_data (dict | None): The full output envelope when present (e.g. {"assistant_message": "...", "content": [{"type": "audio", "uri": "...", "transcript": "..."}]}), otherwise None for plain-text output.
When submitting an actualOutput content-parts envelope, each audio part must include either a non-empty transcript or a non-empty uri. If you provide only a uri, the API transcribes the stored audio automatically and fills in the transcript. A client-supplied transcript or assistant_message always takes precedence over the API’s speech-to-text result. The strict transcript requirement applies only to the user turn (input) — the agent output side accepts audio-only parts.

How Structured Input Flows Through the System

  1. Test case CSV: You provide JSON in the input column: {"user_message": "hello", "chat_type": "support"}
  2. TestCase model: .input = "hello", .input_data = {"user_message": "hello", "chat_type": "support"}
  3. Endpoint templates: Use {{ input.user_message }} or {{ input.chat_type }} to access individual fields. Bare {{ input }} is rejected, because it renders the whole object. The download URL of a file is never part of input, so read a file with input_files
  4. AgentInput (SDK): messages[0].content = "hello", messages[0].metadata = {"chat_type": "support"}
  5. Trace: .input = "hello", .input_data = {"user_message": "hello", "chat_type": "support"}

Simulating Conversations

Multi-turn conversation simulation tutorial.

Generate Trace

Single-turn agent execution with automatic span collection.

Templates & Mapping

Endpoint template syntax including {{ input.field_name }}.

Tracing Agent Operations

Capture internal operations and forward trace_id to remote agents.