Guide

Working Context and Composites

Default owner/repo/PR/issue/ref on tools, prefer composite reads, and keep payloads lean with detail, includePatch, and line ranges.

Agents burn tokens on repeated owner / repo args, multi-hop reads, and fat payloads (full PR diffs, long issue bodies, entire files). The SDK ships three levers that work together: a working context, composite tools, and lean defaults.

Working context

Pass context to createGithubTools, createGithubAgent, or createDurableGithubAgent to default owner, repo, pullNumber, issueNumber, and/or ref on matching tool inputs. Matching schema fields become optional and fill from context when omitted. Agents also get a short system-prompt block describing the context:

context.ts
import { createGithubTools, createGithubAgent } from '@github-tools/sdk'

const tools = createGithubTools({
  preset: 'code-review',
  context: { owner: 'vercel', repo: 'ai', pullNumber: 42 },
})

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

The same option is available on the eve extension via context in the mount config.

Composite tools

Prefer one composite call over chaining several reads:

ToolReturns
getPullRequestContextPR details + files + reviews (+ optional CI checks)
getIssueContextIssue + labelNames + recent comments
getReleaseContextRelease + previous release + tag comparison
getCiFailureContextCombined status, failing checks, failed workflow jobs/steps

Call independent follow-up reads in the same step when you already know the arguments (for example getIssueContext and listIssues together).

Lean payload defaults

DefaultBehaviorOverride
detail: 'summary'Truncates long bodies (~500 chars) on getPullRequest, getIssue, getDiscussion, and release gettersdetail: 'full'
getIssueContextDefaults to detail: 'full' (one-shot) and returns labelNames (strings), not full label objectsdetail: 'summary'; use listLabels for descriptions
includePatch: falseOmits diff patches on listPullRequestFiles, getCommit, compareCommitsincludePatch: true; optionally filenames on listPullRequestFiles
File rangesPrefer startLine / endLine / maxLines on getFileContentOmit ranges only for small files
maxPagesList tools fetch one page by defaultSet maxPages to combine sequential pages in one call
Text-match fragmentssearchCode truncates each snippet to ~300 charsNone — fetch the file with getFileContent for full context
listDiscussionsReturns 20 discussions per call, cursor-paginatedRaise perPage, or pass the returned endCursor as after
listNotificationsReturns 20 unread threads per call (max 50)all: true to include read threads; raise perPage

Example: code review bootstrap

review-bootstrap.ts
import { createGithubAgent } from '@github-tools/sdk'

const agent = createGithubAgent({
  model: 'anthropic/claude-sonnet-4.6',
  preset: 'code-review',
  context: { owner: 'vercel-labs', repo: 'github-tools', pullNumber: 39 },
})

// Prefer getPullRequestContext first, then listPullRequestFiles with
// includePatch + filenames for only the files you need to inspect.
await agent.generate({ prompt: 'Summarize this PR and list two review findings. Read-only.' })

See the tools catalog for the full list and the API reference for context on createGithubTools.