Context Chat Backend error in nextcloud.log "token does not exist"

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.5
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.58
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • none
  • PHP version (e.g, 8.3):
    • 8.3
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • Always i try use Context Chat in Assistant
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare Metal/Archive
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

I installed the AppApi, Context_Chat_Backend, Context_Chat, and Assistant stack as indicated in the documentation. However, when I try to obtain a response from the Context_Chat_Backend in the Nextcloud log, I get the following error:

{"reqId":"Law2TcJ7hOSQMdCqCj4c","level":0,"time":"2025-02-13T21:10:11+00:00","remoteAddr":"192.168.1.60","user":"admin","app":"core","method":"POST","url":"/nextcloud/ocs/v1.php/taskprocessing/schedule?format=json","message":"Session token is invalid because it does not exist","userAgent":"ExApp/context_chat_backend/4.0.7 (httpx/0.28.1)","version":"30.0.5.1","exception":{"Exception":"OC\\Authentication\\Exceptions\\InvalidTokenException","Message":"Token does not exist: token does not exist

Steps to replicate it (hint: details matter!):

  1. Install AppApi
  2. Register Context_Chat_Backend
  3. Enable Context_Chat
  4. Enable Assistant
  5. Open Assistant on browser and ask something
  6. As soon as cron.php runs the error is printed

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

{"reqId":"LgXhOz9lk8OdL3heH2H1","level":0,"time":"2025-02-13T11:00:15+00:00","remoteAddr":"192.168.1.60","user":"admin","app":"core","method":"POST","url":"/nextcloud/ocs/v1.php/taskprocessing/schedule?format=json","message":"Session token is invalid because it does not exist","userAgent":"ExApp/context_chat_backend/4.0.7 (httpx/0.28.1)","version":"30.0.5.1","exception":{"Exception":"OC\\Authentication\\Exceptions\\InvalidTokenException","Message":"Token does not exist: token does not exist","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Authentication/Token/Manager.php","line":118,"function":"getToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":748,"function":"getToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":209,"function":"validateToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":184,"function":"validateSession","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":187,"function":"getUser","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/App/AppManager.php","line":193,"function":"getEnabledApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":85,"function":"loadApps","class":"OC\\App\\AppManager","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_User.php","line":106,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":729,"function":"setupBackends","class":"OC_User","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1134,"function":"init","class":"OC","type":"::"},{"file":"/var/www/html/nextcloud/ocs/v1.php","line":8,"args":["/var/www/html/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php","Line":165,"Previous":{"Exception":"OCP\\AppFramework\\Db\\DoesNotExistException","Message":"token does not exist","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php","line":157,"function":"getToken","class":"OC\\Authentication\\Token\\PublicKeyTokenMapper","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/Authentication/Token/Manager.php","line":118,"function":"getToken","class":"OC\\Authentication\\Token\\PublicKeyTokenProvider","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":748,"function":"getToken","class":"OC\\Authentication\\Token\\Manager","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":209,"function":"validateToken","class":"OC\\User\\Session","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/lib/private/User/Session.php","line":184,"function":"validateSession","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":187,"function":"getUser","class":"OC\\User\\Session","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/App/AppManager.php","line":193,"function":"getEnabledApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_App.php","line":85,"function":"loadApps","class":"OC\\App\\AppManager","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_User.php","line":106,"function":"loadApps","class":"OC_App","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":729,"function":"setupBackends","class":"OC_User","type":"::"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1134,"function":"init","class":"OC","type":"::"},{"file":"/var/www/html/nextcloud/ocs/v1.php","line":8,"args":["/var/www/html/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/lib/private/Authentication/Token/PublicKeyTokenMapper.php","Line":81},"message":"Session token is invalid because it does not exist","user":null,"exception":{},"CustomMessage":"Session token is invalid because it does not exist"}}

Web Browser

If the problem is related to the Web interface, open your browser inspector Console and Network tabs while refreshing (reloading) and reproducing the problem. Provide any relevant output/errors here that appear.

PASTE

Web server / Reverse Proxy

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.1.189"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "sqlite3",
        "version": "30.0.5.1",
        "overwrite.cli.url": "http:\/\/192.168.1.189\/nextcloud",
        "installed": true,
        "loglevel": 0,
        "maintenance": false
    }
}

Apps

Enabled:

  • activity: 3.0.0
  • app_api: 4.0.5
  • assistant: 2.3.0
  • bruteforcesettings: 3.0.0
  • circles: 30.0.0
  • cloud_federation_api: 1.13.0
  • comments: 1.20.1
  • contactsinteraction: 1.11.0
  • context_chat: 4.0.6
  • dashboard: 7.10.0
  • dav: 1.31.1
  • federatedfilesharing: 1.20.0
  • federation: 1.20.0
  • files: 2.2.0
  • files_downloadlimit: 3.0.0
  • files_pdfviewer: 3.0.0
  • files_reminders: 1.3.0
  • files_sharing: 1.22.0
  • files_trashbin: 1.20.1
  • files_versions: 1.23.0
  • firstrunwizard: 3.0.0
  • logreader: 3.0.0
  • lookup_server_connector: 1.18.0
  • nextcloud_announcements: 2.0.0
  • notifications: 3.0.0
  • oauth2: 1.18.1
  • password_policy: 2.0.0
  • photos: 3.0.2
  • privacy: 2.0.0
  • provisioning_api: 1.20.0
  • recommendations: 3.0.0
  • related_resources: 1.5.0
  • serverinfo: 2.0.0
  • settings: 1.13.0
  • sharebymail: 1.20.0
  • support: 2.0.0
  • survey_client: 2.0.0
  • systemtags: 1.20.0
  • text: 4.1.0
  • theming: 2.5.0
  • twofactor_backupcodes: 1.19.0
  • twofactor_totp: 12.0.0-dev
  • updatenotification: 1.20.0
  • user_status: 1.10.0
  • viewer: 3.0.0
  • weather_status: 1.10.0
  • webhook_listeners: 1.1.0-dev
  • workflowengine: 2.12.0
    Disabled:
  • admin_audit: 1.20.0
  • encryption: 2.18.0
  • files_external: 1.22.0
  • suspicious_login: 8.0.0
  • twofactor_nextcloud_notification: 4.0.0 (installed 4.0.0)
  • user_ldap: 1.21.0
    ExApps:
    context_chat_backend (Context Chat Backend): 4.0.7 [enabled]
    llm2 (Local large language model): 2.2.2 [enabled]
    translate2 (Local Machine Translation): 2.0.3 [enabled]

Tips for increasing the likelihood of a response

  • Use the preformatted text formatting option in the editor for all log entries and configuration output.
  • If screenshots are useful, feel free to include them.
    • If possible, also include key error output in text form so it can be searched for.
  • Try to edit log output only minimally (if at all) so that it can be ran through analyzers / formatters by those trying to help you.