Repository navigation
Conversation
Guest chat accounts (is_guest, from Metering) hold a fraction of a cent. Metering refuses any request whose worst case the credit cannot cover, and by default that worst case is the model's whole context window. GuestPolicy keeps it small and honest: - only GUEST_MODELS (default deepseek/deepseek-v4.1-flash), never a router; - requests up to GUEST_MAX_REQUEST_BYTES (16 KiB), and the reservation's prompt bound is the bytes sent upstream plus template overhead; - output capped at GUEST_MAX_OUTPUT_TOKENS (1,024), written into the request so the provider enforces it too; - plain chat fields and text content only: tools, images, reasoning options and provider switches such as `thinking` are refused. A guest key without a configured policy is refused. Signed-in accounts are unaffected. Invalid settings stop the gateway at startup. See the Nexus repo's docs/guest-chat.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of guest chat: a landing-page visitor chats without signing up. Companion PRs: dappnode/dappnode-nexus (control plane, metering, UI) and dappnode/infrastructure (settings). The design is in dappnode-nexus
docs/guest-chat.md.What this changes
Guest accounts (Metering now returns
is_guest) hold a 1-cent credit. Metering refuses any request whose worst-case cost the credit can't cover, and by default that worst case is the model's whole context window: 1M tokens for Flash, far beyond any guest credit.services.GuestPolicymakes a guest request's worst case small and honest:GUEST_MODELS(defaultdeepseek/deepseek-v4.1-flash); never a router.GUEST_MAX_REQUEST_BYTES(16 KiB).max_input_tokens. Tokenizers emit at most one token per byte.GUEST_MAX_OUTPUT_TOKENS(1,024) and written into the request, so the provider enforces it too.reasoning_effortand provider switches such asthinkingget403 guest_not_allowed.Other behavior:
Deploy order
Deploy metering (dappnode-nexus) before or with this. Both directions are safe:
is_guestis absent, so guest accounts are treated as normal accounts. They then reserve the full context window, which their 1-cent credit can't cover, so they're refused.max_input_tokensisn't sent, so guest reservations again use the full window and fail closed.Tests
GuestPolicy: every refusal, the output cap rewrite and the prompt boundmax_input_tokens, readsis_guestgo test ./...,go vet ./...,GOOS=linux go vet -tags nitro_enclave ./...and gitleaks are clean.max_tokens: 100000produced exactly 1,024 tokens/v1/systemoneCodeQL
The two
go/allocation-size-overflowwarnings are in code this PR doesn't change:GatewayError.WithMeta(pkg/domain/error.go:66) and the Presidio adapter. This PR only adds new error constructors toerror.go.🤖 Generated with Claude Code