# Quickstart

Fan-out workflow that fetches and summarizes the top Hacker News stories in parallel, checkpointing each step so a crash re-runs only what didn't finish.

- Category: Getting Started
- Capabilities: workflows, functions, agents
- Source code: [python](https://github.com/agnt5dev/templates/tree/main/python/quickstart), [typescript](https://github.com/agnt5dev/templates/tree/main/typescript/quickstart), [go](https://github.com/agnt5dev/templates/tree/main/go/quickstart)
- [All templates](https://agnt5.com/templates.md)

The quickstart template is a Hacker News digest: fetch the top story IDs, fan out to fetch and summarize each story in parallel, then assemble a digest. It's a small but real example of the fan-out/fan-in shape, with every step checkpointed so a crash mid-run only re-executes what didn't finish. No LLM provider is required to see the durability machinery - only the summarization step calls a model.

## What you'll build

- A `fetch_top_ids` step that pulls the current top Hacker News story IDs
- A parallel fan-out that fetches every story with `fetch_story`
- A parallel fan-out that summarizes every story with `summarize`
- An `assemble_digest` step that combines the summaries into one digest

## Requirements

- Python 3.12+ or Node.js 22+
- [`uv`](https://docs.astral.sh/uv/) (Python)
- `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` (only the `summarize` step calls a model)
- The AGNT5 CLI

## Install

```bash
curl -LsSf https://agnt5.com/cli.sh | bash
```

## Setup



### Scaffold the project



**Python**

```bash
agnt5 create --template python/quickstart my-digest
cd my-digest
```


**TypeScript**

```bash
agnt5 create --template typescript/quickstart my-digest
cd my-digest
```




### Set environment variables

```bash
cp .env.example .env
# uncomment and fill in exactly one of ANTHROPIC_API_KEY or OPENAI_API_KEY
```

In the TypeScript variant, switching providers also means updating `modelName` in `src/functions.ts`.


### Install dependencies



**uv (Python)**

```bash
uv sync
```


**pip (Python)**

```bash
pip install -e .
```


**npm (TypeScript)**

```bash
npm install
```




### Start the dev server

```bash
agnt5 dev
```


### Run the digest workflow

```bash
agnt5 run digest --input '{"limit": 5}'
```

Or open the Studio URL printed in the terminal, pick the `digest` workflow, set the input to `{"limit": 5}`, and click **Run**.


## How it works

The digest workflow runs a four-step pipeline. First, a step pulls the current top story IDs from the Hacker News API - one checkpoint. Second, the workflow fans out a fetch call for every id and awaits them together, so all the fetches run concurrently as independent checkpoints. Third, the same pattern fans out a summarize call over every fetched story. Fourth, a final step combines the summaries into the result.

Because every step is its own checkpoint, the fan-out is crash-safe: if the worker dies after 3 of 5 stories have been summarized, replay only re-runs the missing 2 - completed steps return their journaled results instead of re-executing.


> There's no model call in the fetch steps - only the summarize step calls an LLM, and it does so through the same checkpointed step mechanism, so retries and replay work the same way for model calls as for any other step.


## Key files



**Python**

```text
app.py                          - Worker entry point
src/agnt5_quickstart/workflows.py - digest workflow: fetch IDs, fan out fetch, fan out summarize, assemble
src/agnt5_quickstart/functions.py - fetch_top_ids, fetch_story, summarize, assemble_digest
```


**TypeScript**

```text
src/workflows.ts  - digest workflow: fetch IDs, fan out fetch, fan out summarize, assemble
src/functions.ts  - fetchTopIds, fetchStory, summarize, assembleDigest
```



## Customize

**Change the source.** Swap `fetch_top_ids`/`fetch_story` for another API (Reddit, RSS, an internal feed) - the fan-out/fan-in shape in `workflows.py` doesn't need to change.

**Add a second fan-out stage.** Chain another `asyncio.gather` over `ctx.task(...)` calls after `summarize`, e.g. to categorize or score each story before assembly.

**Tune concurrency.** `limit` controls how many stories are fetched. Raise or lower it to change the fan-out width per run.

## Next steps

- Read [/docs/quickstart](https://agnt5.com/docs/quickstart.md) for a line-by-line tour of this template
- Try the [weather-agent](https://agnt5.com/templates/weather-agent.md) template to add your first tool-calling agent
- Browse [/docs/build/workflows](https://agnt5.com/docs/build/workflows.md) for the execution model

> For the complete documentation index, see [llms.txt](/llms.txt).
> A full single-fetch corpus is available at [llms-full.txt](/llms-full.txt).
