Skip to content

No warning when llama.cpp parallel slots leave too little context per request (HTTP 500 context exceeded) #641

Closed

Description

@opticon454

Bug

A custom llama.cpp model can fail every request with HTTP 500 "Context size has been exceeded" while Codeman gives no warning.

Steps to reproduce

  1. Add a custom llama.cpp (llama-swap) endpoint with the default parallel slots (4 on the build measured) and a ~131K context pool.
  2. Run a Claude Code session that starts parallel subagents.
  3. Concurrent ~40K-token requests all fail with HTTP 500; with --parallel 1 the same requests succeed.

Cause

llama-server's parallel slots share one context pool, so each slot gets only n_ctx / slots. Claude Code sends concurrent requests (main session plus each subagent, each ~40K tokens of system prompt and tools). The existing 40K floor check only looks at total context, so it never warns.

Status

Fixed, with tests, on branch feature/llamacpp-slot-aware-context in my fork. Not submitted as a PR yet: I'm at the open-PR limit and the fix is queued behind my current open PRs (#567, #592, #616, #617, #618). I'll open the PR as soon as a slot frees, or sooner if you'd like to lift the limit or take it directly from the branch.

Activity

  1. Ark0N commented on Oct 18, 2026

    @Ark0N
    Owner

    Thanks @opticon454, the measurement makes the cause clear: llama-server splits one context pool across its parallel slots, so the 40k floor check on the total says nothing about what one request gets once Claude Code runs a main session and subagents at the same time. A warning for that is welcome, so yes, please open the PR.

    One thing to settle in it, since I had a look at feature/llamacpp-slot-aware-context: for llama-swap endpoints the rule is that context is parsed from /running's cmd and never trusted from /props (CLAUDE.md, Custom Model Endpoint Profiles, and architecture-invariants#custom-model-endpoint-profiles). The branch reads n_ctx and total_slots from /props. I can see why for total_slots, since without an explicit --parallel only the server knows what it chose, but please keep /running's cmd as the source of truth for the context size, treat a /props value only as a hint that can raise the warning and never lower a floor or skip a confirmation, and say so in the docs where that rule is written. Also keep it a warning: confirmedSwap and confirmedContext stay separate flags.

    On the open-PR limit: drafts do not count toward it, so a draft is fine until a slot frees.

  2. Ark0N commented on Oct 22, 2026

    @Ark0N
    Owner

    Fixed by #658, which shipped in 1.44.0 (squashed as 33d697a). Discovery now records each llama.cpp model's parallel slot count, and a Claude launch warns when the context split across those slots leaves less than 40K tokens per request, naming the fix (--parallel 1, or a context large enough for every slot). Thanks again @opticon454 for the report with the cause already worked out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions