> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tako.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Answer Agent

export const CodingAgentCTA = ({description, href}) => <p className="mt-2 text-lg prose prose-gray dark:prose-invert [&>*]:[overflow-wrap:anywhere]">
    {description} Building with a coding agent?{" "}
    <a href={href}>Give your agent the full reference →</a>
  </p>;

export const PlaygroundButton = ({href = "https://tako.com/playground", label = "Try in Playground"}) => <div className="float-right not-prose ml-4 -mt-12">
    <a href={href} target="_blank" rel="noopener noreferrer" className="inline-flex items-center gap-1.5 rounded-full border border-gray-200 dark:border-white/15 bg-white dark:bg-white/5 px-3 py-1.5 text-sm font-medium text-gray-700 dark:text-gray-200 no-underline transition-colors hover:border-gray-300 hover:bg-gray-50 dark:hover:bg-white/10">
      <svg viewBox="0 0 24 24" aria-hidden="true" className="h-3.5 w-3.5 fill-current">
        <path d="M8 5v14l11-7z" />
      </svg>
      {label}
    </a>
  </div>;

<CodingAgentCTA description="A deep-research agent that synthesizes multiple sources into an opinionated, cited answer backed by insightful visualizations." href="/documentation/integrating-tako/agent/for-coding-agent" />

## Capabilities

The **Answer Agent** is a deep-research agent that **synthesizes multiple sources into an opinionated, cited answer backed by insightful visualizations**. Hand it a hard, open-ended question — one you have to *figure out* rather than look up — and it plans and researches across Tako's curated knowledge graph and the live web, then writes a synthesized answer with the cards and citations that back it.

<CardGroup cols={1}>
  <Card title="Synthesized, opinionated answer" icon="feather">
    Not a list of results — a written `answer` (markdown) that reasons across everything it found and takes a position, the way a good analyst would.
  </Card>

  <Card title="Cited and attributable" icon="quote-right">
    Every `[n]` marker in the answer joins a top-level `citations` registry covering both Tako and web sources, so each claim is traceable. `metadata` adds the definitions, assumptions, and methodology behind the answer.
  </Card>

  <Card title="Backed by visualizations" icon="chart-column">
    The answer ships with the Tako `cards` that support it — interactive knowledge cards ready to embed alongside the prose.
  </Card>

  <Card title="Asynchronous and long-running" icon="clock">
    Dispatch a run, then poll or stream it to completion (a run can take minutes) — real multi-step reasoning in the background instead of racing a single call.
  </Card>
</CardGroup>

For a specific, known value or a one-line answer over a single retrieval, use one-shot [Answer](/documentation/integrating-tako/answer/overview) instead — it returns in one fast call. For machine-usable structured data rather than prose, use the [Search Agent](/documentation/integrating-tako/agent/search).

## Example

<PlaygroundButton href="https://tako.com/console/playground/agent/answer" />

Dispatch a run, then poll `GET /v1/agent/answer/runs/{run_id}` until `status` is `completed` or `failed`:

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    # 1. Dispatch — returns 202 with an AnswerAgentRun: {"run_id": "...", "status": "queued"}.
    curl -X POST https://tako.com/api/v1/agent/answer/runs \
      -H "X-API-Key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "query": "How have American Airlines margins held up against fuel shocks?"
      }'

    # 2. Poll with the run_id until status is "completed" or "failed".
    curl https://tako.com/api/v1/agent/answer/runs/RUN_ID \
      -H "X-API-Key: YOUR_API_KEY"
    ```
  </Tab>

  <Tab title="Python">
    ```bash theme={null}
    pip install tako-sdk
    ```

    ```python theme={null}
    import os
    import time

    from tako import Configuration
    from tako.lib import Tako
    from tako.models.answer_agent_run_request import AnswerAgentRunRequest

    config = Configuration()
    config.api_key["apiKey"] = os.environ["TAKO_API_KEY"]
    client = Tako(config)

    run = client.agent.answer.run(
        AnswerAgentRunRequest(query="How have American Airlines margins held up against fuel shocks?")
    )

    # Runs can take minutes — poll on a short interval until terminal.
    while run.status not in ("completed", "failed"):
        time.sleep(3)
        run = client.agent.answer.get(run.run_id)

    if run.status == "completed":
        print(run.result.answer)
        for citation in run.result.citations or []:
            print(f"[{citation.index}]", citation.title, citation.url)
    ```
  </Tab>
</Tabs>

<Accordion title="Example API Response">
  <p>
    A completed run. `result.answer` is markdown with `[n]` citation markers; `result.citations` is the registry those markers join; `result.cards` (if any) back the answer. Prose-only answers with no cards are legitimate.
  </p>

  ```json theme={null}
  {
    "run_id": "run_8sKd2m1f0aQ",
    "object": "agent.run",
    "thread_id": "1f0e9c34-2b7a-4f0a-9c2e-7b1a2c3d4e5f",
    "status": "completed",
    "created_at": "2026-06-22T18:04:11+00:00",
    "completed_at": "2026-06-22T18:06:48+00:00",
    "result": {
      "answer": "American Airlines' operating margin has stayed thinner than its network peers through recent fuel spikes: fuel is roughly a quarter of operating cost, so the 2022 run-up compressed margins into the low single digits before recovering in 2023–24 [1][2].",
      "cards": [
        {
          "card_id": "mA-C6b48zxyU3G33JJdO",
          "title": "American Airlines Operating Margin vs. Jet Fuel Price",
          "webpage_url": "https://tako.com/card/mA-C6b48zxyU3G33JJdO/",
          "image_url": "https://tako.com/api/v1/image/mA-C6b48zxyU3G33JJdO/",
          "embed_url": "https://tako.com/embed/mA-C6b48zxyU3G33JJdO/",
          "source_indexes": ["data"]
        }
      ],
      "citations": [
        {
          "index": 1,
          "title": "American Airlines Operating Margin vs. Jet Fuel Price",
          "source_name": "Company Filings (10-K)",
          "source_index": "data"
        }
      ],
      "metadata": null,
      "request_id": "f20f965b-6bbd-40df-b50b-a8861f34df24"
    },
    "error": null
  }
  ```
</Accordion>

## Citations

The `answer` is markdown carrying inline `[n]` markers. Each marker joins `result.citations` — a single top-level registry that covers Tako **and** web sources alike. Every citation has an `index` and `title`; the Answer Agent also populates `source_index` (`data` or `web`) at launch. Markers map to citations, not one-to-one — a citation may back the answer without a surviving inline marker.

`result.metadata`, when present, carries the answer's `definitions`, `assumptions`, and `methodology` (with citations lifted out into the registry).

<Note>
  **Frozen contract.** The Answer Agent never returns structured output or inline data — the result is `answer` + `cards` + `citations` + `metadata`, and nothing else. If you need machine-usable structured data, use the [Search Agent](/documentation/integrating-tako/agent/search)'s `output_schema`. To download the data behind a card, pass its URL to [Contents](/documentation/integrating-tako/contents/overview).
</Note>

## Choosing sources

`source_indexes` controls where the agent researches. It defaults to `["data", "web"]` — both — so pass it only to **restrict**:

* `["data", "web"]` (default) — Tako's curated knowledge graph **and** the live web.
* `["data"]` — the curated knowledge graph only.
* `["web"]` — the live web only.

The legacy value `"tako"` is accepted as a synonym for `"data"`.

## Continue a thread

Each run belongs to a thread. Pass a prior run's `thread_id` to ask a follow-up in the same conversation:

```python theme={null}
follow_up = client.agent.answer.run(
    AnswerAgentRunRequest(query="How does that compare to Delta over the same period?", thread_id=run.thread_id)
)
```

Omit `thread_id` to start a fresh thread. A thread is pinned to one agent product and one set of `source_indexes`.

## Stream live progress

To show progress while the agent works, stream the run over Server-Sent Events instead of polling — send `Accept: text/event-stream` on dispatch. `client.agent.answer.stream()` yields `AnswerAgentStreamEnvelope` events; the terminal `agent_result` event carries the same `AnswerAgentResult` you'd get from polling. See the [coding-agent reference](/documentation/integrating-tako/agent/for-coding-agent#stream-live-progress-sse) for the full event taxonomy and resume semantics.

<Check>
  Stream for live progress in interactive UIs; poll for simple server-to-server flows. Both return the same `AnswerAgentResult` when the run completes.
</Check>
