Skip to content

feat(email-search): add server-side query support & fix agent silent stalls#5153

Open
Katsoragi wants to merge 1 commit into
odysseus-dev:devfrom
Katsoragi:personal/email-server-side-search
Open

feat(email-search): add server-side query support & fix agent silent stalls#5153
Katsoragi wants to merge 1 commit into
odysseus-dev:devfrom
Katsoragi:personal/email-server-side-search

Conversation

@Katsoragi

@Katsoragi Katsoragi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds server-side query support for email listings. By delegating keyword searches directly to the IMAP server (SEARCH TEXT "query"), we optimize retrieval times, prevent heavy local filtering of large folder slices, and resolve silent agent stalls when searching large mailboxes.

Target branch

  • This PR targets dev, not main. All PRs land in dev; main is curated by the maintainer at each release. If your PR is on main by accident, click "Edit" on this PR and change the base.

Linked Issue

Fixes #5165

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs — this is not a duplicate.
  • This PR targets dev
  • My changes are limited to the scope described above — no unrelated refactors or whitespace changes mixed in.
  • I actually ran the app (docker compose up or uvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.

How to Test

  1. Use the email listing tool list_emails or backend route /api/email/list with a query parameter.
  2. Observe that keyword search executes server-side on the IMAP server, returning only matching emails.

Checks Run

  • Run pytest suite: pytest tests/test_imap_leak_fixes.py tests/test_imap_mailbox_quoting.py tests/test_email_owner_scope.py (All Passed).

@github-actions github-actions Bot added needs work PR description incomplete — please update before review ready for review Description complete — ready for maintainer review and removed needs work PR description incomplete — please update before review labels Jul 3, 2026
…stalls

- Added query parameter to list_emails and /list endpoint supporting server-side IMAP TEXT search.
- Updated tool schemas for list_emails to document the new query parameter.
- Modified the agent loop to catch invalid/failed native tool calls, outputting a system warning nudge and looping again rather than silently stalling.
@Katsoragi
Katsoragi force-pushed the personal/email-server-side-search branch from e7476b3 to 2d21aa3 Compare July 12, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support server-side query filtering for IMAP emails

1 participant