github / github/copilot-sdk

Mutable session properties

Abierto
#39 5 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement wishlist
Lenguaje dominante
Java
Estrellas
10.5k
Forks
1.5k
Merge medio
1 d 11 h
PR fusionados (30 d)
127

Descripción

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",
},
},
},
})

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.