# Playground

> The playground is where you chat with your agent before and after deploying it — inspect the exact prompt sent to the model, expand the sources behind every answer, rate replies, and turn corrections into Q&A pairs.

The **playground** is your test harness. It runs your agent exactly as a real customer would experience it — same retrieval, same prompt, same model — but with the tools you need to see *why* the agent answered the way it did and to fix it on the spot.

Use the playground continuously: while you build, after every data change, and as a debugging tool when a customer reports a bad answer. Open it from your agent's **Playground** tab.

> **TEST WITH REAL QUESTIONS:** Paste in the actual questions your customers ask — pulled from your inbox or [chat logs](/docs/agents/activity) — not idealized ones. The gaps show up fastest on real phrasing.

## Chatting with your agent

Type a question and the agent replies the same way it would on your website widget. Start with the questions that matter most:

- "How long do I have to return something?"
- "Where is my order?"
- "Do you ship to Canada?"
- "What's your warranty on this?"

Every answer is grounded in your data and carries citations. The playground reflects the live agent, so a source you just trained or a Q&A pair you just added is testable immediately.

*[image: The Bookbag playground: a chat panel on the left with an agent reply, and an expandable Sources section showing the document chunks cited for that answer.]*

## Inspecting sources

Expand the **sources** under any answer to see the exact chunks the agent retrieved and the document each came from. This is the fastest way to debug:

- If the cited chunk is **right** but the answer is wrong, the issue is the prompt or model — tune them in [Agent settings](/docs/agents/settings).
- If the cited chunk is **wrong or missing**, the issue is the data — add or fix a source.
- If a **Q&A pair** was matched, you'll see it cited as the source, confirming the pin worked.

## Inspect prompt

The **Inspect prompt** tool shows the exact, fully-assembled prompt that the chat runtime would send to the model for a given question — including your system prompt, the retrieved chunks, and the conversation — without actually calling the model or spending credits.

It's the ground truth for "what does the model actually see?" Use it when an answer is surprising: you can confirm whether the right chunks made it into context and whether your system prompt is doing what you think.

> **INFO:** Inspect prompt is read-only and free — it assembles the prompt but never invokes the model, so you can run it as often as you like while tuning.

## Rating and improving answers

Rate any answer thumbs-up or thumbs-down. Ratings feed [Analytics](/docs/agents/analytics) and the **Suggestions** list on your Data sources tab, so a thumbs-down becomes a flagged gap you can act on.

### Improve answer

When an answer is close but not quite right, use **Improve answer** to edit the reply and save it as a high-priority Q&A pair. The corrected version is ingested immediately and retrieved first the next time a similar question comes in — turning a one-off fix into a permanent improvement.

1. **Spot a weak answer** — Ask a question and notice the reply is vague, incomplete, or off.
2. **Edit the response** — Use Improve answer to write exactly what the agent should have said.
3. **Save as Q&A** — Bookbag stores it as a high-priority Q&A source and retrains it on the spot.
4. **Re-ask to confirm** — Ask the same question again — the agent now returns your approved answer.

## A tuning loop that works

1. **Ask** — Pose a real customer question.
2. **Inspect** — Expand sources and, if needed, Inspect prompt to see what the model received.
3. **Fix the cause** — Wrong chunk → fix the data. Right chunk, wrong answer → adjust the prompt or model. Close but off → Improve answer into a Q&A pair.
4. **Re-test** — Ask again and confirm the fix. Repeat across your top questions.

> **CHECK:** When your top 20 real questions answer correctly in the playground, you're ready to deploy with confidence.

## What's next

- [Agent settings](/docs/agents/settings) — Tune the system prompt, temperature, fallbacks, and appearance.
- [Data sources](/docs/agents/data-sources) — Fix the data behind a wrong answer.
- [Activity & chat logs](/docs/agents/activity) — Review real conversations to find what to test next.
- [Deploy & channels](/docs/deploy/overview) — Put your tested agent in front of customers.
