Repository navigation
fix(llm): honor max_tokens_field in the connection test - #573
Merged
BaaRai merged 15 commits intoNov 26, 2026
Merged
Conversation
POST /api/assets decoded with json.NewDecoder directly. A multipart Content-Type skips the JSON body middleware, so that request was uncapped. Decode through the shared limit first and answer 413 before touching the database.
The Test button on System -> LLM always sent the output cap as max_tokens, because POST /api/llm/test never read the profile's max_tokens_field. OpenAI reasoning models (o-series, GPT-5) reject max_tokens with unsupported_parameter, so a profile set to max_completion_tokens failed the test with HTTP 400 while conversations with the same profile worked. testLLM now accepts max_tokens_field from the form and falls back to the stored profile's value when the field is omitted (list-view test). It is normalized like profile saves: only the openai format with max_completion_tokens keeps it. The form passes its current selection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Username/password was offered to any client and accepted any credentials, so a non-loopback client bypassed the loopback-only rule applied to no-auth by offering method 0x02. Credentials are never verified, so both methods are now accepted from loopback clients only; any other client gets 0xFF.
renderTemplate replaced placeholders param by param, so a value containing
another placeholder was expanded again inside the first value's shell
quotes: a="{b}", b="; id" rendered {a} as ''; id'' and ran id. Whether it
happened depended on map iteration order. Scan the template once and never
rescan substituted values.
limitRequestBody skipped every request with a multipart Content-Type, so any handler decoding JSON straight from r.Body (about 30 of them) read an unbounded body when the client simply labelled the request multipart. Multipart bodies now get an upload-sized cap (the largest limit an upload handler sets); upload handlers keep their own tighter limits and messages.
…example The host filter description showed a real routable IP (107.172.96.177) to the model as its example. Use 192.0.2.10 from TEST-NET-1 (RFC 5737) so the example cannot prime the agent toward a third-party host.
Contributor
|
Review notes Looks good to merge. Small request: the other fix PRs add a CHANGELOG entry; this one doesn't yet. |
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Contributor
Author
|
Added a CHANGELOG entry under |
BaaRai
force-pushed
the
fix/llm-test-max-completion-tokens
branch
from
November 26, 2026 22:24
10ee740 to
d64c8fe
Compare
BaaRai
added a commit
to Coff0xc/ARTEX-contrib
that referenced
this pull request
Nov 26, 2026
BaaRai
force-pushed
the
fix/llm-test-max-completion-tokens
branch
from
November 26, 2026 22:40
d64c8fe to
c63262f
Compare
BaaRai
added a commit
to Coff0xc/ARTEX-contrib
that referenced
this pull request
Nov 26, 2026
fix: custom-tool injection, SOCKS5 open proxy, multipart body cap, example IP
fix(server): cap insert_assets request bodies
# Conflicts: # CHANGELOG.md
BaaRai
added a commit
to Coff0xc/ARTEX-contrib
that referenced
this pull request
Nov 26, 2026
Owner
|
Merged, thanks @gabrimarch3. Rebased on current main and verified with its tests and negative control. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On System → LLM, a profile with format OpenAI and max tokens field set to
max_completion_tokensfails the Test button against OpenAI reasoning models (o-series / GPT-5):Conversations and tasks with the same profile work: the runtime path copies
MaxTokensFieldfrom the profile intoagent.Config, butPOST /api/llm/testnever read it.TestConnectionalways setsMaxTokens: 8192, so the test request carried the cap under the defaultmax_tokenskey.Change
server/server.go(testLLM): accept an optionalmax_tokens_field. When the request omits it (the list-view test sends onlyprofile_id), use the stored profile's value. Normalize it the same way profile saves do: only formatopenaiwithmax_completion_tokenskeeps it; anything else becomes""(max_tokens).web/src/lib/api.ts,web/src/app/(main)/system/llm/page.tsx: the form sends its current selection, so an unsaved change is tested as shown.Other formats are unaffected: anthropic and openai-responses hard-code their field names, and the value is cleared for them.
Tests
server/llm_test_max_tokens_field_test.go, against a fake OpenAI endpoint. It asserts which key the request body carries in four cases: form value, stored-profile fallback, explicit empty form value overriding the stored choice, and an unknown value falling back tomax_tokens. It fails onmain: the body carriesmax_tokensinstead ofmax_completion_tokens.go vet ./server/is clean. The existingTestLLMTest*tests pass.go test ./server/with Postgres passes, except the six*AsRootisolation tests. Those fail identically on unmodifiedmainin my environment (run as root in agolangcontainer on macOS/OrbStack), so they are unrelated to this change.tsc --noEmitis clean.biome linton the touched files reports only warnings that already exist onmain.Not run: a live test against the OpenAI API.
🤖 Generated with Claude Code