Skip to content

feat(licensing): limit conversations on an unlicensed install (OHE-4179) - #1406

Merged
hieptl merged 1 commit into
mainfrom
hiep/ohe-4179-license-enforcement-unlicensed-mode
Nov 18, 2026
Merged

hieptl merged 1 commit into
mainfrom
hiep/ohe-4179-license-enforcement-unlicensed-mode

Conversation

@hieptl

@hieptl hieptl commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

With license enforcement on, an install without a valid license is held to one user and one organization, but nothing limits its conversations. Any of its users can start any number of them, from Canvas, the API, a resolver or an automation.

OHE-4179 asks that an unlicensed install (installed with no license, or a trial that ended) gets a lifetime limit on conversations, and that only its first Super Admin can start them.

Summary

  • An install without a valid license can start 50 conversations in its lifetime, and only its first Super Admin (instance_settings.setup_user_id) can start them. An install with no first Super Admin on record lets any Super Admin. Every conversation row counts, deleted ones included, which is the total the usage report sends Customer Center.
  • The check runs in LiveStatusAppConversationService, which every start goes through (Canvas, API keys, resolvers, Slack, Jira, child conversations, preset automations), and at POST /api/v1/sandboxes, because a client that starts a sandbox there (a custom automation, the SDK) starts its conversations on the sandbox itself.
  • A refusal is a 402 with detail: {"error": "LICENSE_LIMIT_REACHED", "message": "<reason>"}. Canvas shows the message, and the automation service reads the code to skip the run (feat(dispatcher): skip runs the install's license does not allow (OHE-4179) automation#763).

Issue Number

OHE-4179

How to Test

Unit tests:

uv run pytest tests/unit/server/licensing tests/unit/app_server/test_sandbox_router.py tests/unit/app_server/test_live_status_app_conversation_service.py

Manual steps:

  1. Start OHE with LICENSE_ENFORCEMENT_ENABLED unset and no license. Finish the install wizard as the first Super Admin, and add a second user.
  2. Set LICENSE_ENFORCEMENT_ENABLED=true and restart. Canvas shows the banner about the missing license key.
  3. As the first Super Admin, start a conversation in Canvas. It starts.
  4. As the second user, start a conversation. Canvas shows "Without a valid license, only the first Super Admin can start conversations."
  5. Once the install has 50 conversations, start one as the first Super Admin. Canvas shows "Without a valid license, this install can start 50 conversations, and it has used them all." An automation run is refused too.
  6. Save a valid license under Super Admin > License. Both users can start conversations again.

Only the unit tests were run. The manual steps were not run.

Video/Screenshots

N/A. Nothing new in the UI: Canvas shows the reason where it shows any other error from starting a conversation.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

  • No effect while enforcement is off, while the first license check is pending, or with a valid license. The per-month limits.conversations of a license is still not enforced.
  • Existing installs. An unlicensed install that already has 50 conversations can start no more once enforcement is on. That includes an install whose trial ended, and one that has had no trusted answer from Customer Center since the last one expired.
  • Not a hard guarantee, like the user and organization limits. Two starts at the same moment can both pass, and deleting a user or an organization deletes their conversation rows, which lowers the count.
  • Status code. 402 with a code, and not the 403 the user and organization limits answer with: the automation service takes a 403 for an expired API key, retries with a new key and drops the reason.
  • Automation service. Until feat(dispatcher): skip runs the install's license does not allow (OHE-4179) automation#763 is in the automation image an install runs, a refused run fails there with "Failed to get execution context" and is not skipped with the reason.
  • Not blocked. Resuming an existing sandbox and starting conversations on it directly. POST /api/v1/app-conversations/stream-start has already answered 200 when the start is refused, so its stream breaks; nothing in Canvas, the automation service or the SDK calls that route.
  • Banner. Unchanged. Canvas and the settings pages already show one for a missing, expired, invalid or unverified license.
  • Messages are in English only.

Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-195e2ed

With license enforcement on, an install without a valid license (no
license, an ended trial, or a license that can no longer be verified)
was held to one user and one organization, but any of its users could
start any number of conversations.

Such an install now:

- can start 50 conversations in its lifetime. Deleted conversations
  still count.
- lets only its first Super Admin start them. An install with no first
  Super Admin on record lets any Super Admin.

The check runs where a conversation starts, and where a client starts a
sandbox through the API, because such a client starts its conversations
on the sandbox itself. A refusal is a 402 with the error
LICENSE_LIMIT_REACHED and the reason, which the automation service reads
to mark the run skipped.

Nothing changes while enforcement is off, while the first license check
is pending, or with a valid license.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  openhands/app_server/app_conversation
  live_status_app_conversation_service.py 819
  openhands/app_server/sandbox
  sandbox_router.py 126-130
  server/licensing
  limits.py
  service.py
Project Total  

This report was generated by python-coverage-comment-action

@hieptl hieptl self-assigned this Nov 17, 2026
@hieptl
hieptl marked this pull request as ready for review November 17, 2026 02:35

@tofarr tofarr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

@hieptl
hieptl merged commit cc19475 into main Nov 18, 2026
28 checks passed
@hieptl
hieptl deleted the hiep/ohe-4179-license-enforcement-unlicensed-mode branch November 18, 2026 11:34
@openhands-release-bot openhands-release-bot Bot added the released: 1.95.0 Shipped in 1.95.0 label Nov 19, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.95.0.

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

Labels

released: 1.95.0 Shipped in 1.95.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants