fix: keep oauth profile stable
This commit is contained in:
@@ -104,6 +104,7 @@
|
|||||||
- Telegram: send GIF media as animations (auto-play) and improve filename sniffing.
|
- Telegram: send GIF media as animations (auto-play) and improve filename sniffing.
|
||||||
- Bash tool: inherit gateway PATH so Nix-provided tools resolve during commands. Thanks @joshp123 for PR #202.
|
- Bash tool: inherit gateway PATH so Nix-provided tools resolve during commands. Thanks @joshp123 for PR #202.
|
||||||
- Delivery chunking: keep Markdown fenced code blocks valid when splitting long replies (close + reopen fences).
|
- Delivery chunking: keep Markdown fenced code blocks valid when splitting long replies (close + reopen fences).
|
||||||
|
- Auth: prefer OAuth profiles over API keys during round-robin selection (prevents OAuth “lost after one message” when both are configured).
|
||||||
|
|
||||||
### Maintenance
|
### Maintenance
|
||||||
- Agent: add `skipBootstrap` config option. Thanks @onutc for PR #292.
|
- Agent: add `skipBootstrap` config option. Thanks @onutc for PR #292.
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ describe("resolveAuthProfileOrder", () => {
|
|||||||
},
|
},
|
||||||
provider: "anthropic",
|
provider: "anthropic",
|
||||||
});
|
});
|
||||||
expect(order).toEqual(["anthropic:b", "anthropic:a", "anthropic:c"]);
|
expect(order).toEqual(["anthropic:a", "anthropic:b", "anthropic:c"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("pushes cooldown profiles to the end, ordered by cooldown expiry", () => {
|
it("pushes cooldown profiles to the end, ordered by cooldown expiry", () => {
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ function orderProfilesByMode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort available profiles by lastUsed (oldest first = round-robin)
|
// Sort available profiles by lastUsed (oldest first = round-robin)
|
||||||
// Then by type (oauth preferred over api_key)
|
// Then by lastUsed (oldest first = round-robin within type)
|
||||||
const scored = available.map((profileId) => {
|
const scored = available.map((profileId) => {
|
||||||
const type = store.profiles[profileId]?.type;
|
const type = store.profiles[profileId]?.type;
|
||||||
const typeScore = type === "oauth" ? 0 : type === "api_key" ? 1 : 2;
|
const typeScore = type === "oauth" ? 0 : type === "api_key" ? 1 : 2;
|
||||||
@@ -508,14 +508,14 @@ function orderProfilesByMode(
|
|||||||
return { profileId, typeScore, lastUsed };
|
return { profileId, typeScore, lastUsed };
|
||||||
});
|
});
|
||||||
|
|
||||||
// Primary sort: lastUsed (oldest first for round-robin)
|
// Primary sort: type preference (oauth > api_key).
|
||||||
// Secondary sort: type preference (oauth > api_key)
|
// Secondary sort: lastUsed (oldest first for round-robin within type).
|
||||||
const sorted = scored
|
const sorted = scored
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
// First by lastUsed (oldest first)
|
// First by type (oauth > api_key)
|
||||||
if (a.lastUsed !== b.lastUsed) return a.lastUsed - b.lastUsed;
|
if (a.typeScore !== b.typeScore) return a.typeScore - b.typeScore;
|
||||||
// Then by type
|
// Then by lastUsed (oldest first)
|
||||||
return a.typeScore - b.typeScore;
|
return a.lastUsed - b.lastUsed;
|
||||||
})
|
})
|
||||||
.map((entry) => entry.profileId);
|
.map((entry) => entry.profileId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user