Guide

Issues

List, search, read, create, edit and comment on issues with the same options on every platform.

Calls

ts
const repo = { owner: "owner", repo: "repo" };
const issue = { ...repo, number: 42 };

const open = await forge.issues.list(repo, { state: "open", perPage: 30 });
const found = await forge.issues.search(repo, { query: "hydration mismatch", state: "all" });
const one = await forge.issues.get(issue);
const comments = await forge.issues.listComments(issue, { perPage: 50 });
const comment = await forge.issues.getComment(issue, { commentId: comments.items[0]!.id });
const posted = await forge.issues.createComment(issue, { body: "Fixed in #43." });
await forge.issues.updateComment(issue, { commentId: posted.id, body: "Fixed in #44." });
await forge.issues.deleteComment(issue, { commentId: posted.id });
const reactions = await forge.issues.listReactions(issue);

const created = await forge.issues.create(repo, {
  title: "Broken link on the deploy page",
  body: "The Cloudflare link 404s.",
  labels: ["docs"],
  assignees: ["someone"],
});

const closed = await forge.issues.update(issue, {
  state: "closed",
  removeLabels: ["needs-triage"],
});

ListOptions is cursor, perPage and state, and state is open, closed or all.

The shape

ts
interface Issue {
  id: string;
  number: number; // GitLab iid, not the global id
  title: string;
  body: string;
  state: "open" | "closed";
  labels: string[];
  author: { login: string };
  assignees: { login: string }[];
  createdAt: string;
  updatedAt: string;
  url: string;
  type?: string | null; // GitHub only, see below
  fields?: Record<string, string | number | string[]>;
}

GitHub's /issues endpoint returns pull requests too, which is a trap the first time. They are filtered out here by the missing pull_request key, so issues.list on GitHub is issues only.

A huge issue body reaches an agent in pieces. forges_issues_get pages it with offset, maxChars and bodyHash, exactly like a pull request body.

search keeps the platform's own syntax. GitHub qualifiers like label:bug is:open work on GitHub. GitLab and Gitea treat the whole string as text, so label:bug there searches for the literal string. The result is a SearchPageResult, a PageResult plus incomplete, true when the platform admits the answer is partial.

Leave out state and the search covers open and closed items on every platform. Gitea on its own answers with open ones only, so forges asks it for all of them.

An empty query is a ForgesError with status 400 before any request goes out.

Search across repositories

Open bugs anywhere in an organization used to mean a loop. One call per repository, until somebody gives up. searchGlobal asks once.

ts
const bugs = await forge.issues.searchGlobal("", {
  owner: "agntn",
  state: "open",
  labels: ["bug"],
});

Each hit is an Issue plus repository, so you know where to go next. Pull requests never show up, not even on GitHub, where they share the search route.

The options come from pull request search: author, owner, repo, sort, order, cursor and perPage. Issues add two. state is open, closed or all, and leaving it out means all. labels is a list, and an issue has to carry every label on it. Still need a query? Not with an owner, an author or a label. Any one of them is enough. "Every open issue in this org" is a fine question all by itself.

GitHub and GitLab match every label natively. Gitea is the odd one. Its search route takes two labels as either one, so forges drops the rows missing a label and sets incomplete. totalCount goes missing there too, because Gitea counted the wrong thing. Worse, Gitea forgets a label name it doesn't know and returns everything, so a typo looked like a perfect match. Not anymore. When the rows prove the filter was dropped, you get an empty page. Forgejo does exactly the same, and gets the same treatment.

A label with a comma or a double quote is a 400 before anything goes out. Gitea and GitLab split the list on commas.

forges_issues_search_global puts the same call in MCP, Pi and OMP. Bodies stay out unless bodyChars asks for the start of each one.

Comments

listComments reads the discussion oldest first. On GitHub and Gitea issues and pull requests share the endpoint, both index pull requests as issues. On GitLab the notes are asked for with an explicit ascending sort, and two kinds are dropped: system notes about label and state churn, and inline diff notes, which belong to review threads. So a short GitLab page that still carries nextCursor is normal, keep paging. Gitea sends the whole discussion at once and the page you asked for is cut locally.

createComment adds one to the end of that discussion and returns it as the platform stored it. A blank body is a ForgesError with status 400 before anything goes out. Calling it twice posts two comments, there is nothing to deduplicate on.

updateComment edits an issue comment and returns it as stored, which beats posting a correction under your own typo. deleteComment removes it and returns nothing. Both check that the comment belongs to the named issue. That's a useful boundary: a mismatch raises NotFoundError without writing anything.

ts
interface Comment {
  id: string;
  body: string;
  author: { login: string };
  url: string;
  createdAt: string;
  updatedAt: string;
}

Reactions

Sometimes the whole reply is a thumbs up. listReactions reads those too, oldest first.

ts
const issue = { owner: "owner", repo: "repo", number: 42 };
const onIssue = await forge.issues.listReactions(issue);
const onComment = await forge.issues.listReactions(issue, { commentId: "3001" });
ts
interface Reaction {
  content: string; // "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket" or "eyes"
  user: { login: string };
  createdAt: string;
}

Names follow GitHub everywhere. Where did the thumbs up go on GitLab? It's thumbsup there, and smile is GitHub's laugh. forges translates the four that differ. An emoji GitHub can't react with keeps its own name, so GitLab's fire stays fire. No guessing.

Give it a pull request number and you get a NotFoundError. GitLab says the same, and so do GitHub and Gitea, because forges reads the issue next to its reactions.

commentId takes an id from listComments. GitHub and Gitea find a comment by id alone, ignoring the issue. So forges reads the comment too. A comment from another issue is a NotFoundError, same as getComment. GitLab puts the issue in the path anyway.

Timeline

Dependencies in another repository like to hide on an issue's timeline, not in its body. listEvents reads that timeline oldest first, cross-references included.

ts
const issue = { owner: "agntn", repo: "credentials", number: 6 };
const { items } = await forge.issues.listEvents(issue);
const mentions = await forge.issues.listEvents(issue, { kinds: ["referenced"], perPage: 100 });
ts
interface ThreadEvent {
  id: string;
  kind: ThreadEventKind; // "referenced", "comment", "label", "state_change", "commit", "review" and the rest
  action: string; // "closed", "labelled", "assigned", or "other" where the forge's word has no match
  summary: string;
  actor: { login: string } | null;
  createdAt: string | null;
  reference: EventReference | null;
}

interface EventReference {
  repository: string; // "agntn/forges"
  kind: "issue" | "pull_request" | "discussion" | "commit";
  number: number | null;
  sha: string | null;
  title: string | null;
  state: "open" | "closed" | "merged" | null;
  url: string | null;
}

Comment bodies stay out of the rows. A timeline full of them would flood the page, so listComments reads them instead.

Who mentioned this thread? A referenced event points back to the source, often in another repository. Its reference carries the source's repository, kind, number, title, state and URL. A commit has a SHA instead of a number.

GitHub and Gitea fill in the title, state and URL. They report merged pull requests as closed with a merge date, so forges shows them as merged. GitLab leaves those three null. Its system note says "mentioned in merge request !5", and that's all it says.

The kinds filter works on each page separately. A short or empty page can still have a nextCursor, so keep following it. An empty list or an unknown kind is a 400 before any request.

GitHub and Gitea share one timeline route for both kinds, so forges reads the issue too and a swapped number is a NotFoundError. GitLab numbers them apart.

GitBucket has no timeline route, so listEvents returns a ForgesError with status 501 and a sentence. That's clearer than a 404 for an issue that might exist. Agents get both timelines through forges_issues_events and forges_pull_requests_events.

Sub-issues

One issue holding eight jobs is a list nobody ticks off. So split it. addSubIssue hangs an existing issue under a parent. removeSubIssue takes it back off. listSubIssues reads what's hanging there, in the parent's own order.

ts
const parent = { owner: "agntn", repo: "web", number: 292 };

await forge.issues.addSubIssue(parent, { subIssue: 303 });
await forge.issues.addSubIssue(parent, { subIssue: 304, replaceParent: true });
const { items } = await forge.issues.listSubIssues(parent, { perPage: 50 });
await forge.issues.removeSubIssue(parent, { subIssue: 303 });

Why an object for the parent? Two issue numbers in a row are one slip away from hanging the parent under its own child. Named, they can't swap places quietly. New calls take two arguments at most. The older ones still line theirs up and will follow.

Both numbers live in the parent's repository. GitHub doesn't want the child's number, it wants the internal REST id. That's the trap. forges reads the child first and sends the id, so you never see it.

A pull request number, parent or child, is a NotFoundError before anything gets linked. GitHub itself lists a pull request's sub-issues as an empty page, which looks exactly like "no children". It isn't. An issue under itself is a 400 before any request.

A child that already has a parent gets refused. replaceParent: true moves it instead. Removing deletes nothing, the child just goes back to being an ordinary issue. Both writes return the parent.

