# Demo 01 — Zero to Movie Recommendation Agent in 5 Minutes

**Platform aspects**: Agent creation, `ai init`, `ai serve`, `ai run`, `ai web`
**Graph**: Neo4j Recommendations demo database (`recommendations` / `recommendations` / `recommendations`)
**Audience**: New users; developer onboarding; conference opening slot

---

## The Scenario

You've just heard about agent-intelligence.ai. You want to go from zero to a running AI
agent that answers natural-language questions about movies — in under five minutes, on your
laptop, with no cloud account required. The agent will use the Neo4j Movies demo database
and a local Cypherlite graph for caching.

---

## Prerequisites

```bash
# Install the ai CLI (one-line curl install)
curl -fsSL https://agent-intelligence.ai/install.sh | sh

# Verify
ai --version
# ai version 0.4.1 (commit a3f2c1d, built 2026-03-09)
```

You need an Anthropic API key:
```bash
export ANTHROPIC_API_KEY=sk-ant-...
```

---

## Step 1 — Create your agent with `ai init`

```bash
ai init my-movie-agent
cd my-movie-agent
```

The onboarding agent starts an interview:

```
╔══════════════════════════════════════╗
║  agent-intelligence.ai  v0.4.1      ║
║  Agent Onboarding                   ║
╚══════════════════════════════════════╝

Hi! I'll help you configure your agent in a few questions.

What should your agent be called? › movie-assistant
What does it do? › Answer questions about movies, directors, and actors

Do you have a Neo4j database to connect to? (y/n) › y
Connection URI › neo4j+s://demo.neo4jlabs.com:7687
Username › recommendations
Password › recommendations
Database (leave blank for default) › recommendations

✓ Connected to Neo4j
✓ Introspecting schema...
  Node labels: Movie, User, Genre, Actor, Director
  Relationship types: RATED, IN_GENRE, ACTED_IN, DIRECTED
  Key properties: title, year, plot, imdbRating, tmdbId, name, userId

Generating agent.toml and toolbox.yaml...

✓ Created agent.toml
✓ Created toolbox.yaml
✓ Created .env.example

All done! Run `ai serve` to start your agent.
```

Look at what was generated:

```bash
ai show
```

```toml
[agent]
name        = "movie-assistant"
description = "Answer questions about movies, directors, and actors"
system_prompt = """
You are a helpful movie expert with access to a comprehensive graph database
of movies, actors, directors, and genres. You can answer questions about:
- Movie details (release year, tagline, cast, director)
- Actor filmographies and collaborations
- Genre exploration and recommendations
- "Six degrees of separation" style relationship paths

Always cite specific movie titles, years, and actor names in your answers.
"""

[agent.model]
provider = "anthropic"
model    = "claude-sonnet-4-6"
api_key  = "${ANTHROPIC_API_KEY}"

[agent.budget]
max_turns           = 10
context_warn_ratio  = 0.70
context_compact_ratio = 0.80
context_abort_ratio = 0.95

[agent.toolbox]
endpoint  = "http://localhost:15000/mcp/sse"
transport = "sse"
```

The generated `toolbox.yaml` has Cypher tools pre-built from the schema:

```yaml
sources:
  recs-db:
    kind: neo4j
    uri: neo4j+s://demo.neo4jlabs.com:7687
    user: recommendations
    password: recommendations
    database: recommendations

tools:
  find_movies_by_title:
    kind: neo4j-query
    source: recs-db
    description: Search for movies by title (partial match), returns rating and year
    parameters:
      - name: title
        type: string
        description: Movie title or partial title to search for
    query: |
      MATCH (m:Movie)
      WHERE toLower(m.title) CONTAINS toLower($title)
      RETURN m.title AS title, m.year AS year, m.plot AS plot,
             m.imdbRating AS imdb_rating
      ORDER BY m.imdbRating DESC LIMIT 10

  find_movies_by_genre:
    kind: neo4j-query
    source: recs-db
    description: List top-rated movies in a specific genre
    parameters:
      - name: genre
        type: string
        description: Genre name (e.g. Action, Comedy, Drama, Thriller)
    query: |
      MATCH (m:Movie)-[:IN_GENRE]->(g:Genre {name: $genre})
      RETURN m.title AS title, m.year AS year, m.imdbRating AS imdb_rating
      ORDER BY m.imdbRating DESC LIMIT 12

  find_similar_movies:
    kind: neo4j-query
    source: recs-db
    description: Find movies similar to a given title based on shared actors and genres
    parameters:
      - name: title
        type: string
    query: |
      MATCH (m:Movie {title: $title})<-[:ACTED_IN]-(a:Actor)-[:ACTED_IN]->(rec:Movie)
      WHERE rec <> m
      WITH rec, count(a) AS overlap, collect(a.name) AS shared_actors
      MATCH (rec)-[:IN_GENRE]->(g:Genre)<-[:IN_GENRE]-(m)
      WITH rec, overlap, shared_actors, count(g) AS genre_overlap
      RETURN rec.title AS recommended, rec.year AS year,
             rec.imdbRating AS imdb_rating,
             overlap AS shared_actors_count,
             genre_overlap AS shared_genres
      ORDER BY (overlap * 2 + genre_overlap) DESC LIMIT 8

  get_user_recommendations:
    kind: neo4j-query
    source: recs-db
    description: Get personalized recommendations for a user based on their ratings
    parameters:
      - name: user_id
        type: string
        description: User ID string (e.g. "564")
    query: |
      MATCH (u:User {userId: $user_id})-[r:RATED]->(m:Movie)
      WHERE r.rating >= 4.0
      WITH u, collect(m) AS liked
      MATCH (m2:Movie)<-[:ACTED_IN]-(a:Actor)-[:ACTED_IN]->(liked_m:Movie)
      WHERE liked_m IN liked AND NOT (u)-[:RATED]->(m2)
      WITH m2, count(a) AS score
      RETURN m2.title AS recommended, m2.year AS year,
             m2.imdbRating AS imdb_rating, score AS relevance_score
      ORDER BY score DESC LIMIT 10
```

