Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix: Set max completion tokens to true when using default openai config (#3007)

Mohamed Bassem98c0c7896e85
diff --git a/docs/docs/03-configuration/01-environment-variables.md b/docs/docs/03-configuration/01-environment-variables.md
index f1c9a704..fa83364c 100644
--- a/docs/docs/03-configuration/01-environment-variables.md
+++ b/docs/docs/03-configuration/01-environment-variables.md
@@ -103,7 +103,7 @@ Either `OPENAI_API_KEY` or `OLLAMA_BASE_URL` need to be set for automatic taggin
| OLLAMA_BASE_URL | No | Not set | If you want to use ollama for local inference, set the address of ollama API here. |
| OLLAMA_KEEP_ALIVE | No | Not set | Controls how long the model will stay loaded into memory following the request (examples: "5m" for 5 minutes, "-1m" to keep the model loaded indefinitely, "0" to unload the model instantly after processing is complete). |
| SEMANTIC_SEARCH_ENABLED | No | true | Enables the hybrid and semantic bookmark search modes. **Experimental.** `EMBEDDING_ENABLE_AUTO_INDEXING` must also be enabled. |
-| INFERENCE_TEXT_MODEL | No | gpt-4.1-mini | The model to use for text inference. You'll need to change this to some other model if you're using ollama. |
+| INFERENCE_TEXT_MODEL | No | gpt-5.6-luna | The model to use for text inference. You'll need to change this to some other model if you're using ollama. |
| INFERENCE_IMAGE_MODEL | No | gpt-4o-mini | The model to use for image inference. You'll need to change this to some other model if you're using ollama and that model needs to support vision APIs (e.g. llava). |
| EMBEDDING_ENABLE_AUTO_INDEXING | No | enabled if using OpenAI | Whether bookmark embedding generation and vector indexing are enabled. This is enabled by default if you're using the default OpenAI settings (i.e. no Ollama, no OpenAI base URL override). Otherwise, you need to manually enable it after configuring the embedding model and its dimensions. |
| EMBEDDING_OPENAI_API_KEY | No | `OPENAI_API_KEY` | The API key used for OpenAI-compatible embedding requests. If unset, embedding requests use `OPENAI_API_KEY`. |
@@ -116,7 +116,7 @@ Either `OPENAI_API_KEY` or `OLLAMA_BASE_URL` need to be set for automatic taggin
| EMBEDDING_JOB_TIMEOUT_SEC | No | 60 | How long to wait for an embedding generation and vector indexing job to finish before timing out. Increase this if your embedding provider or vector store is slow. |
| INFERENCE_CONTEXT_LENGTH | No | 2048 | The max number of tokens that we'll pass to the inference model. If your content is larger than this size, it'll be truncated to fit. The larger this value, the more of the content will be used in tag inference, but the more expensive the inference will be (money-wise on openAI and resource-wise on ollama). Check the model you're using for its max supported content size. |
| INFERENCE_MAX_OUTPUT_TOKENS | No | 2048 | The maximum number of tokens that the inference model is allowed to generate in its response. This controls the length of AI-generated content like tags and summaries. Increase this if you need longer responses, but be aware that higher values will increase costs (for OpenAI) and processing time. |
-| INFERENCE_USE_MAX_COMPLETION_TOKENS | No | false | \[OpenAI Only\] Whether to use the newer `max_completion_tokens` parameter instead of the deprecated `max_tokens` parameter. Set to `true` if using GPT-5 or o-series models which require this. Will become the default in a future release. |
+| INFERENCE_USE_MAX_COMPLETION_TOKENS | No | *Read description* | \[OpenAI Only\] Whether to use the newer `max_completion_tokens` parameter instead of the deprecated `max_tokens` parameter. Set to `true` if using GPT-5 models which require this. If using the default openai configuration (with 5.6 luna) this will be set to true, else defaults to false. |
| INFERENCE_LANG | No | english | The language in which the tags will be generated. |
| INFERENCE_NUM_WORKERS | No | 1 | Number of concurrent workers for AI inference tasks (tagging and summarization). Increase this if you have multiple AI inference requests and want to process them in parallel. |
| INFERENCE_ENABLE_AUTO_TAGGING | No | true | Whether automatic AI tagging is enabled or disabled. |
diff --git a/packages/shared/config.ts b/packages/shared/config.ts
index 4d7a9580..a05cfca0 100644
--- a/packages/shared/config.ts
+++ b/packages/shared/config.ts
@@ -105,7 +105,7 @@ const allEnv = z.object({
EMBEDDING_JOB_TIMEOUT_SEC: z.coerce.number().default(60),
INFERENCE_CONTEXT_LENGTH: z.coerce.number().default(2048),
INFERENCE_MAX_OUTPUT_TOKENS: z.coerce.number().default(2048),
- INFERENCE_USE_MAX_COMPLETION_TOKENS: stringBool("false"),
+ INFERENCE_USE_MAX_COMPLETION_TOKENS: optionalStringBool(),
INFERENCE_SUPPORTS_STRUCTURED_OUTPUT: optionalStringBool(),
INFERENCE_OUTPUT_SCHEMA: z
.enum(["structured", "json", "plain"])
@@ -350,7 +350,16 @@ const serverConfigSchema = allEnv.transform((val, ctx) => {
inferredTagLang: val.INFERENCE_LANG,
contextLength: val.INFERENCE_CONTEXT_LENGTH,
maxOutputTokens: val.INFERENCE_MAX_OUTPUT_TOKENS,
- useMaxCompletionTokens: val.INFERENCE_USE_MAX_COMPLETION_TOKENS,
+ // The new default model (5.6 series) requires this being set to true.
+ // So if someone explicitly sets it to false, we'll respect that. If
+ // someone using the default openai based configuration, we'll default
+ // to true.
+ useMaxCompletionTokens:
+ val.INFERENCE_USE_MAX_COMPLETION_TOKENS !== undefined
+ ? val.INFERENCE_USE_MAX_COMPLETION_TOKENS
+ : !val.OLLAMA_BASE_URL && !val.OPENAI_BASE_URL && !!val.OPENAI_API_KEY
+ ? true
+ : false,
outputSchema:
val.INFERENCE_SUPPORTS_STRUCTURED_OUTPUT !== undefined
? val.INFERENCE_SUPPORTS_STRUCTURED_OUTPUT