Skip to content

RFC: Session artifacts #507

Open
Open

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 chat is that chat. There is no separate ChatState.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 same uri.
  • 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.
  • relations is an array because an entry is keyed by uri and 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 attached relation. What a user attached to a message belongs to message attachments, not here.
  • derivedFrom covers both "the PR whose branch is checked out here" (copilot-host's headBranch) 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), like SessionOrigin, so we can add variants later without turning a plain interface into a union in every generated client.
  • No overlap with ChatOrigin. ChatOrigin/SessionOrigin record 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 to ChatOrigin.

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

  1. Naming. Many entries aren't produced by the session, so "artifact" is used loosely. references or relatedItems are alternatives. Similarly derivedFrom vs subject / basedOn.
  2. Recommended displayKind values. Should the spec list values such as pullRequest, issue and commit, the way attachments list image and document, so clients don't drift on what they call the same thing?
  3. Client-added artifacts. Should clients be able to dispatch session/artifactSet (e.g. to pin an item), or only remove entries?

Activity

  1. added
    feature-request
    under-discussion
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestunder-discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions