Skip to content

feat(chat): let an Admin choose who starts agent work, kept with who changed it and when (AC-011, 00481) - #2147

Merged
gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/ac-011-agent-work
Nov 6, 2026
Merged

gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/ac-011-agent-work

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

AC-011 part 2: the Agent work setting from ROADMAP-plan §06 (Drive › Ansvisor Product Developments › Diğer › ROADMAP-plan.md, decision 2 of 2026-10-22). The mockup is ROADMAP-mockup.html screen 3, the gear and its panel.

Stacked on #2146 (the Today card). Merge #2146 first; this diff then shrinks to its own commits: 24d2d03, b8579d7, f7e5c82 and c14b9b8. The other commits are merges of that branch.

What the person sees

  • The gear: Agent work sits at the right of the header of Action Center › Today. It shows only where Chat is on, because these are Chat's agents. It opens "Who starts agent work?" with two choices:
    • I approve first: every change an agent makes waits for someone's approval, whatever the agent's mode. This is the default, and every workspace starts here.
    • Agent starts on its own: each agent works in its own mode: Ask me first, Auto or Full auto (Full auto still Growth and up).
  • The panel: it says that neither choice changes going live. Under the choices it shows "Changed by {name} · {date}", or "Not changed yet: every workspace starts on I approve first."
  • Who can change it: Admins pick and Save. Everyone else sees the panel read-only, with "Only Admins change this." On an ended plan, saving answers with the plan message, and in Settings › Chat it opens the upgrade dialog.
  • Settings › Chat: the same panel, as a new Agent work section after the switches, where the other workspace switches live.

How it fits the Chat agent modes
The setting is a workspace ceiling on agent autonomy. It is applied inside the approval precedence, with no second gate. This is the coordinator's proposal; see the open questions.

  • I approve first:
    • In precedence.ts step 5, an agent's run on I approve first gets ask('agent_work') for every WRITE. ctx.agentRun marks an agent's run; readPrecedenceContext sets it when the engine passes the run's agent.
    • The check sits beside Ask me first and before the policy and mode steps. So Auto, Full auto, "Don't ask again" and an Admin's Always all ask too.
  • Untouched by the setting:
    • a person's own chat;
    • READs, refusals and EXECUTE clicks;
    • step 4b, an allowed agent going live on its own. Going live stays under the go-live switches and a person's click.
  • Agent starts on its own changes nothing: each agent's mode applies as on main, including agentModeNow and Full auto for agents.
  • Before 00481 is applied: readPrecedenceContext reads agent_work in its own query, so the rest of the context still reads, and agents ask first (the default). A value it doesn't recognise counts as I approve first.

The change log

  • setAgentWork (Admins only, active plan) writes only chat_settings.agent_work, so the other settings keep their values.
  • It then inserts a setting_changes row: key agent_work, the old value (null when never set), the new value, changed_by and changed_at.
  • If that row can't be written, the old value goes back and the save fails. The setting never moves without its record.
  • Saving the value already in place writes nothing.
  • getAgentWorkView and Settings › Chat's view read the last change, with the person's name, or else their e-mail.

Migration 00481 (needs-migration)

  • chat_settings.agent_work text not null default 'approve_first', with a check allowing approve_first and auto_start.
  • A new setting_changes table:
    • columns: id, organization, key (format check), old and new value (length checks), changed_by (on delete set null), changed_at;
    • an index on (organization, key, changed_at desc);
    • RLS: workspace members read their workspace's rows; only the service role writes. These are the same grants and policy as chat_settings (00401).
    • No brand_id, so the demo coverage list doesn't apply.
  • supabase/schema.sql is rebuilt. web/src/types/supabase.ts is updated by hand.

Help

  • help/action-center/action-center-actions.md: a new Agent work section.
  • help/chat/agents.md: a new section, Agent work: who starts agent work.
  • help/settings/chat-rules.md: a new Agent work section.
  • Keywords updated, and approved-articles.json regenerated.

Tests

  • Precedence:
    • the ceiling in every mode, and Always asks too;
    • the default when the value is absent or unknown;
    • Agent starts on its own equals the agent's own mode;
    • untouched: a person's chat, reads, clicks and refusals; go-live still runs.
  • Context: the read; agentRun; before 00481; a failed read.
  • Actions:
    • the view and the last change;
    • Admin-only, a read-only plan, invalid choices;
    • the log row's fields;
    • a no-op when unchanged;
    • rollback when the log fails;
    • before 00481.
  • UI:
    • Settings › Chat: the Admin saves, others see it read-only, "Changed by …";
    • the gear: hidden with Chat off, saving, the failure message;
    • the gear in the Today card (page test).
  • Engine: the agent-run tests now set agent_work: 'auto_start' where they mean "the agent's own mode", plus one test for the default.

