Skip to content

Complete WorkBuddy risk controls - #97

Merged
maiphucgiang merged 1 commit into
mainfrom
fix/workbuddy-risk-controls
Oct 26, 2026
Merged

maiphucgiang merged 1 commit into
mainfrom
fix/workbuddy-risk-controls

Conversation

@maiphucgiang

@maiphucgiang maiphucgiang commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Keep WorkBuddy channel refusals request-scoped: 11128 still gets the existing same-account /console detour, but a final refusal no longer cools any credential or triggers cross-account replay.
  • Add one bounded same-account system-to-user retry for residual 11128 refusals, preserving message blocks, tools and images and recording a dedicated attempt stage.
  • Complete the DSH channel adapter for the Web GUI fingerprint, including assistant quotations and text blocks, while leaving ordinary user/tool content unchanged.
  • Replace the generic 11140 cooldown path with a persisted two-hour restricted state. The credential page labels it as an official restriction and provides an appeal-release action; expiry and manual release rejoin routing and maintenance.
  • Reuse the existing automatic restriction metadata, so no control database schema migration is required. Update English/Chinese behavior docs and regression coverage.

Fixes #92

Summary by Sourcery

Harden WorkBuddy channel and account-risk handling while preserving same-account recovery paths and administrative visibility.

New Features:

  • Add a persisted two-hour WorkBuddy account restriction state for upstream 11140 errors, with automatic expiry and manual release support.
  • Add a bounded same-account retry that converts system instructions to user instructions after a residual 11128 channel refusal.
  • Complete DSH Web GUI fingerprint adaptation across supported assistant and text-block content.

Bug Fixes:

  • Prevent final 11128 refusals from cooling credentials or triggering cross-account replay.

Enhancements:

  • Expose restriction status and remaining duration in credential administration and provide an appeal-release action.
  • Reuse existing automatic restriction metadata so the new restriction lifecycle requires no control-store schema migration.

Documentation:

  • Update English and Chinese behavior documentation for channel refusals and account restrictions.

Tests:

  • Add regression coverage for restriction persistence and expiry, channel retry behavior, content preservation, and the credential release interface.

@sourcery-ai

sourcery-ai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Sorry @maiphucgiang, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 16 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR completes WorkBuddy risk controls by scoping 11128 handling to a single request and account, adding a bounded system-to-user retry and DSH Web GUI adaptation, and replacing 11140 account cooldowns with a persisted two-hour restriction that expires or can be released from the credentials UI.

Sequence diagram for bounded WorkBuddy channel refusal handling

sequenceDiagram
    participant Client
    participant Gateway
    participant Credential
    participant WorkBuddy

    Client->>Gateway: Chat request
    Gateway->>WorkBuddy: POST chat
    WorkBuddy-->>Gateway: 11128 channel refusal
    Gateway->>WorkBuddy: Retry same account via /console
    WorkBuddy-->>Gateway: 11128 channel refusal
    Gateway->>Gateway: system_as_user_body(body)
    Gateway->>WorkBuddy: Retry same account with system instructions as user
    alt Retry succeeds
        WorkBuddy-->>Gateway: 200 stream
        Gateway-->>Client: Response
    else Final refusal
        WorkBuddy-->>Gateway: 11128 refusal
        Gateway-->>Client: Upstream refusal
    end
Loading

Sequence diagram for persisted WorkBuddy account restriction

sequenceDiagram
    participant WorkBuddy
    participant CredentialPool
    participant ControlStore
    participant CredentialsUI
    participant Maintenance

    WorkBuddy-->>CredentialPool: 11140 restriction
    CredentialPool->>CredentialPool: note_restriction()
    CredentialPool->>ControlStore: _auto_disable(RESTRICTED_REASON)
    CredentialPool->>CredentialPool: Set restricted_until = now + 2 hours
    CredentialPool-->>CredentialsUI: restricted state and expiry
    CredentialsUI-->>CredentialPool: PATCH enabled=true
    CredentialPool->>ControlStore: set_credential(enabled=true)
    CredentialPool->>CredentialPool: release_restriction()
    CredentialPool-->>CredentialsUI: Credential rejoins routing
    Maintenance->>CredentialPool: expire_restrictions()
    CredentialPool->>CredentialPool: Release expired restrictions
Loading

File-Level Changes

Change Details Files
Make WorkBuddy channel refusals request-scoped and add a bounded same-account retry that relocates meaningful system instructions into user content.
  • Retain the existing same-account /console fallback for 11128.
  • Retry once after residual refusal by converting leading system instructions while preserving content blocks, tools, and images.
  • Record a dedicated retry stage and prevent final refusals from cooling credentials or triggering cross-account replay.
  • Add regression coverage for same-account routing, no cooldown, payload preservation, and idempotence.
app/desensitize.py
converter.py
tests/test_upstream_compat.py
tests/test_workbuddy_templates.py
Complete DSH-to-WorkBuddy channel adaptation for the Web GUI fingerprint across supported content forms.
  • Rewrite the confirmed Web GUI follow-up fingerprint in channel text.
  • Preserve existing behavior for ordinary user/tool content and unrelated references.
  • Cover the new fingerprint, including assistant quotations, in template tests and documentation.
app/desensitize.py
tests/test_workbuddy_templates.py
docs/advanced.md
docs/advanced.zh-CN.md
Replace 11140 cooldown/disable handling with a persisted, expiring official restriction lifecycle.
  • Persist restriction metadata and restore restricted state across restarts without a schema migration.
  • Apply a two-hour routing exclusion, expire it during maintenance, and clear cooldown/error state on release.
  • Expose restriction status and remaining time through the admin API and add coverage for persistence and expiry.
app/control_store.py
converter.py
app/admin_api.py
app/gateway_management.py
tests/test_credential_cooldowns.py
docs/advanced.md
docs/advanced.zh-CN.md
Expose official restriction status and an operator appeal-release action in the credentials UI.
  • Validate and render restricted credential state with an official 11140 label and countdown.
  • Provide a one-click release action that re-enables the credential and confirms the revision.
  • Add frontend regression coverage for the label and release request.
web/src/api.ts
web/src/pages/Credentials.tsx
web/src/values.tsx
web/src/enhancements.test.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@maiphucgiang
maiphucgiang merged commit 1d1bf7c into main Oct 26, 2026
7 checks passed
@maiphucgiang
maiphucgiang deleted the fix/workbuddy-risk-controls branch October 26, 2026 22:27
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.

deepseek-v4.1-flash 持续 11102 service info not found(同一账号官方客户端可用)

1 participant