Skip to content

Make the app fully non-blocking#114

Open
marcelklehr wants to merge 16 commits intomainfrom
fix/async
Open

Make the app fully non-blocking#114
marcelklehr wants to merge 16 commits intomainfrom
fix/async

Conversation

@marcelklehr
Copy link
Member

@marcelklehr marcelklehr commented Feb 5, 2026

fixes #113

  • Sadly couldn't easily make the calendar tools non-blocking, so they remain blocking, but those HTTP requests should not take super long.. 🤷

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to address blocking behavior (Issue #113) by converting Nextcloud API interactions and most tool implementations to async, so long-running tool calls don’t block processing of other conversations.

Changes:

  • Switched core Nextcloud interactions from NextcloudApp/Nextcloud to AsyncNextcloudApp and updated call sites to await async methods.
  • Converted most tools to async and replaced sync HTTP calls with niquests.async_api.
  • Updated task processing helper and logging to be async-friendly (with calendar tools explicitly remaining sync/blocking per PR description).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
ex_app/lib/tools.py Load tools using AsyncNextcloudApp and await async availability/config reads.
ex_app/lib/nc_model.py Move chat model execution to _agenerate with async scheduling/polling via Nextcloud OCS.
ex_app/lib/main.py Make enable handler and background polling/reporting use async Nextcloud APIs.
ex_app/lib/logger.py Make log() async and await Nextcloud log calls.
ex_app/lib/agent.py Update agent entrypoint typing to AsyncNextcloudApp.
ex_app/lib/all_tools/youtube.py Update tool loader signature to async Nextcloud app.
ex_app/lib/all_tools/weather.py Convert weather tool to async HTTP calls.
ex_app/lib/all_tools/talk.py Convert Talk tools to async Nextcloud Talk API usage.
ex_app/lib/all_tools/openstreetmap.py Convert OSM tools to async HTTP calls.
ex_app/lib/all_tools/openproject.py Convert OpenProject OCS calls to async.
ex_app/lib/all_tools/mcp.py Convert MCP config reads/logging to async.
ex_app/lib/all_tools/mail.py Convert Mail OCS calls/logging to async.
ex_app/lib/all_tools/lib/task_processing.py Convert task scheduling/polling helper to async and add explicit schedule failure.
ex_app/lib/all_tools/image_gen.py Convert image generation tool to async task processing + async OCS URL lookup.
ex_app/lib/all_tools/here.py Convert HERE API key fetch + HTTP call to async.
ex_app/lib/all_tools/files.py Convert Files tools to async OCS + async download.
ex_app/lib/all_tools/duckduckgo.py Update tool loader signature to async Nextcloud app.
ex_app/lib/all_tools/doc-gen.py Convert doc generation to async task processing + async URL lookup.
ex_app/lib/all_tools/deck.py Convert Deck HTTP calls to async.
ex_app/lib/all_tools/context_chat.py Convert context chat tool to async task processing.
ex_app/lib/all_tools/contacts.py Convert Contacts DAV/OCS calls to async.
ex_app/lib/all_tools/calendar.py Keep calendar operations sync via NextcloudApp while adapting outer tool interface to async.
ex_app/lib/all_tools/audio2text.py Convert transcription tool to async task processing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@kyteinsky
Copy link

seems like caldav supports async now, might be worth to create an issue in nc_py_api to add the api there too
https://github.com/python-caldav/caldav?tab=readme-ov-file#async-api

nice fix meanwhile for the sync functions here in context_agent :)

@marcelklehr
Copy link
Member Author

I would kindly ask to only review the changes in this PR. We can and should definitely improve the code base, but I'd rather not have to fix the whole codebase just because I touched everything :S

@kyteinsky
Copy link

cool, resolved the ones that were not directly related to async changes.

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
and keep long poll interval if no tasks are running

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@kyteinsky
Copy link

fix(ci): Upgrade to python 3.11

maybe also in pyproject.toml

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
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.

Tool calls block the processing of other conversations

2 participants