Related issue

None. AC-011 (ROADMAP-plan §06, decision 2), part 2. The owner first dropped this setting, then asked for it on 2026-11-05.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Apply migration 00481 (needs-migration). Until it is applied, the gear and the section show the default, and saving says "isn't available yet". Chat keeps working, with agents asking first.
  2. With Chat on, open Action Center › Actions. Agent work is in the Today card's header and reads I approve first, "Not changed yet".
  3. Run an agent in Full auto that drafts content. Its change waits in Needs you with an approval card.
  4. As an Admin, pick Agent starts on its own and Save:
    • the panel says "Changed by {you} · {today}";
    • setting_changes has the row (agent_work, null → auto_start, you, now);
    • run the agent again, and Full auto makes the change.
  5. As a Manager or Analyst, the panel is read-only. A direct call to setAgentWork answers forbidden.
  6. Settings › Chat shows the same setting in its Agent work section.
  7. An agent allowed to publish on its own (CHAT_AUTO_GO_LIVE) still goes live with either choice.
  8. Tests: cd web && npx vitest run src/lib/chat/precedence.test.ts src/lib/chat/precedence-context.test.ts src/lib/chat/engine.test.ts src/lib/actions/chat-settings.test.ts src/components/chat-access/chat-settings-section.test.tsx src/components/action-center/agent-work-gear.test.tsx "src/app/[locale]/(dashboard)/dashboard/action-center/actions/page.test.tsx" src/lib/help

Checklist

Checks run locally on this branch, using CI's jobs:

  • schema: supabase/build-schema.sh leaves schema.sql as committed. version:check passes.

  • web, first full run: format:check, lint, typecheck and build pass. yarn test passed 986 of 990 files (10,624 tests). Five tests failed, all fixed in f7e5c82 and c14b9b8:

    • the read-only coverage list needed setAgentWork (2 tests);
    • Settings › Chat's read-only test expects no radiogroup for non-Admins, so the panel now uses a fieldset;
    • the agents' test set's workspace now runs agents on Agent starts on its own;
    • the precedence context's read count now includes the Agent work read.
  • web reruns: the changed suites pass.

    • 9 files, 217 tests: precedence, context, settings, Settings › Chat, the gear, coverage, Help.
    • Then the agents' test set and the engine: 2 files, 303 tests.
  • server, first full run: format:check and lint pass. npm test passed 418 of 421 files:

    • brand-access-policies needed setting_changes on its Account-level list (fixed in f7e5c82);
    • two timing tests (content-people, traffic-events "fast") ran over their wall-clock limits on a busy machine. This PR doesn't touch either.

    The rerun of those files, together with today and content-agent, passes: 5 files, 188 tests.

  • After the last edits: web format:check, lint and typecheck, and server format:check and lint, pass again.

