# list_learnings

URL: https://codepanel.ai/docs/mcp-server/list_learnings

The CodePanel MCP tool that lists a repository's learnings with their state: active, candidate, off or expired, and what confirms a candidate.

`list_learnings` lists a repository's learnings, the short facts the orchestrator checks against the code when a pull request touches their scope, each with a `state` that says whether it applies yet. Call it to see which are `active`, which wait for confirmation and which someone turned off. It needs `repo` and the `read` scope.

## When to call it

- **Before `add_learning`.** Check the fact isn't there already, in any state.
- **To find a learning to rate.** A review names the learnings it applied (`L3`). `list_learnings` shows the ones it didn't: candidates waiting for an up, and ones turned off.
- **When a finding was dropped and you want to know why.** `hits` names the findings a learning decided.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | Repository as owner/name |

It only reads: the server marks it `readOnlyHint: true`, so clients that ask before a write can run it without asking.

## What it returns

An array, highest ref first. A repository holds at most 200 learnings.

| Field | Meaning |
| --- | --- |
| `ref`, `number` | `L3` and `3`. Numbers are never reused |
| `text`, `scope` | The fact, and the path prefix it holds under. `scope` is empty for the whole repository |
| `source` | Where it came from: `comment` (`/remember`), `api` (a token: the CLI, MCP or HTTP), `dashboard`, or `drafted` |
| `prNumber` | The pull request it came from, when one was given. A learning never applies to that pull request |
| `state` | See below |
| `drafted` | On a drafted learning: `at`, `model` and `evidence`, each with `label`, `prNumber`, `ref`, `file`, `note` and `by` |
| `hits` | `count`, `lastAt` and `lastPrNumber`: how many findings the learning dropped or demoted. Present only when the repository has the `REVIEW_LEARNING_ATTRIBUTION` switch on and the learning has decided a review |

### The four states

| `state.status` | Meaning |
| --- | --- |
| `active` | Applied to pull requests opened after `activatedAt`. `by` says who activated it: `person`, `agents` (two independent ups) or `evidence` (drafted) |
| `candidate` | Not applied. `needs` says what would confirm it |
| `off` | Someone rated it down. `by` is `person` or `agent`, with the `reason` and `prNumber` when given |
| `expired` | Active once, with no confirmation for 180 days. `lastConfirmedAt` is the last one. A new up confirms it again |

Any trusted `down` turns a learning off at once; lowering scrutiny takes agreement, raising it never does. A person's up activates one. Agents need two ups from different accounts on two different pull requests, because the agent that wrote a change would otherwise grade its own review. [`add_learning`](/docs/mcp-server/add_learning) has the details.

## Examples

These responses come from a test account on a local backend. L1 and L4 are left out of the arrays below to keep them short; the call returned all four.

```json title="Call"
{
  "repo": "codepanel-dev/web-app"
}
```

```json title="Result (trimmed to L3 and L2)"
[
  {
    "createdAt": 1794607257488,
    "drafted": {
      "at": 1794607257488,
      "evidence": [
        {
          "by": "person",
          "file": "src/server/auth/rateLimit.ts",
          "label": "PR #142 F3",
          "note": "Both are named constants in config/auth.ts; this line imports them.",
          "prNumber": 142,
          "ref": "F3"
        }
      ],
      "model": "anthropic/claude-opus-5-5"
    },
    "number": 3,
    "prNumber": 142,
    "ref": "L3",
    "scope": "src/server/auth/",
    "source": "drafted",
    "state": {
      "activatedAt": 1794607257488,
      "by": "evidence",
      "status": "active"
    },
    "text": "Limits under src/server/auth/ are named constants imported from config/auth.ts; don't report the numbers at their call sites as magic numbers."
  },
  {
    "createdAt": 1794528057488,
    "number": 2,
    "prNumber": 139,
    "ref": "L2",
    "scope": "src/flags/",
    "source": "api",
    "state": {
      "needs": "an up from a person, or an up from another identity on another pull request",
      "status": "candidate"
    },
    "text": "Feature flags in src/flags/ are read on every request, never cached, so findings about stale flag values there are false positives."
  }
]
```

L3 was drafted by the orchestrator and is active at once. The orchestrator drafts one when at least three false-positive verdicts from two or more pull requests share a cause. L2 came from a token on pull request 139, so it waits for a person or for another identity on another pull request. The two learnings dropped from this view were an active one added by a person (L1) and one a person turned off (L4, `state.status: "off"`).

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel learnings <owner/name>` ([CLI](/docs/cli)) |
| HTTP API | [`GET /learnings`](/docs/api#get-learnings) |
| Pull request | The review comment names each learning it applied and each candidate on the files it read |

## What the server tells your agent

The description your agent reads when it lists the tools:

> A repository's learnings, highest ref first: ref (L3), text, scope (a path prefix; empty for the whole repository) and state. state.status is active (applied to pull requests opened after it activated), candidate (state.needs says what would confirm it), off (someone rated it down) or expired (no up for 180 days; an up re-confirms it). A learning with source drafted was written by the orchestrator from at least three false positives on two or more pull requests; drafted.evidence lists them (label, file, note). It is active at once; rate it down if the code contradicts it. A candidate learning becomes active with state.by disputes once the repository's disputeLearnings switch is on and the orchestrator has conceded agents' false-positive disputes citing its ref on 3 pull requests; conceded lists them (label, file, note, like drafted.evidence). hits (count, lastAt, lastPrNumber), present once the repository has REVIEW_LEARNING_ATTRIBUTION on and the learning has decided a review, counts the findings the orchestrator dropped or demoted because of it; rate a learning down if its hits are wrong.

## Related

- [`add_learning`](/docs/mcp-server/add_learning): record a fact.
- [`rate_learning`](/docs/mcp-server/rate_learning): confirm a candidate or turn one off.
- [`get_knowledge`](/docs/mcp-server/get_knowledge): learnings beside the rules and notes.
- [Learnings](/docs/repo-context#learnings): activation, drafting, hits and expiry.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
