Skip to content

org: a chat at its spending limit reads the organization's sentence, not a payment failure - #2936

Merged
AbirAbbas merged 5 commits into
org/mainfrom
org/cap-refusal-words
Nov 25, 2026
Merged

AbirAbbas merged 5 commits into
org/mainfrom
org/cap-refusal-words

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

A hosted chat whose organization limit was reached read:

openrouter accepted the key but the account cannot pay — This chat has reached its spending limit of $0.00, so it is paused. Start a new chat to carry on.

  1. The organization's model door refuses with an HTTP 402 shaped like a provider's, so the client classified it as OutcomeAccountCannotPay and put the service name and "accepted the key but the account cannot pay" in front of the organization's own sentence.
  2. A cap of 0.001 was printed as $0.00.

The change

  • The door signs every error it writes with "door":"organization" in the error envelope (provider.DoorKey / provider.OrganizationDoor, one spelling shared by server and client). The client reads that field, never the sentence. A provider's refusal passed through the door is not signed.
  • APIError.OrgLimitWords() returns the door's sentence for its payment-shaped refusals only. The engine's ending (internal/session/loop.go) and the page's failure line (internal/tui3/feed.go) show it as written. The org limit no longer triggers a read of the person's own OpenRouter credits.
  • The limit sentences write the number it is: whole cents keep two places ($5.00, $0.50), anything finer is spelled by teams.Money ($0.001). Zero stays $0.00.
  • Retry, hedge, route and spend behaviour is untouched: the refusal is still terminal everywhere (AccountCannotPay, OurRequest, RoutePayment unchanged). The monthly limit refusal had the same defect and is fixed the same way.
  • Manual page organization-hosted-sessions.md gets a section (and a search probe) saying the limit lines are the organization's own words, not an OpenRouter credit problem.

Validation contract and tests

  1. The door's cap refusal reads exactly the door's sentence, end to end through the real handler over a socket and a real engine turn: TestAHostedChatAtItsSpendingLimitReadsTheOrganizationsSentenceAndNothingElse, TestAHostedChatAtTheMonthlyLimitReadsTheOrganizationsSentenceAndNothingElse (serve). The page's line from the same real turn: TestAChatAtTheOrganizationsLimitDrawsOnlyTheOrganizationsSentence (tui3). Both fail on the base with the exact line from the report.
  2. A genuine provider 402 still reads as today: TestAProvidersOwnPaymentRefusalThroughTheDoorStillReadsAsAnAccountThatCannotPay (through the door), TestAProvidersOwnPaymentRefusalStillNamesTheServiceAndTheAccount (tui3), TestOnlyTheOrganizationsDoorIsReadAsTheOrganizationSpeaking (provider: a provider's insufficient_quota is not the mark). The existing payment-note and plan-door tests pass unchanged.
  3. Caps read $0.001, $0.50, $2.00, zero stays $0.00: TestALimitIsWrittenAsTheNumberItIs, TestEveryErrorTheDoorWritesIsSignedAndOnlyThoseItWrites (serve; real handler at cap 0.5 reads $0.50).
  4. Nothing else changes: TestTheDoorsLimitIsStillTerminalForEveryReaderOfARefusal, TestTheOrganizationsLimitDoesNotSendAReadOfThePersonsOwnCredits, and the field-name pin TestTheDoorsFieldIsTheOneTheClientDecodes.

Gates

make pr-ready BASE=origin/org/main passed on the final commit (build, vet, Windows vet, packed manual, change entries, manual gates, laws, touched packages: serve, provider, session, tui3, manual, cmd).

Note

Over the engine wire the typed refusal becomes plain text, so a remote TUI draws the same sentence under its ordinary error: label for untyped endings; the service name and the payment wording are gone there too.

🤖 Generated with Claude Code

AbirAbbas and others added 5 commits November 25, 2026 12:25
A refusal from the organization's model door is shaped like a provider's, so a
client could not tell the organization's own sentence from a service's failing
account. The error envelope now has a `door` field, and a refusal carrying
`door: organization` is flagged on the APIError, with OrgLimitWords giving the
organization's sentence for the limit refusals (402, payment-shaped) and false
for every other refusal. Terminal handling of the refusal is untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…number it is

Every error the organization's model door writes now carries the `door` mark, so
a client can show its sentence as written. A provider's refusal passed through
the door is not signed and keeps its own wording. The limit sentences wrote every
cap with two decimals, so a limit of a tenth of a cent read "$0.00"; a whole
number of cents keeps two places ($5.00, $0.50), anything finer is spelled by the
one door that spells a cap (teams.Money: $0.001).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s sentence

The engine's ending and the page's failure line put "<service> accepted the key
but the account cannot pay" in front of a door's limit sentence, blaming the
vendor and the person's account for a limit the organization set. A refusal the
organization's door signed is now shown as the door wrote it, with no service
name, and it no longer asks for a read of the person's own OpenRouter credits.
A provider's own payment refusal reads exactly as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AbirAbbas
AbirAbbas merged commit 4e39da4 into org/main Nov 25, 2026
9 checks passed
@AbirAbbas
AbirAbbas deleted the org/cap-refusal-words branch November 25, 2026 18:04
AbirAbbas added a commit that referenced this pull request Nov 25, 2026
…ack (#2903)

The hosted organisation line: a team-mode org server deciding every request through one access model (verbs, roles, grants and policy in SQLite), hosted chats run by the sessionhost under a per-chat uid inside a Landlock fence with minted model bearers, sealed keys and a git helper, shared chats acting through verbs, bots owned by their creator, the Hosting and chats policy settings, and a self-hosting stack (deploy/org Docker Compose, published images behind a leak gate, a Railway path).

Consolidates #2894 #2895 #2896 #2898 #2899 #2900 and the follow-ups #2904 #2905 #2907 #2908 #2910 #2911 #2912 #2913 #2915 #2916 #2918 #2927 #2936 #2944. Proven by the full suite, a keyless Compose smoke, a hostile wire client, sandbox escape probes, a real-model run and a production-style install from the published images.

Co-Authored-By: Santosh kumar <[email protected]>
Co-Authored-By: ZeroPoint95 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant