> For the complete documentation index, see [llms.txt](https://docs.meganova.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.meganova.ai/libra-os/use-cases/research-report-generator.md).

# Research Report Generator

Generate a structured, evidence-backed report on any topic — complete with sections, inline citations, a risk matrix, a forward timeline, and a numbered References list — grounded in your knowledge collection and, optionally, live web research. The output is a compiled markdown document, not a chat reply.

This is the right approach when you need a deliverable you can share: a market assessment, a regulatory landscape review, a due-diligence summary, a technical briefing. Each section retrieves relevant passages from your documents before writing, so every claim traces back to a source.

***

## When to use this

Use the report generator instead of a plain chat response when:

* **The deliverable is a document, not a conversation.** You need something with headings, a narrative, and a references section — not a paragraph reply.
* **Claims must be grounded and cited.** Each section retrieves from your knowledge collection before writing; sources appear inline as `[source:chunk_id]` and again in a numbered References list at the end.
* **The topic needs structure imposed on it.** The pipeline first produces an outline, then writes each section independently with its own evidence, then synthesizes an executive summary — the structure emerges from the content, not from you prompting section by section.
* **You want a risk matrix and forward timeline alongside the analysis.** These are generated automatically as part of every report; you do not need to ask for them separately.
* **The topic needs current external information.** Web research can be enabled per-request to augment internal documents with live search results, useful for fast-moving subjects where your knowledge base may lag.

If a single-paragraph answer is enough, use a standard chat request instead. The report pipeline is optimized for long-form deliverables and runs several sequential and parallel phases; it is not a faster path to a short answer.

***

## How it works

Every report runs through a fixed pipeline:

1. **Outline** — the system reads your request and produces a structured outline (section titles, scope notes). This is the planning phase.
2. **Parallel section generation** — each section runs concurrently. For every section: retrieve relevant chunks from the bound knowledge collection → write the section prose → append callouts (key findings, caveats) → attach inline citations.
3. **Risk matrix** — a structured assessment of identified risks, produced after sections are complete so it can draw on their findings.
4. **Timeline** — a three-horizon forward view: 0–6 months, 6–12 months, 12–18 months. Grounded in the evidence gathered during section generation.
5. **Executive summary + conclusion** — synthesized last, after all sections, the risk matrix, and the timeline exist. These two pieces run on the premium answer-tier model (see [Model-tier split](#the-model-tier-split-the-cost-lever) below).
6. **Compile** — all parts are assembled into a single markdown document. The final compiled report arrives as one SSE delta just before `[DONE]`.

Progress streams throughout. You will see phase-annotated events for each step; the full document appears at the end.

***

## Trigger a report

The report pipeline is driven by the built-in **`generate_report`** tool. The key requirement: **the agent must have the report tool available** — it is not produced by an ordinary chat persona. A report request to a knowledge-bound persona that does *not* have the report tool just returns a normal (cited) chat answer, not the multi-section pipeline.

Reports are surfaced two ways:

### Option A — a report-configured agent over the chat endpoint

Use an agent that has report generation enabled (Libra OS's built-in report/BI personas, or a persona your operator has configured with the report tool), then post to the OpenAI-compatible endpoint:

```bash
curl -X POST "https://demo.meganova.app/v1/chat/completions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<report-configured-agent>",
    "stream": true,
    "messages": [
      {"role": "user",
       "content": "Generate a report on the regulatory landscape for digital lending in Southeast Asia, covering key risks and a 12-month outlook."}
    ]
  }'
```

> **Note:** `model` is the agent name. Set `stream: true` to receive progress as it's generated; a 10-second heartbeat comment keeps the connection alive during long phases. When the pipeline runs, the agent issues a `generate_report` tool call and Libra OS streams the phase progress, then the compiled markdown.

### Option B — Super Nova

The built-in **Super Nova** admin persona has the `generate_report` tool wired out of the box. Asking Super Nova for a report over an indexed collection is the most direct way to exercise the full pipeline.

> **Verify on your deployment.** Whether a *custom* persona can trigger the full pipeline depends on how the report tool is exposed on your instance (it is registered under the Super Nova toolset by default). Confirm your report agent actually emits a `generate_report` tool call — if a report request comes back as a normal prose answer with no sections/References, the agent doesn't have the tool. Ask your operator to enable it, or use Super Nova / a built-in report persona.

### Set up the knowledge collection first

The report persona reads from a bound knowledge collection. If you have not set one up yet, follow the collection and persona setup steps in [Document Q\&A Copilot](https://docs.meganova.ai/libra-os/use-cases/document-qa-copilot.md) — the steps are identical. Then add `knowledge_bindings` to your report persona:

```bash
curl -X POST "https://demo.meganova.app/v1/agents" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "anthropic-beta: managed-agents-2026-04-01" \
  -d '{
    "name": "handbook-report-agent",
    "agent_type": "persona",
    "model": "gemini/gemini-2.5-flash",
    "knowledge_bindings": ["regulatory-docs"],
    "system": "You are a research analyst. Write structured, evidence-backed reports grounded in the provided documents. Cite sources inline using [source:chunk_id]. Do not assert facts that are not present in the retrieved evidence."
  }'
```

Replace `"regulatory-docs"` with your collection name. The `model` field must carry a `<provider>/` prefix — bare model names are rejected.

***

## Add live web research

When the flag is included in the request, each section's evidence is augmented with live web search results in addition to internal document retrieval. This is useful when:

* The topic is time-sensitive and your knowledge base may not have recent developments.
* You want to cross-reference internal documents against publicly available information.
* The knowledge base covers background context but not current market data.

To enable it, include `web_research: true` in the request body:

```bash
curl -X POST "https://demo.meganova.app/v1/chat/completions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "handbook-report-agent",
    "stream": true,
    "messages": [
      {
        "role": "user",
        "content": "Generate a report on the current state of open banking regulation in the EU, including recent developments."
      }
    ],
    "web_research": true
  }'
```

> **Note:** Web research increases both cost and latency. Each section makes additional search calls, and the search results are fetched and summarized before writing. Expect a meaningfully longer generation time compared to knowledge-only reports. Web research also requires a web-search backend to be configured on the server (a Ceramic, Tavily, or compatible key in the operator environment). Contact your operator if search results are absent.

***

## The model-tier split — the cost lever

Report generation uses two model tiers to balance cost and quality:

| Phase                                    | Tier                     | Operator setting       |
| ---------------------------------------- | ------------------------ | ---------------------- |
| Outline, sections, risk matrix, timeline | Skill tier (fast, cheap) | `LIBRA_OS_SKILL_MODEL` |
| Executive summary, conclusion            | Answer tier (premium)    | `OPENAI_MODEL`         |

The majority of token spend is in section generation — there are many sections, each with retrieval and prose. Running these on the skill tier (typically a fast Flash-class model) keeps cost low. The executive summary and conclusion are where reader-facing polish matters most, so these run on the premium answer-tier model.

This split cuts report cost several-fold compared to running every phase on a premium model, with the reader-facing output quality determined by the premium model where it counts.

Operators configure the two tiers as environment variables. If you want higher-quality section prose at higher cost, operators can point `LIBRA_OS_SKILL_MODEL` at a more capable model. If you want to reduce cost further, point it at a lighter model. The answer-tier model (`OPENAI_MODEL`) controls executive-summary and conclusion quality and should remain a strong model for reader-facing output.

***

## Poll status for long runs

For most reports, streaming the response directly is sufficient — progress events arrive throughout and the final document arrives at the end. For very long reports (many sections, large knowledge bases, web research enabled), you may want to track status independently.

**Poll the status endpoint:**

```bash
curl "https://demo.meganova.app/api/reports/status/{id}" \
  -H "Authorization: Bearer $TOKEN"
```

Replace `{id}` with the job ID returned in the stream's initial event. The response returns the current phase and, when complete, a link to the compiled document.

**For very long jobs, submit as an async job:**

```bash
curl -X POST "https://demo.meganova.app/agents/v1/$API_KEY/jobs" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Generate a comprehensive report on fintech regulation across APAC, 8 sections, include risk matrix and 18-month timeline."
  }'
```

This returns a `job_id` immediately. Poll `GET /agents/v1/$API_KEY/jobs/{job_id}` for state (`queued`, `running`, `completed`, `failed`), or stream live events with `GET /agents/v1/$API_KEY/jobs/{job_id}/stream`. The stream supports `Last-Event-ID` for resuming after a disconnect.

***

## Output format

Every report follows the same compiled structure:

```
## Executive Summary
…

## [Section 1 title]
… prose with inline citations [source:chunk_id] …

## [Section 2 title]
…

## Risk Matrix
| Risk | Likelihood | Impact | Mitigation |
|------|-----------|--------|------------|
…

## Timeline
### 0–6 Months
…
### 6–12 Months
…
### 12–18 Months
…

## Conclusion
…

## References
1. [Document title] — [collection] — chunk_id
2. …
```

**Languages:** reports can be generated in English, Chinese, or bilingual (English + Chinese). Specify in your request: "Generate this report in Chinese" or "Produce a bilingual version."

**Inline citations** are `[source:chunk_id]` references inserted at the point of each claim. The numbered References section at the end lists every cited source with its document title, collection, and chunk identifier so readers can locate the original passage.

***

## Improve report quality

**Richer source documents.** Retrieval is only as good as the indexed content. A report on a regulatory topic will improve substantially if you ingest the actual regulatory texts, official guidance documents, and recent commentary — not just summaries. Use `POST /v1/managed/documents/upload` to add PDFs, DOCX files, or text directly.

**Enable web research for current topics.** If the subject moves fast (current market conditions, recently enacted regulations, this quarter's earnings), internal documents alone will produce a report that reads as dated. Set `web_research: true` to bring live evidence into each section.

**Tune the number of section workers.** By default, sections are written with 4 parallel workers. For a very large report with many sections, the operator can raise `LIBRA_OS_REPORT_WORKERS` to reduce wall-clock time. For cost-constrained environments, lowering it serializes section generation and reduces peak API concurrency.

**Choose the right answer-tier model.** The executive summary and conclusion are where a reader forms their overall impression of the report. If these feel thin or lack nuance, ask your operator to point `OPENAI_MODEL` at a more capable model (for example, a strong Opus-class model for high-stakes deliverables).

**Tighter system prompt.** If the report drifts off-topic or invents unsupported claims, tighten the system prompt on the persona: add explicit instructions like "Do not include any claim that cannot be traced to a retrieved passage" and "Sections must be grounded in the provided documents, not general knowledge."

***

## Next steps

* Set up the knowledge collection used for grounding — see [Document Q\&A Copilot](https://docs.meganova.ai/libra-os/use-cases/document-qa-copilot.md) for the full collection and ingestion walkthrough.
* Build a research assistant that answers multi-step questions over a legal or regulatory corpus — [Legal Research Assistant](https://docs.meganova.ai/libra-os/use-cases/legal-research-assistant.md).
* See all available model tiers, retrieval settings, and grounding options — [Capabilities](https://docs.meganova.ai/libra-os/capabilities.md).
