---
title: "Context"
description: "Point the agent at one repository, pull request or issue, and let it read what a task needs in one call."
canonical_url: "https://github-tools.com/context"
---
# Context

> Point the agent at one repository, pull request or issue, and let it read what a task needs in one call.

## Overview

Working context is a default owner, repository, pull request or issue number that every GitHub tool fills in when the model leaves it out. An agent that works on one repository or one pull request then doesn't have to repeat them on every call, or guess them.

Context tools go with it. Each one gathers what a common task needs, such as reviewing a pull request or diagnosing a failed CI run, in a single call instead of a chain of reads the model has to plan.

## Configure

Set `context` where you create the tools or the agent:

```ts [review.ts]
import { createGithubAgent } from '@github-tools/sdk'

const agent = createGithubAgent({
  model: 'anthropic/claude-opus-5.5',
  preset: 'code-review',
  context: { owner: 'vercel', repo: 'ai', pullNumber: 42 },
})

await agent.generate({ prompt: 'Summarize this pull request and list two review findings.' })
```

The model calls `getPullRequestContext` with no arguments, and the tool fills in `vercel`, `ai` and `42`.

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Fills
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        owner
      </code>
    </td>
    
    <td>
      <code>
        owner
      </code>
      
       on every repository tool
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        repo
      </code>
    </td>
    
    <td>
      <code>
        repo
      </code>
      
       on every repository tool
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pullNumber
      </code>
    </td>
    
    <td>
      <code>
        pullNumber
      </code>
      
       on pull request tools
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        issueNumber
      </code>
    </td>
    
    <td>
      <code>
        issueNumber
      </code>
      
       on issue tools
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ref
      </code>
    </td>
    
    <td>
      <code>
        ref
      </code>
      
       on tools that read a branch, tag or commit
    </td>
  </tr>
</tbody>
</table>

For each field you set, the matching input becomes optional in the tool's schema, and the value fills it when the model leaves it out.

`createGithubAgent` also adds one line to the system prompt, such as "Working context: repository vercel/ai, pull request #42.", telling the model to leave those values out.

## Context tools

A context tool answers one common question in a single call. Use them in place of the reads they replace: the model plans fewer steps, and each result is shaped for the task.

<context-bundle>



</context-bundle>

<table>
<thead>
  <tr>
    <th>
      Tool
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        getPullRequestContext
      </code>
    </td>
    
    <td>
      The pull request, its changed files and its reviews. Optional: check runs and combined status for the head commit (<code>
        includeChecks
      </code>
      
      ), and the issues it closes (<code>
        includeLinkedIssues
      </code>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getIssueContext
      </code>
    </td>
    
    <td>
      The issue with its full body, the repository's label names, and the five most recent comments
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getReleaseContext
      </code>
    </td>
    
    <td>
      A release (latest, by ID or by tag), the release before it, and the comparison between their tags
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getCiFailureContext
      </code>
    </td>
    
    <td>
      For a <code>
        ref
      </code>
      
      : combined status, failing check runs, recent failed runs, and the failed jobs, steps and log tail of the latest one. For a <code>
        runId
      </code>
      
      : that run and its failed jobs
    </td>
  </tr>
</tbody>
</table>

### Get what a context tool left out

Each context tool marks what it left out, so the model knows when to fetch more:

- `getPullRequestContext` sets `filesHasMore` and `reviewsHasMore` when those lists continue. Patches are left out unless `includePatch` is true. Fetch the diffs you need with `listPullRequestFiles` and `filenames`.
- `getIssueContext` sets `commentsHasMore`, and `listIssueComments` pages through the rest. Raise `maxComments` for more. It returns label names only, and `listLabels` has their colors and descriptions.
- `getReleaseContext` compares against the previous published release. Pass `previousTag` when a repository publishes several packages and the previous release belongs to another one.
- `getCiFailureContext` returns the last 40 lines of each of the first three failed jobs. Change it with `logLines`, or set `0` to skip logs, then read more with `getWorkflowJobLogs`.

## FAQ

<accordion>
<accordion-item label="Can the agent still work on another repository?">

Yes, a value the model passes always wins over the context, so it can read another repository when the user asks.

</accordion-item>

<accordion-item label="Is the context line added when I replace the system prompt?">

Yes, `createGithubAgent` appends the context line even when you replace the prompt with `instructions`.

</accordion-item>

<accordion-item label="Where does context work?">

`context` works on `createGithubTools`, `createGithubAgent`, `createDurableGithubAgent`, the [eve extension](https://github-tools.com/integrations/eve) and [TanStack AI](https://github-tools.com/integrations/tanstack-ai). It doesn't apply to [single tool factories](https://github-tools.com/tools#pick-single-tools).

</accordion-item>

<accordion-item label="Why does getIssueContext return the full issue body?">

`getIssueContext` defaults to `detail: 'full'` because it's meant to be called once per issue. The other three context tools default to `detail: 'summary'`, like the single reads. See [Output size](https://github-tools.com/tools#output-size).

</accordion-item>
</accordion>


## Sitemap

See the full [sitemap](https://github-tools.com/sitemap.md) for all pages.