---

## Step 2 — Start the agent

```bash
ai serve
```

```
Starting agent-intelligence.ai...

[mcp-toolbox]  Starting subprocess on :15000...
[mcp-toolbox]  ✓ Health check passed (238ms)
[mcp-toolbox]  ✓ Loaded 4 tools from movies-db

[a2a-server]   Listening on :8080
[mcp-server]   Listening on :8081

agent-card:    http://localhost:8080/.well-known/agent.json
a2a endpoint:  http://localhost:8080/a2a
mcp endpoint:  http://localhost:8081/mcp  (Streamable HTTP)
mcp endpoint:  http://localhost:8081/sse  (legacy SSE)

Ready. Press Ctrl+C to stop.
```

---

## Step 3 — Run your first query

In a second terminal:

```bash
ai run "Who directed The Matrix, and what other movies did they direct?"
```

```
Thinking...
  → find_directors_by_movie(title="The Matrix")
  ← director: "Lana Wachowski", movie: "The Matrix", released: 1999

  → find_movies_by_actor(name="Lana Wachowski")
  ← [Cloud Atlas (2012), Jupiter Ascending (2015), The Matrix Revolutions (2003), ...]

The Matrix was directed by **Lana Wachowski** (then credited as Larry Wachowski).
After The Matrix, the Wachowski siblings went on to direct:

- **The Matrix Reloaded** (2003) — the first sequel, expanding Neo's conflict with the machines
- **The Matrix Revolutions** (2003) — the trilogy conclusion
- **Speed Racer** (2008) — a visually bold adaptation of the anime series
- **Cloud Atlas** (2012) — co-directed with Tom Tykwer; an intricate multi-timeline epic
- **Jupiter Ascending** (2015) — original sci-fi space opera

All Matrix films are in the graph. Cloud Atlas and Jupiter Ascending are also present.
```

Try a more complex query:

```bash
ai run "Find me six degrees of separation between Tom Hanks and Keanu Reeves"
```

```
Thinking...
  → find_movies_by_actor(name="Tom Hanks")
  ← [Cast Away, Forrest Gump, The Green Mile, Apollo 13, You've Got Mail, ...]

  → find_movies_by_actor(name="Keanu Reeves")
  ← [The Matrix, Speed, Johnny Mnemonic, Much Ado About Nothing, ...]

  → recommend_similar_movies(title="The Green Mile")
  ← shared actors/directors lead to other films...

Here's a connection between **Tom Hanks** and **Keanu Reeves**:

Tom Hanks → (appeared in) **The Da Vinci Code** → (also starred) **Audrey Tautou**
Audrey Tautou → (appeared in) **Amélie** → (featured) ...

Actually, a shorter path: both are in the Movies graph but have no direct co-starring
credit in this dataset (the Neo4j demo graph has ~3,600 nodes). Within the available
data, the closest connection is through directors who worked with both actors' peers.

Want me to look for a specific pathway, or explore what films they share genre-overlap with?
```

---

## Step 4 — Open the web console

```bash
ai web
```

```
Starting web console...
Connecting to agent at http://localhost:8080...
✓ Agent online (movie-assistant v0.4.1)

Web console: http://localhost:8888
Opening browser...
```

The browser opens to a chat interface where you can:
- Type natural language queries
- See tool calls and results in the debug panel (`--debug` flag)
- Save interesting conversations as eval cases

```bash
# With debug panel enabled:
ai web --debug
```

In the debug panel you'll see each tool call expand inline:
```
▶ find_movies_by_actor  {"name": "Tom Hanks"}     32ms
▶ find_movies_by_actor  {"name": "Keanu Reeves"}  28ms
  tokens: 847 in / 312 out  ($0.0009)
```

---

## What you just built

In five minutes and one command, you created an agent that:

- **Speaks natural language** — no Cypher knowledge required from the user
- **Uses a real graph database** — 3,682 nodes, 9,629 relationships
- **Explains its reasoning** — tool calls are visible via `ai web --debug` or `ai run --verbose`
- **Serves over two protocols** — A2A on `:8080`, MCP on `:8081`
- **Has a web UI** — shareable chat interface at `:8888`

Next: [Demo 02 — Company Intelligence with GraphRAG](demo-02-company-intelligence.md)

---

## Appendix — Demo fixture files

**`toolbox.yaml`** (full generated config): [`fixtures/demo-01/toolbox.yaml`](fixtures/demo-01/toolbox.yaml)
**`agent.toml`** (full config): [`fixtures/demo-01/agent.toml`](fixtures/demo-01/agent.toml)

```bash
# Quick-start with fixture files (skip ai init):
curl -fsSL https://agent-intelligence.ai/downloads/demo-01-fixtures.tar.gz | tar xz
ai serve
```
