Add additionalContentExclusionPolicies to SessionConfig (public high-level API)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu từ interface công khai SessionConfigBase và các điểm vào createSession() và resumeSession(), sau đó so sánh ánh xạ của chúng với kiểu SessionOpenOptions được sinh tự động. Xác nhận cách các trường policy cấp thấp hiện có được biểu diễn và xuất ra. Hoàn tất khi các kiểu công khai được lập tài liệu, các policy được chuyển tiếp nguyên tử trong cả quá trình tạo và tiếp tục phiên, và coverage xác minh cả hai đường đi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Add additionalContentExclusionPolicies to SessionConfig (public high-level API)
Summary
The Copilot SDK exposes content exclusion policy support at the low-level RPC layer
(SessionOpenOptions.additionalContentExclusionPolicies, session.rpc.options.update,
session.rpc.permissions.configure) but does not surface it through the public
SessionConfig / SessionConfigBase interface used by createSession() and
resumeSession(). This makes it impossible for SDK consumers to set per-session
content exclusion rules through the documented, stable public API.
Motivation
Content exclusion is a core compliance and data-governance feature. At GitHub
organization level, admins configure it via repository settings. However, SDK
consumers — especially those building multi-tenant agentic applications — need to
inject additional exclusion rules per session, beyond what GitHub org settings provide:
- Multi-tenant SaaS: Each tenant has their own data classification rules that
must not be shared with the model context (PII paths, credentials directories,
confidential source trees). - Regulated environments (GxP, HIPAA, SOC 2): Compliance requirements dictate
that certain file patterns are never read by the model, regardless of what
the repository-level GitHub policy says. - Agent isolation: Pipeline orchestrators that spawn per-role sessions need to
scope each session's readable context to only the files that role is authorized
to see, without coupling this to GitHub org settings.
Current workaround (and why it is insufficient)
The only way to set exclusion rules today is via session.rpc.permissions.configure()
after the session is created:
const session = await client.createSession({ ... });
// Race condition: session may have already started reading files before this call
await session.rpc.permissions.configure({
additionalContentExclusionPolicies: [{
rules: [{ paths: ["**/secrets/**", "**/.env*"], source: { name: "tenant-policy", type: "host" } }],
last_updated_at: Date.now(),
scope: "all",
}],
});
Problems:
- Race condition: The session may read files before the
configurecall returns.
There is no way to guarantee exclusion rules are active before the first turn. - Undocumented surface:
session.rpcis a low-level raw RPC accessor marked
@experimental. Nothing in the README or SDK docs points consumers here for
content exclusion. - Inconsistent with the rest of the API: Every other security-relevant session
option (availableTools,excludedTools,onPermissionRequest,
skipCustomInstructions,gitHubToken,skipEmbeddingRetrieval) is set
throughSessionConfigBase. Content exclusion policies should follow the same
pattern. - Mid-session update (
rpc.options.update) is the only per-turn path: There is
no way to supply policies atomically with the session creation RPC.
Proposed change
Add additionalContentExclusionPolicies to SessionConfigBase:
export interface SessionConfigBase {
// ... existing fields ...
/**
* Additional content-exclusion policies to merge into the session's policy set
* on creation (and on resume). Rules are evaluated alongside natively-discovered
* GitHub organization / repository policies.
*
* Use this to inject application-level or tenant-level path exclusions that
* are not covered by GitHub organization settings — for example, in multi-tenant
* deployments where each session must be scoped to its tenant's permitted file set.
*
* Each policy rule that matches a file path will cause the CLI to deny Copilot
* access to that file, equivalent to a `PermissionDecisionDeniedByContentExclusionPolicy`
* outcome on the permission request for that path.
*
* @example
* ```typescript
* const session = await client.createSession({
* additionalContentExclusionPolicies: [{
* scope: "all",
* last_updated_at: Date.now(),
* rules: [
* {
* paths: ["**/.env*", "**/secrets/**", "**/*.pem"],
* source: { name: "tenant-compliance-policy", type: "host" },
* },
* ],
* }],
* });
* ```
*
* @experimental
*/
additionalContentExclusionPolicies?: ContentExclusionPolicy[];
}
The ContentExclusionPolicy / ContentExclusionPolicyRule types should be exported
as first-class public types (not re-exports of the generated RPC types), with clear
JSDoc:
/** Scope for a content exclusion policy. */
export type ContentExclusionPolicyScope = "repo" | "all";
/** A single rule within a content exclusion policy. */
export interface ContentExclusionPolicyRule {
/** Glob patterns for file paths to exclude from Copilot context. */
paths: string[];
/** The rule is active only when at least one of these patterns matches the file content. */
ifAnyMatch?: string[];
/** The rule is active only when none of these patterns matches the file content. */
ifNoneMatch?: string[];
/** Source label identifying who issued this rule. */
source: { name: string; type: string };
}
/** A content exclusion policy applied to a session. */
export interface ContentExclusionPolicy {
/** The rules that make up this policy. */
rules: ContentExclusionPolicyRule[];
/** ISO 8601 timestamp or Unix ms epoch when the policy was last updated. */
last_updated_at: string | number;
/** Whether the policy applies to the current repository only, or all repositories. */
scope: ContentExclusionPolicyScope;
}
Expected behavior
- Policies supplied in
SessionConfig.additionalContentExclusionPoliciesare
applied atomically with the session creation RPC (SessionOpenOptions), before
any tool execution can occur. - On
resumeSession, the same field re-applies the policies so resumed sessions
respect updated tenant rules. - Policies compose with GitHub org-level exclusions (same as the current RPC
behavior): a file is excluded if it matches any policy from any source.
Alternatives considered
- Rely on
onPermissionRequestto deny individual file reads: This works per
permission prompt but does not prevent the model from receiving file content via
attachment or retrieval paths that do not go through the permission system. - Use
availableTools/excludedToolsto remove read tools: Too coarse —
this removes read access entirely rather than scoping it to allowed paths. - GitHub org content exclusion settings: Not available in multi-tenant scenarios
where the SDK host is not a GitHub organization admin, or where tenants are
not GitHub entities at all.
References
- Generated RPC types:
SessionOpenOptions.additionalContentExclusionPolicies,
PermissionsConfigureParams.additionalContentExclusionPolicies,
OptionsUpdateParams.additionalContentExclusionPolicies - Related:
SessionConfigBase.gitHubToken— per-session GitHub identity for
org-level content exclusion discovery - Related:
SessionConfigBase.availableTools/excludedTools— tool-level
filtering, not path-level content filtering
- Ngôn ngữ chính
- Java
- Star
- 10.5k
- Fork
- 1.5k
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 131
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/copilot-sdk
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2709 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
github/copilot-sdk#2673 ·
-
bug testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
github/copilot-sdk#2628 ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2627 · 1 bình luận ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
github/copilot-sdk#2493 ·
Tất cả issue của github/copilot-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
elastic/gradle-plugins#157 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cryptomator/hub#497 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
johanhaleby/occurrent#1120 ·