github / github/copilot-sdk

Mutable session properties

未关闭
#39 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement wishlist
主要语言
Java
星标
10.5k
派生
1.5k
平均合并
1 天 11 小时
30 天内合并 PR
127

描述

Whether a session was created anew or an existing was resumed, the session object should have some mutable properties:
- model
- provider
- tools
- env

(I can break these into separate issues if need be)

**Model**

ATM, you can only define a model at time of creation. But if a session is going from (eg) Opus for planning to Sonnet for execution, you should be able to do that in the same session.

**Provider**

Like model, but `provider` is able to be customized when resuming a session. The needs/use case are the same.

**Tools**

We can resume a session and modify its `tools` and `customAgents`, but not the availableTools. Everything should be mutable throughout the lifetime of the session.

**env (blocking)**

A session should be resumable with a different set of ENV variables. The `CopilotClient` can still accept an `env`, but this should be treated as fallback. Individual sessions can/should override what the parent-client provides as fallback.

---

**Proposed APIs**

Perhaps a unifying `await session.configure({ ... })` can be added, so that it can be called at any time, but is only applied while the pending_messages being modified (AKA, before the next `.send()` message is processed, whether its an immediate or enqueued message)

or

Add additional `options` to `send()` so that is processed with

```ts
let c = new CopilotClient({
env: {
GITHUB_TOKEN: "DEFAULT-TOKEN"
}
});

let s = await c.createSession({
model: "default",
mcpServers: {
github: {
type: "http",
url: "https://api.githubcopilot.com/mcp/",
tools: ["*"],
headers: {
"Authorization": `Bearer DEFAULT-TOKEN`, // <<
"X-MCP-Readonly": "true",
},
},
},
});

// Option 1: Modify session
// eg "use these from here on out"
await s.configure({
model: "override",
env: {
GITHUB_TOKEN: "USER-TOKEN",
},
mcpServers: {
github: {
type: "http",
url: "https://api.githubcopilot.com/mcp/",
tools: ["*"],
headers: {
"Authorization": `Bearer USER-TOKEN`, // <<
"X-MCP-Readonly": "true",
},
},
},
});

await s.send({ prompt: "uses overrides" });
await s.send({ prompt: "me too" });

// ---

// Option 2: inline overrides
// Only applies to the single turn

await s.send({
prompt: "Include custom settings, just for this message",
// Config for this message
// ---
model: "override",
env: {
GITHUB_TOKEN: "USER-TOKEN",
},
mcpServers: {
github: {
type: "http",
url: "https://api.githubcopilot.com/mcp/",
tools: ["*"],
headers: {
"Authorization": `Bearer USER-TOKEN`, // <<
"X-MCP-Readonly": "true",
},
},
},
})

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。