A row from listSubIssues is a SubIssue, an Issue plus repository. GitHub lets a child live in another repository of the same owner, and the row says which one.

GitHub only. GitLab, Gitea and Forgejo answer with a ForgesError of status 501, and GitBucket too. forges_issues_sub_issues, forges_issues_sub_issues_add and forges_issues_sub_issues_remove give the same three calls to agents.

Transfer

Is an issue in the wrong repo? Give it a new address.

ts
const moved = await forge.issues.transfer(
  { owner: "agntn", repo: "chains", number: 106 },
  { owner: "agntn", repo: "keys" },
);
moved.number; // 371

The result is the issue in the target repo. It has its new number and URL.

forges reads the issue before moving it. A missing issue or pull request number raises NotFoundError. Nothing moves. A target matching the source repo, ignoring case, returns 400 before any request.

GitHub moves issues between repos with the same owner. Comments and assignees stay. Labels and milestones stay only when the target has matching names. The old URL redirects to the new one. Another org, though? Then you're filing a new one.

GitLab moves issues to any project you can write to. It closes the original and copies it, including comments. The closed original gets a note pointing to the new issue. Closer to a copy than a move, honestly.

Pull requests can't move on either forge. Gitea, Forgejo, GitBucket and other forges return ForgesError with status 501.

The agent tool is forges_issues_transfer. Its targetRepo takes a bare repo name under the same owner, or owner/name. A nested GitLab group goes in targetOwner. Pi asks before running it.

Types and fields

Bug or feature? A board sorted by Priority wants to know. create and update can say so now.

ts
const repo = { owner: "agntn", repo: "forges" };
const { types, fields } = await forge.issues.getFields(repo);

await forge.issues.create(repo, {
  title: "Set issue type and fields",
  body: "",
  type: "Feature",
  fields: { Priority: "High", "Target date": "2026-11-15" },
});

await forge.issues.update(
  { ...repo, number: 325 },
  { fields: { Effort: "Low" }, clearFields: ["Target date"], clearType: true },
);

Where do the names come from? getFields lists every type and field the repository takes, with the options of each select. Case doesn't matter. The write spells a name the way GitHub does, so "high" lands as High.

Every name and value is checked before anything is written. A type the repository lacks is a ForgesError with status 422 that lists the ones it has. Same for a field or an option. A number for a date, or a made up day like 2026-02-30, is a 422 too. A typo shouldn't leave you with half an issue.

update touches only what you name. fields sets, clearFields empties, clearType drops the type. Fields go out through POST, never PUT, because PUT replaces every value on the issue. And POST with an empty list wipes them all. forges never sends one.

Types work in any repository, even a personal one. Fields belong to an organization that turned them on. Anywhere else getFields answers with an empty fields, and a write with fields is a 422.

One sneaky part. Without push access GitHub drops the type and fields without a word. The issue still comes back, just bare. forges_issues_create and forges_issues_update compare and put it in a note.

Issue carries type and fields where the payload has them: GitHub's get, list and search. An untyped issue has type: null. GitBucket sends neither, so both stay missing, which isn't the same as empty.

GitHub only. GitLab, Gitea and Forgejo answer with a ForgesError of status 501 before anything goes out, so a type never vanishes on the way. forges_issues_fields hands agents the list.

Changing one after it's filed

update works like the pull request one. It takes only what changes: title, body, state ("closed" closes, "open" reopens), and addAssignees, removeAssignees, addLabels, removeLabels. What you leave out stays, so fixing one number in the body keeps the labels and assignees where they were. The result is the issue after the write.

An update that changes nothing, a blank title, or the same login or label in both an add and a remove list is a ForgesError with status 400 before anything goes out.

GitHub and Gitea serve pull requests on the issue route too, so both read the number first and answer NotFoundError when it's a pull request, before anything is written. After that GitHub patches title, body and state, then adds and removes assignees and labels one route at a time. GitLab sends one PUT and reads the issue first only for an assignee change, because assignees go out as the whole list. Gitea also sends assignees as the whole list, and changes labels by id. Several requests are not one transaction, so read the issue again before you retry a failed one.

GitHub's state_reason (completed, not_planned) is left out. GitLab and Gitea have nothing like it.

Assignees

assignees on create takes logins. GitLab Free accepts one. Pass two and you get a 400 before the request leaves, instead of a confusing answer from GitLab.

An issue body or a comment was written by whoever has an account. Render it, summarize it, do not execute it.