Skip to content

feat(comment-automation): moderate comments with an ai router (jev) connection - #1745

Merged
sung17 merged 2 commits into
mainfrom
feat/comment-moderation-jev
Nov 18, 2026
Merged

sung17 merged 2 commits into
mainfrom
feat/comment-moderation-jev

Conversation

@sung17

@sung17 sung17 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

AI moderation on comment automations (Facebook, Instagram, Threads, TikTok) can now classify comments with an AI Router connection (Decision, e.g. Jev) instead of an AI agent's model. Categories, extra guidance, hide/delete and the moderation log work the same for both.

  • hideComments.aiModeration.engine: aiAgent or decision. If it is absent, the setting is treated as aiAgent, so every stored automation keeps working unchanged. The setting lives in a JSON column, so there is no migration.
  • The decision engine uses decisionConnectionId, decisionModel (one of the connection's modelCatalog) and decisionThreshold (0.5–0.99, default 0.7).
  • How Jev classifies: each selected category becomes one yes/no (noul) question keyed by the category name. A category is blocked when its probability is at or above the threshold. The comment is sent in state.currentMessage and marked as untrusted data, never as an instruction.
  • Log entry: Jev returns probabilities, not a sentence. So reason reads like AI Router jev-1.13.0: hate 92%, offensive 12%, provider is the connection's providerKind and modelId is the model.
  • Fails open: if the connection is missing, disabled or no longer lists the model, or the provider errors, the comment is not hidden and the reply goes ahead (same as the agent path). These results are not cached.
  • Verdict cache key: includes the engine's inputs (connection, model, threshold). The aiAgent key is unchanged, so verdicts cached across the deploy stay valid.
  • Write-time check: the service rejects a connection that belongs to another workspace, is disabled, or lacks the chosen model. This applies to every create/update path and to all four channels.
  • Templates: a connection holds the source workspace's API key, so it is never copied. When a template is installed, moderation on a decision engine is switched off, the connection is cleared, and the installer gets a credentialRequired warning.
  • API: the public comment-automation schemas share the partial, so the new fields show up in the public API, CLI and MCP with their descriptions. decisionConnections.list already exists. The builder gets a private decisionProfiles.listModerationConnections (enabled connections only, without credentials) for the form.
  • UI: the form has an "AI agent / AI Router (Jev)" choice, a connection picker, a model picker that follows the chosen connection, and a threshold slider. It shows an empty state with a link to AI Router settings, and a warning when the saved connection was deleted or turned off. New strings are added to all 21 message files.
  • Docs: docs/comment-automation.md and trap 23 of the comment-automation skill are updated.

Possibly an existing gap, not changed here: a template install copies aiModeration.aiAgentId as-is, so the installed automation points at the source workspace's agent. At runtime the lookup is scoped by workspace, so the agent is not found and moderation is skipped (no data leaks).

Test plan

  • pnpm lint
  • check-types for database, business, worker and builder (the pre-commit hook also ran it across 25 packages)
  • Full @chatbotx.io/business suite (10,088 passed) and worker suite (5,244 passed)
  • Builder: public-spec-operations, public-spec-mcp, api-parity-manifest, edge-instrumentation-graph, plus comment/moderation/decision tests
  • New tests:
    • schema: old rows read as aiAgent; decision requires a connection and model; threshold bounds
    • Jev question builder, including the instruction length limit
    • worker: blocks at or above the threshold; resumes below it; fails open on failed/unavailable; cache keys differ by engine, model and threshold
    • write-time connection checks
    • template install clears and disables the connection
  • invariant-guard agent: no violations
  • Manual: connect a Jev connection, turn on moderation with the Jev engine, then post an offensive comment and a polite one

🤖 Generated with Claude Code

…onnection

AI moderation can now run on an AI Router (Decision) connection such as Jev
instead of an AI agent's model. `hideComments.aiModeration.engine` picks
`aiAgent` (default, and what every stored row reads as) or `decision`, with
`decisionConnectionId`, `decisionModel` and `decisionThreshold` (0.5-0.99,
default 0.7).

The decision engine asks one yes/no question per selected category and
flags those whose probability reaches the threshold. Failures and missing or
disabled connections fail open, like the agent path. Writes check that the
connection belongs to the workspace, is enabled and lists the model; a
template install switches it off and clears the connection with a
credentialRequired warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feature New feature or request label Nov 18, 2026
- Keep the connection picker rendered when none is enabled so the
  required error shows on save instead of failing silently.
- Cap AI Router guidance at 500 characters in the schema and stop
  truncating it, so every question carries the full guidance.
- Align the threshold range to 0.5–0.95 across schema, docs and slider.
- Do not mark the form dirty when a stale model is swapped on load.
- Document the decision engine fields in the CLI README and schema.
- Share one usable-connection check between classify and the write check.
- Move the enabled-connections picker endpoint to decision-connections
  (decisionConnectionsAPI.listEnabled), reading through the existing query.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sung17
sung17 merged commit 2cf3a77 into main Nov 18, 2026
14 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
…onnection (#1745)

* feat(comment-automation): moderate comments with an ai router (jev) connection

AI moderation can now run on an AI Router (Decision) connection such as Jev
instead of an AI agent's model. `hideComments.aiModeration.engine` picks
`aiAgent` (default, and what every stored row reads as) or `decision`, with
`decisionConnectionId`, `decisionModel` and `decisionThreshold` (0.5-0.99,
default 0.7).

The decision engine asks one yes/no question per selected category and
flags those whose probability reaches the threshold. Failures and missing or
disabled connections fail open, like the agent path. Writes check that the
connection belongs to the workspace, is enabled and lists the model; a
template install switches it off and clears the connection with a
credentialRequired warning.

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

* fix(comment-automation): address ai router moderation review findings

- Keep the connection picker rendered when none is enabled so the
  required error shows on save instead of failing silently.
- Cap AI Router guidance at 500 characters in the schema and stop
  truncating it, so every question carries the full guidance.
- Align the threshold range to 0.5–0.95 across schema, docs and slider.
- Do not mark the form dirty when a stale model is swapped on load.
- Document the decision engine fields in the CLI README and schema.
- Share one usable-connection check between classify and the write check.
- Move the enabled-connections picker endpoint to decision-connections
  (decisionConnectionsAPI.listEnabled), reading through the existing query.

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

---------

Co-authored-by: Deathgiver <[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

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant