Skip to content

[AI Assistant] Search, calendar and archive/move tools ignore shared accounts (no accountId passed) #39

Open

Description

@dasplus-repo

Description

Our users work with several Stalwart shared/group accounts (isPersonal: false, e.g. info@ and muhasebe@). The AI Assistant (2.2.1, marketplace) only works with the user's primary account:

  • Mail search only searches the primary account. Asked about a shared mailbox, it can only return matches from the user's own mail.
  • Calendar lookup only lists the user's own calendar; shared accounts' calendars are never queried.
  • Archive / Move on a message that belongs to a shared account fails with "Something went wrong" (nothing is moved — safe, but unusable).

Reading works: opening or selecting a message in a shared account and asking "summarize" is fine, because those calls pass the message's account.

Cause in the bundle (ai-assistant.js 2.2.1)

  • All 5 api.email.search(...) calls pass no account, e.g. api.email.search({ ...query, limit }), api.email.search({ text: q2, limit: 5 }), api.email.search({ after: since, mailboxId: inbox.id, limit: 50 })
  • api.calendar.getEvents({ from, to }) passes no account.
  • api.email.archive([email.id]) and api.email.move([email.id], plan.folder.id) pass no account.
  • In contrast, getThread, getAttachmentText, email.get already use accountArg(email.accountId), and api.user.getAccounts() is already called.

Server side is fine (measured via JMAP with the same user's session): the session lists 7 accounts (1 personal + 6 shared), each with urn:ietf:params:jmap:mail and urn:ietf:params:jmap:calendars; Email/query and Calendar/get with the shared accountId return the expected data. Bulwark's own UI archives/moves mail in these accounts correctly.

Steps to Reproduce

  1. Log in as a user who is a member of a shared account (Stalwart group with ACL access).
  2. Ask the assistant: "List the last 3 mails in the info@… mailbox" → only the user's own account is searched.
  3. Ask: "What is in the shared calendar this week?" → only the user's own calendar is listed.
  4. Enable actions ("Ask first"), open a message inside the shared account, ask "Archive this message", click "Do it" → "Something went wrong".

Expected Behavior

  • Search and calendar tools can target a given account (or all readable accounts) and label each result with its account.
  • Archive/Move use the message's own account (email.accountId) and the shared account's archive-role mailbox, like Bulwark's toolbar does.
  • Optional admin setting: "Lookups include shared/group accounts".

Actual Behavior

  • Search/calendar: only the primary account.
  • Archive/Move on a shared-account message: fails with "Something went wrong"; counters unchanged in both accounts.

Bulwark Edition

Bulwark

Bulwark Version

1.20.0 (Docker, ghcr.io/bulwarkmail/webmail:v1.20.0)

Stalwart Mail Server Version

1.0.1

Browser

Chrome / Chromium

Operating System

Windows

Screenshots / Screen Recording

No response

Relevant Logs or Error Output

UI: archive_message plan → "Something went wrong. Try again." (shared account message)
Assistant reply: "Archiving does not work in this mailbox; the message belongs to another (shared) account."

Additional Context

AI backend: OpenAI-compatible (vLLM, qwen3.8-27b, tool calling on). Plugin forced on for all users.
All accounts now have an archive-role mailbox (personal archive via the assistant works fine), so the failure is only the missing accountId.
Related host-side fixes: webmail #1149 (Move menus in shared mailboxes), GHSA-8x23-qw3w-mhrx (actions by id across accounts).
Happy to test a build.
Server: Ubuntu Server 26.04, Docker 29.9.3 (client OS above = Windows 11).

Activity

  1. added
    bug
    on Nov 7, 2026
  2. bulwark-warden commented on Nov 7, 2026

    @bulwark-warden

    The calls you quote match the plugin source: search_mail and the archive/move action pass no account. Passing email.accountId from the plugin won't fix it alone, though. The webmail's plugin API doesn't accept an account for these methods today:

    • Archive/Move: on webmail main, api.email.move and api.email.archive take no account argument. They only accept a target folder that is not shared, and they throw open a folder of this account first; the open list belongs to another account or several when a shared folder is open (host-api-mail.ts). The comment there gives the reason: plugins name messages by bare id, and ids repeat across accounts. Making this work needs a change in bulwarkmail/webmail first.
    • Search: api.email.search refuses keys it doesn't list (readObject), and accountId isn't one of them. It does search a shared account when you give it the mailboxId of a shared folder (host-api-mail.ts). The assistant's search_mail tool never passes a mailboxId, so a fix in the plugin alone could go that way.
    • Calendar: on webmail main, api.calendar.getEvents reads events through queryAllCalendarEvents (host-api-calendar.ts). That function already loops over every account with urn:ietf:params:jmap:calendars and tags shared events with their account (client.ts). A shared account the client has marked as access-denied is skipped before the query, and one whose query fails is logged to the console and skipped. I couldn't confirm whether v1.20.0 has the same code or why your shared calendars don't show up. A Failed to query calendar events for account line in the browser console during a lookup would help narrow it down.

    webmail#1273 (closed) was about the same gap in api.email.get for shared accounts.

    Bulwark Warden is an AI assistant and can be wrong. It answers from the docs, the code and earlier issues, and links its sources.

  3. rathlinus commented on Nov 20, 2026

    @rathlinus
    Member

    Fixed on main in 1e9326f, in the next release.

    • The assistant searches the mailbox whose folder is open, or the one you name, one folder at a time, the inbox unless you name another.
    • Marking and tagging a message in a shared account now change that message, and the calendar lookup names each event's calendar and mailbox.
    • Archive and move still work only for your own mail; the assistant now says so instead of failing after Do it. That needs a change in the webmail first.
    • Could you check whether a Failed to query calendar events for account line shows in the browser console (F12, Console tab) when you ask about the shared calendar?
  4. rathlinus commented on Nov 24, 2026

    @rathlinus
    Member

    Fixed on main in 3144598, in the next release.

    • The assistant now archives and moves messages of team and shared mailboxes, into that mailbox's Archive or one of its folders, and Undo puts them back.
    • It needs the next webmail release too; with 1.21.3 or older it still says this works only for your own mail.
    • Could you check that "archive this" on a message in the shared mailbox lands in that mailbox's Archive, not yours?
  5. dasplus-repo commented on Nov 27, 2026

    @dasplus-repo
    Author

    Thanks a lot! Answers from our side (Bulwark 1.22.0, Stalwart 1.0.2, AI Assistant 2.2.1 — still the latest in the directory):

    • Calendar: no "Failed to query calendar events for account" line in the console. Asking for "this week in the info@ calendar", the assistant returned 3 events, one of them created in a shared calendar for testing — so shared calendars seem to be reached on 1.22.0. 2.2.1 doesn't label which calendar/mailbox an event comes from, so I can't fully confirm; your fix should make that visible.
    • Archive/move in a shared mailbox: on 1.22.0 + plugin 2.2.1 it still fails safely ("Something went wrong", nothing moved), as expected until the new plugin release. As soon as it is in the directory I'll test that "archive this" lands in the shared mailbox's Archive (counter of that Archive +1, mine unchanged) and report back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions