-
Notifications
You must be signed in to change notification settings - Fork 35
Description
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
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",
},
},
},
})