> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.athenaintel.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.athenaintel.com/_mcp/server.

# Handle Large Task Results

> Persist oversized task outputs as reusable assets instead of returning them inline

When a Task Studio task returns a very large payload (for example, a big list
of contacts or rows pulled from an external API), the result can exceed the
maximum size a task run is allowed to return inline. When that happens the run
still **completes successfully**, but the oversized payload can't be returned
or previewed directly, and you'll see a message like:

> This task returned too much data to display or pass along directly.

This guide shows the two ways to work around that limit by persisting the full
output as a reusable asset.

## Option 1: Save the result as an asset (no code changes)

The quickest fix requires no changes to the task itself — just ask the agent to
**re-run the task and save its result as an asset**. For example:

> Re-run that task and save the result as an asset.

The agent re-runs the task, stores the complete output as a `tool_result`
asset, and returns an `asset_id` instead of the raw payload. That `asset_id`
can then be handed to other tools — for instance, to bulk-load the rows into a
database — without the data ever being re-typed or truncated.

> **Note**
>
> Saving only works on a fresh run. Once a run has already reported that its
> result was too large, the full payload is no longer available to save — the
> task has to be run again with saving enabled.

## Option 2: Update the task to write an asset itself

For a task that reliably produces large outputs, the durable fix is to have the
task **create an asset and return a reference to it** rather than returning the
raw data. You can ask the agent to update the script for you, or edit it
directly.

Instead of returning a large array:

```python
def main(company: str) -> dict:
    contacts = fetch_all_contacts(company)  # potentially thousands of rows
    # ❌ Returning the full array inline can exceed the result-size limit
    return {"contacts": contacts}
```

...create an asset from the SDK and return its id plus a small summary:

```python
from athena import Athena


def main(company: str, api_key: str) -> dict:
    client = Athena(api_key=api_key)
    contacts = fetch_all_contacts(company)

    # ✅ Persist the full dataset as a spreadsheet asset the agent can reuse
    asset = client.assets.create(
        asset_type="spreadsheet",
        title=f"{company} contacts",
    )
    populate_spreadsheet(client, asset.asset_id, contacts)

    # Return a small, inline-safe reference instead of the full payload
    return {
        "asset_id": asset.asset_id,
        "row_count": len(contacts),
        "text": f"Saved {len(contacts)} contacts for {company} to an asset.",
    }
```

The task now returns a compact response that always fits inline, while the full
dataset lives in an asset that downstream tools and the agent can open and reuse
later.

See [Create Assets](/python-guides/create-assets) for the full asset-creation
API and [Build with Agents](/python-guides/build-with-agents) for how tasks and
agents work together.