Open questions for the owner

  1. How Agent work maps to Chat's modes. This PR builds the coordinator's proposal: a workspace ceiling. I approve first makes every agent run ask before each change, as Ask me first does. Agent starts on its own lets each agent's mode apply. Going live is never affected. Is that the meaning you want?
  2. Agents starting from Today. The spec's "Agent starts on its own: items set to Agent start when they reach Today" is not built. Today's Me/Agent/Team label is read-only (feat(action-center): show what to do today, the Next 7 and what was done this week (AC-011) #2146), and agents start from their own triggers, as now. Should a later PR start an agent when its item reaches Today?
  3. Existing workspaces also start on I approve first. The column's default and a missing row both mean I approve first. So agents that ran in Auto or Full auto will ask before each change until an Admin picks "Agent starts on its own". This matches the owner's launch decision that every change needs a person's approval, and Chat is still behind CHAT_AGENTIC. Should 00481 instead backfill auto_start for workspaces that already have agents?
  4. Going live under I approve first. An agent an Admin allowed to publish on its own still does. At launch that switch stays off (CHAT_AUTO_GO_LIVE). Should I approve first also hold it once it's on?
  5. The log table. It is a general setting_changes (key, old, new, who, when); only agent_work is written today. Should other workspace switches (Full auto for members, go-live) log there too, in a later PR?

Generated by Claude Code

…changed it and when (AC-011, 00481)

ROADMAP-plan §06's "Agent work" (mockup screen 3): a gear on Action
Center › Today, and the same panel in Settings › Chat.

- I approve first (the default, every workspace starts on it): every change
  an agent's run makes asks for approval, whatever the agent's mode. The
  approval precedence applies it in step 5, beside Ask me first, so there is
  no second gate; Admin's Always asks too. Going live (step 4b) and reads,
  refusals and clicks are untouched.
- Agent starts on its own: each agent's own mode applies, as today.
- Admins only; members read it with its last change ("Changed by … ·
  date"). Each change is kept in setting_changes (key, old value, new
  value, changed_by, changed_at); one that can't be kept is undone.

Migration 00481 adds chat_settings.agent_work (default approve_first) and
setting_changes (members read their workspace's rows, the server writes).
The web reads agent_work on its own, so a database before 00481 keeps
working, with agents asking first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…own, and ask on the default

The engine's agent-run tests set Agent work to auto_start, as "the agent's
mode" means since 00481, and a new one checks that an agent in Full auto
asks for its change on I approve first, the default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…ect them, and copy its Help

- setAgentWork goes on the read-only coverage's open list with the other
  Admin settings: asAdmin() checks the plan itself and answers read_only.
- setting_changes is the Account's, no brand's data (brand access list).
- The panel groups its two choices in a fieldset, so Settings › Chat's
  policy pickers stay its only radiogroups.
- The agents' test set runs each agent in its own mode: its workspace is on
  Agent starts on its own.
- The precedence's read test counts the Agent work read beside the settings.
- approved-articles.json regenerated (yarn test -u src/lib/help).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
… with every default

A row the database writes carries every column's default; the test set's
had only Agent work, so its Full auto agents read Full auto for agents as
off and never started.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Nov 5, 2026

@gkhngyk gkhngyk 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.

LGTM.

gkhngyk
gkhngyk previously approved these changes Nov 5, 2026

@gkhngyk gkhngyk 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.

LGTM.

Main brought ansvisor#2137 (00480) and ansvisor#2143. schema.sql is rebuilt with
build-schema.sh (00480 then 00481). help/chat/agents.md's front matter
keeps both keyword and synonym lists (Agent work's and Onboarding's).
approved-articles.json regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@gkhngyk gkhngyk 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.

LGTM.

gkhngyk
gkhngyk previously approved these changes Nov 5, 2026

@gkhngyk gkhngyk 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.

LGTM.

cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 5, 2026
…t (AC-011)

When ansvisor#2147 ships, Agent work starts every workspace on "I approve first",
so agents that run in Auto or Full auto today will wait for a person
before each change. This entry tells people why, and how an Admin lets
agents start work on their own again. It is held back (published
2099-12-31) and not approved until ansvisor#2147 is on main and Cihan approves it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMenyNyxsr2Doq4CaQ3

@gkhngyk gkhngyk 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.

LGTM.

gkhngyk
gkhngyk previously approved these changes Nov 5, 2026

@gkhngyk gkhngyk 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.

LGTM.

gkhngyk pushed a commit that referenced this pull request Nov 5, 2026
…t (AC-011) (#2152)

* docs(help): approve the last 14 Help articles so Chat answers from them

Cihan approved them on 2026-11-05, ahead of Chat's launch: Chat answers
how-to questions only from approved articles (CHAT-19 §4).
approved-articles.json regenerated with yarn test -u src/lib/help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMenyNyxsr2Doq4CaQ3

* docs(chat): add a What's new entry telling people agents now ask first (AC-011)

When #2147 ships, Agent work starts every workspace on "I approve first",
so agents that run in Auto or Full auto today will wait for a person
before each change. This entry tells people why, and how an Admin lets
agents start work on their own again. It is held back (published
2099-12-31) and not approved until #2147 is on main and Cihan approves it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMenyNyxsr2Doq4CaQ3

---------

Co-authored-by: Claude <[email protected]>
gkhngyk
gkhngyk previously approved these changes Nov 5, 2026

@gkhngyk gkhngyk 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.

LGTM.

…t-work

# Conflicts:
#	help/chat/agents.md
#	web/src/lib/help/approved-articles.json
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main in after #2179/#2180: help/chat/agents.md keeps both sides' keywords, and approved-articles.json is regenerated from the article (Help tests pass).

@gkhngyk gkhngyk 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.

LGTM.

@gkhngyk
gkhngyk merged commit c870c48 into ansvisor:main Nov 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants