Skip to content

fix(usage): list service accounts in usage monitoring (OHE-4159) - #1405

Merged
hieptl merged 1 commit into
mainfrom
hiep/ohe-4159-bug-service-account-automation-usage-is-hidden
Nov 18, 2026
Merged

hieptl merged 1 commit into
mainfrom
hiep/ohe-4159-bug-service-account-automation-usage-is-hidden

Conversation

@hieptl

@hieptl hieptl commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

An automation that runs as a service account is attributed to that account, but Usage Monitoring leaves service accounts out of the Users tab and out of the per-user team usage. Their spend still counts in the organization totals, so the user rows do not add up to the totals, and an admin cannot see which service account spent it.

The per-user queries in OrgConversationService filter on User.account_type == 'human'. #1049 added that filter because a service account has no email or login and showed as "Unknown". A service account does have a display_name, and the budget rows already use it.

Summary

  • The Users tab and the team_usage list of GET /api/organizations/{org_id}/conversations/usage now include service accounts. A row is named by the account's display name and carries account_type (human or service).
  • In the Users tab, a service account shows Service account under its name, where a person's email goes.
  • Rows for people and the organization totals are unchanged. A disabled service account keeps its past usage.

Issue Number

OHE-4159

How to Test

Unit tests:

uv run pytest tests/unit/test_org_conversation_usage_models.py
cd frontend && npx vitest run __tests__/components/features/admin-dashboard/usage-dashboard-tabs.test.tsx

Manual steps:

  1. In Settings > Service Accounts, create a service account such as nightly-report.
  2. Create an automation that runs as it, and run it.
  3. Open Settings > Usage Monitoring > Users. nightly-report has a row marked Service account, with its conversation count and spend.
  4. Disable the service account and reload. The row is still there.

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

Video/Screenshots

N/A. The Users tab gains one row per service account, with Service account in place of the email.

Type

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

Notes

  • API. team_usage rows and user-usage rows gain account_type. active_users now counts a service account that has usage, and team_usage[].percentage is a share that includes service accounts. The settings UI renders neither field.
  • Overview tab. It has no per-user breakdown today, so the team_usage change shows only in the API response.
  • Super Admin dashboard. Its Users tab uses the same route and component, so it lists service accounts too.
  • Names for people. user_name is still the git name for a person. Only a service account has a display_name.
  • Not in this PR. The Conversations tab still shows Unknown for a service account's conversations, because that response carries only the email.
  • No migration. user.account_type and user.display_name already exist.

Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-359dda1

An automation that runs as a service account is attributed to that
account, but the Users tab of Usage Monitoring and the per-user team
usage left service accounts out. Their spend still counted in the
organization totals, so the per-user rows did not add up to the totals
and an admin could not see which service account had spent it.

#1049 left them out because a service account has no email or login and
showed as "Unknown". It does have a display name, and the budget rows
already use it.

The per-user usage queries no longer filter on the account type. A row
is named by the account's display name, then the git name, and carries
account_type. The Users tab shows "Service account" under the name,
where a person's email goes. Rows for people are unchanged, and so are
the organization totals.

The usage tests now expect a service account in both lists, through the
ledger and the legacy query, and cover a disabled account and the Users
tab label.
@github-actions github-actions Bot added the type: fix A bug fix label Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  server/routes
  org_models.py
  server/services
  org_conversation_service.py 143
Project Total  

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

@hieptl
hieptl marked this pull request as ready for review November 17, 2026 02:36

@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 8ed9cf6 into main Nov 18, 2026
30 checks passed
@hieptl
hieptl deleted the hiep/ohe-4159-bug-service-account-automation-usage-is-hidden branch November 18, 2026 11:35
@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: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants