Add additionalContentExclusionPolicies to SessionConfig (public high-level API)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 65/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- typescript
- 领域
- api
调研方向
从公开的 SessionConfigBase 接口以及 createSession() 和 resumeSession() 入口开始,然后将它们的映射与生成的 SessionOpenOptions 类型进行比较。确认现有低级策略字段的表示和导出方式。公开类型完成文档编写、策略在创建和恢复时都以原子方式转发,并且覆盖率验证两条路径,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Java
- 星标
- 10.5k
- 派生
- 1.5k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 130
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/copilot-sdk 的其他 Issue
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2760 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2759 ·
-
documentation
难度 1/5 1 小时以内 新手友好度 85/100
github/copilot-sdk#2758 ·
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 68/100
github/copilot-sdk#2709 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 78/100
github/copilot-sdk#2673 ·
查看 github/copilot-sdk 的全部 Issue
相似的 Issue
-
area/plugin
难度 2/5 1-3 小时 新手友好度 75/100
kestra-io/plugin-kestra#190 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
apache/rocketmq-dashboard#5064 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
wso2/dpdp-accelerator#287 ·