fix: inject /v1 suffix in baseURL and skip injection when gateway is down

The Anthropic SDK appends /messages to baseURL, so the gateway
baseURL must include /v1. Also removes the static baseURL from
opencode.json — the plugin now injects it dynamically only when the
gateway health check passes, so requests fall through directly to
api.anthropic.com when Mnemosyne is not running.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Joey Yakimowich-Payne 2026-03-13 11:59:50 -06:00
commit f8f85aea47

View file

@ -275,8 +275,9 @@ const MnemosynePlugin: Plugin = async (ctx: PluginInput): Promise<Hooks> => {
// Only set if not already overridden by user
if (!inputConfig.provider.anthropic.options.baseURL) {
inputConfig.provider.anthropic.options.baseURL = gateway.url;
log.info(`Routing Anthropic through gateway at ${gateway.url}`);
// Anthropic SDK appends /messages to baseURL, so we need /v1 suffix
inputConfig.provider.anthropic.options.baseURL = `${gateway.url}/v1`;
log.info(`Routing Anthropic through gateway at ${gateway.url}/v1`);
} else {
log.debug(
`baseURL already set to ${inputConfig.provider.anthropic.options.baseURL}, not overriding`