Repository navigation
Open
Labels
feature-requestRequest for new features or functionalityunder-discussionIssue is under discussion for relevance, priority, approach
Description
Motivation
Agent hosts already track the durable things a session is about or produced, such as the pull request it opened, the issue it is fixing, or a link the agent told the user to come back to. Clients show them as pills next to the chat input and in session lists. Each host does this through its own _meta convention today:
- copilot-host publishes
_meta["copilot.githubReferences"]on the session and its summary: a list of{ referenceType, repository, number, title, state?, url, relations: ["headBranch" | "attached"] }. - VS Code publishes
_meta["agentHost/sessionArtifacts"]({ id, chat?, type: "pullRequest" | "issue" | "commit" | …, label, isArtifact, link, isGitHub }), plus Git-derived pull request URLs per folder under_meta["githubData"].
Neither host reads the other's key, so a client has to implement both to show "this session's pull request". The doctrine says an escape hatch should become typed state once interoperable clients need it. This RFC proposes that typed state.
Proposal
A single list of artifacts on the session. Each artifact is a thing plus one or more reasons why the session references it.
/** @nonexhaustive */
export const enum ArtifactKind {
/** An artifact addressed by URI. */
Resource = 'resource',
}
/** @nonexhaustive */
export const enum ArtifactRelationKind {
/** The session or chat produced it, e.g. opened the pull request or pushed the commit. */
Created = 'created',
/** The agent pointed the user at it as worth returning to. */
Referenced = 'referenced',
/** The work is derived from it: the issue being fixed, the pull request being reviewed or iterated on. */
DerivedFrom = 'derivedFrom',
}
export interface ArtifactRelation {
kind: ArtifactRelationKind;
/** The chat that established the relation. Absent means the relation belongs to the session as a whole. */
chat?: URI;
}
export interface ArtifactBase {
label: string;
/** Advisory display hint, same semantics as `MessageAttachmentBase.displayKind`. */
displayKind?: string;
/** Why the session references this artifact. Never empty. */
relations: ArtifactRelation[];
_meta?: Record<string, unknown>;
}
/** Keyed by `uri`, which hosts SHOULD canonicalize. */
export interface ResourceArtifact extends ArtifactBase, ContentRef {
type: ArtifactKind.Resource;
}
export type Artifact = ResourceArtifact;State
SessionState.artifacts?: Artifact[]is the authoritative list. The host sets the order.- A chat's view is the entries with a relation whose
chatis that chat. There is no separateChatState.artifacts, so there is nothing to keep in sync. SessionSummary.artifacts?: Artifact[]mirrors the list for session lists. The host SHOULD keep it small and MAY leave entries out.
Actions (following the keyed-collection convention)
session/artifactSet { artifact }adds the entry, or replaces the one with the sameuri.session/artifactRemoved { uri }removes it, and does nothing if no entry matches. A client may dispatch this to dismiss an entry; the host still decides.
Design notes
- No PR/issue/commit types. A pull request is just a URI with something like
displayKind: "pullRequest"as a hint. Clients that need a number or state can parse the URL or fetch the item; forge-specific state (open/merged/draft, CI) goes in_meta. This keeps the protocol independent of any particular forge. relationsis an array because an entry is keyed byuriand the same item can be related to the session in several ways, or by several chats. For example, chat A opens a PR (created) and chat B links to it (referenced). A single value would need either a composite key or a precedence rule that loses per-chat attribution.- No
attachedrelation. What a user attached to a message belongs to message attachments, not here. derivedFromcovers both "the PR whose branch is checked out here" (copilot-host'sheadBranch) and "this session exists to fix issue resolveSessionConfig/sessionConfigCompletions for custom metadata in createSession flow #42", including sessions started from an issue or a PR.- A one-variant union (
Artifact = ResourceArtifact), likeSessionOrigin, so we can add variants later without turning a plain interface into a union in every generated client. - No overlap with
ChatOrigin.ChatOrigin/SessionOriginrecord how something was created: they are fixed at creation and point at chats or automation runs. Artifact relations record what the work is about or produced, and change over time. Artifacts MUST NOT describe relationships between chats in the same session; that lineage belongs toChatOrigin.
Mapping from today's conventions
| Today | Proposed |
|---|---|
copilot headBranch |
derivedFrom |
copilot attached |
Not an artifact; the host may add derivedFrom if the item clearly drives the session |
VS Code artifact, isArtifact: true |
created with chat |
VS Code artifact, isArtifact: false |
referenced with chat |
VS Code githubData.pullRequestUrls / associatedPullRequestUrls, create-session-from-PR |
derivedFrom |
VS Code initialPullRequestUrls, pullRequestBranchName |
Stays private host bookkeeping |
Open questions
- Naming. Many entries aren't produced by the session, so "artifact" is used loosely.
referencesorrelatedItemsare alternatives. SimilarlyderivedFromvssubject/basedOn. - Recommended
displayKindvalues. Should the spec list values such aspullRequest,issueandcommit, the way attachments listimageanddocument, so clients don't drift on what they call the same thing? - Client-added artifacts. Should clients be able to dispatch
session/artifactSet(e.g. to pin an item), or only remove entries?
Metadata
Metadata
Assignees
Labels
feature-requestRequest for new features or functionalityunder-discussionIssue is under discussion for relevance, priority, approach
Activity