Skip to content

feat(chat): let a run with no session make a session-free change as its person - #1972

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feat/chat-session-free-engine
Nov 2, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:feat/chat-session-free-engine

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Chat's agent runs with no session behind them can now create and change content drafts without a card, when the run's mode and policies allow it. Builds on #1946 (such runs ask before every change) and #1959 (the session-free draft writers). Owner decision 2026-11-01: "İkisi de, sırayla".

What changes

  • Only create_draft and update_draft, which are sessionFree. In a run with no session of its person (the minute tick, signals, the sweep, a run taken from the queue by someone else's request), these follow the precedence decision for the run's person instead of always asking:

    • Full auto, Always or "Don't ask again" runs them through runFor;
    • Ask me first still shows the card.

    Every other WRITE still asks first, with fix(chat): ask before a change in an agent run no session is behind #1946's note.

  • The run's mode is read fresh for each change (agentModeNow). If the owner set the agent to Ask me first during the run, or an Admin turned Full auto off for agents, the next change asks. If the agent can't be read, it asks too.

  • write.ts: runLoggedWrite takes withoutSession and calls tool.runFor, with the same idempotency key, Activity log line and Undo window. A row without runFor is refused before anything runs.

  • Identity always comes from the run's row (toolContext → actorOf), never from the model's input. The session-free path goes through the same decideForEngine / precedence as a session: role, excludeRoles, plan, policy, mode, demo and brand scope.

  • Help: help/chat/agents.md "When a run asks before a change" is updated.

Related issue

None. Follow-up to the agent runs review (owner decision 2026-11-01).

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. Set an agent on content drafts to Full auto, and let a schedule or signal start it. The draft appears with no card; the Activity log shows it as the owner's change, with Undo.
  2. In Ask me first, the run shows Needs you. Switch the agent to Ask me first while a run is going: its next change asks.
  3. Unit tests (engine.test.ts, write.test.ts):
    • no-session Full auto writes;
    • Ask me first, Admin Never and Ask policies, and "Full auto for members" off all ask or refuse;
    • a Manager demoted to Analyst during the run is refused;
    • a row without runFor asks;
    • the owner's own Run now is unchanged.

A pre-push review found no blocking issue; its points are in.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes (0 errors; 7 old warnings in files this PR doesn't touch)
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

CI passed on this branch (945bbea), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41360076118): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits November 2, 2026 00:41
…ts person

An agent run that the minute tick or a signal started (or that another
person's Run now picked up) has no session of its person behind it, so
ansvisor#1946 turned every change it would make by itself into a card. The draft
rows already have their own writers for such a run (ansvisor#1959: create_draft
and update_draft runFor, checked as the run's person with the service
role); this wires the engine to them.

- engine.ts: askWithoutSession leaves a sessionFree row's decision as the
  precedence made it, read for the run's person like any call's (role,
  excludeRoles, plan, policy, mode, demo brand, brand scope): Full auto,
  an Admin's Always or the person's tick run it; Ask me first still shows
  the card. Every other row still asks first, with the no-session note.
- write.ts: runLoggedWrite takes withoutSession and runs the row's runFor
  instead of run, with the same idempotency key, Activity log row and
  Undo window. A row without runFor refuses before anything runs.
- The person is always the run's (the tool context the engine builds from
  the run's row), never the model's input. A card's Approve still runs in
  its person's own request, with their session.

Tests: Full auto makes the draft with no card through createContentDraftFor,
logged as the run's person's with Undo (and undone); Ask me first still
asks and the owner's Approve uses their session; a row without runFor
still asks; a Manager made an Analyst mid-run is refused update_draft
(forbidden_role) and an Analyst's run never gets it; the owner's own Run
now still uses their session; runLoggedWrite runs runFor for both draft
rows, once per approval, and refuses a row without it.

Help article updated (help/chat/agents.md: "When a run asks before a change").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups (D-3, D-6) for the session-free engine:

- An agent run's change is decided in the mode the run has now, read
  fresh at each change (agentModeNow): the mode it started in, or the
  agent's own mode when it was set lower since, and Ask me first once an
  Admin turned Full auto off for agents (chat_settings.agents_full_auto)
  under a run that started in it. What can't be read asks first. So a
  session-free row no longer runs by itself after the owner set the agent
  to Ask me first, or the Admin turned Full auto off, mid-run. A person's
  own chat keeps its mode; reads are not affected.
- Engine tests for the session-free path with an Admin's Never (not
  offered, nothing made) and Ask (its card in Full auto), "Full auto for
  members" off (an Analyst's Full auto asks, an Admin's runs), and the
  agent run's mode now: still Full auto runs, Full auto off for agents or
  the agent set to Ask me first mid-run asks, an unreadable agent asks.

Help article updated (help/chat/agents.md: "When a run asks before a change").

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

@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 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 cd6611e into ansvisor:main Nov 2, 2026
6 checks passed
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.

2 participants