fix(coding-agent): fixed compaction to prefer active session model over role default

- Added the active session model to compaction candidate selection before role-based candidates.
- Updated compaction routing so role-based models are only considered after the current chat model.
- Added a regression test proving an Anthropic session prefers its active model over `modelRoles.default` on OpenAI.
This commit is contained in:
can1357
2026-05-21 16:37:44 +09:00
parent dbd3540a31
commit 3d96fd0d9e
3 changed files with 110 additions and 0 deletions
@@ -6171,6 +6171,12 @@ export class AgentSession {
};
const currentModel = this.model;
// Prefer the active session's model: it's what the user is actively using,
// and routing compaction to a different provider (e.g. an OpenAI default
// model while the chat is on Anthropic) changes provider-specific behavior
// like remote compaction endpoints. Role-based candidates only kick in
// as auth fallbacks when the current model has no usable credentials.
addCandidate(currentModel);
for (const role of MODEL_ROLE_IDS) {
addCandidate(this.#resolveRoleModelFull(role, availableModels, currentModel).model);
}