mirror of
https://github.com/rohitg00/agentmemory.git
synced 2026-09-14 20:16:33 +08:00
27c38b74e6
@rager306 reported v0.9.8 MiniMax compression failing with "MiniMax API error 401: invalid api key" against a known-good key. Direct curl to https://api.minimax.io/anthropic/v1/messages with the same key succeeded; control curl to https://api.minimaxi.com/anthropic reproduced the 401. The 401 came from the stale fallback host, not the key. Root cause: split-brain env source. src/config.ts (provider detection, API key load) reads ~/.agentmemory/.env via the merged getMergedEnv() loader. src/providers/minimax.ts read MINIMAX_BASE_URL directly off process.env. Users who put MINIMAX_BASE_URL only in ~/.agentmemory/.env (e.g. systemd / launchd / .env-only deployments) got their key loaded fine but the base URL fell through to the stale api.minimaxi.com default. MiniMax's current Anthropic-compatible endpoint per their docs is api.minimax.io/anthropic/v1/messages (https://platform.minimax.io/docs/api-reference/text-anthropic-api). Fix: - Switch MinimaxProvider.baseUrl resolution from process.env['MINIMAX_BASE_URL'] to getEnvVar('MINIMAX_BASE_URL'), matching how every other config knob in agentmemory is loaded. - Bump the default from https://api.minimaxi.com/anthropic to https://api.minimax.io/anthropic. - Update the inline JSDoc to mention ~/.agentmemory/.env as a source alongside process.env, so the env contract is discoverable from the file. - Add test/minimax-provider.test.ts asserting the default is the current host and the env override is honored. Verified locally: 862/862 tests pass on the branch. @rager306 has already verified end-to-end that a local patch with the same change fixed his /agentmemory/observe + compression flow.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { describe, expect, it, afterEach } from "vitest";
|
|
import { MinimaxProvider } from "../src/providers/minimax.js";
|
|
|
|
describe("MinimaxProvider — base URL resolution (#285)", () => {
|
|
const originalEnv = process.env["MINIMAX_BASE_URL"];
|
|
|
|
afterEach(() => {
|
|
if (originalEnv === undefined) {
|
|
delete process.env["MINIMAX_BASE_URL"];
|
|
} else {
|
|
process.env["MINIMAX_BASE_URL"] = originalEnv;
|
|
}
|
|
});
|
|
|
|
it("defaults to https://api.minimax.io/anthropic (not the legacy minimaxi.com host)", () => {
|
|
delete process.env["MINIMAX_BASE_URL"];
|
|
const provider = new MinimaxProvider("test-key", "MiniMax-M2.7", 800);
|
|
expect((provider as unknown as { baseUrl: string }).baseUrl).toBe(
|
|
"https://api.minimax.io/anthropic",
|
|
);
|
|
});
|
|
|
|
it("honors MINIMAX_BASE_URL via getEnvVar (merged ~/.agentmemory/.env + process.env)", () => {
|
|
process.env["MINIMAX_BASE_URL"] = "https://custom.example.com/anthropic";
|
|
const provider = new MinimaxProvider("test-key", "MiniMax-M2.7", 800);
|
|
expect((provider as unknown as { baseUrl: string }).baseUrl).toBe(
|
|
"https://custom.example.com/anthropic",
|
|
);
|
|
});
|
|
});
|