Skip to content

fix(composio): preserve first-person Notion memories during extraction - #13304

Closed
nbhby wants to merge 5 commits into
BasedHardware:mainfrom
nbhby:fix/notion-personal-memory-case
Closed

nbhby wants to merge 5 commits into
BasedHardware:mainfrom
nbhby:fix/notion-personal-memory-case

Conversation

@nbhby

@nbhby nbhby commented Sep 9, 2026 •

Copy link
Copy Markdown

Fixes #13302.

The Composio Notion extractor lowercases each sentence but compares it with mixed-case keywords such as I like, silently returning no memories for supported first-person input. Normalize the keywords at the comparison boundary and apply the same casing policy when formatting recognized phrases. For example, i LIKE reading science fiction books on weekends now produces User likes reading science fiction books on weekends. Sentence-length filtering, rule priority and the casing of the remaining text are preserved.

Add offline coverage asserting complete outputs for case variants, excluded content, and the real FastAPI extraction route. The route receives synthetic Notion blocks and must store the expected memory. Register the plugin test runner in the shared local/CI manifest. A separate setup script provisions the plugin environment before checks, with CI caching keyed by the plugin requirements; the test runner never installs dependencies or invokes uv. Missing setup produces an explicit error.

Validation:

  • Python 3.11.16 with the plugin's pinned direct requirements.
  • Verified regression failures before the corresponding fixes: missing memories and incorrect first-person output for case variants. Nonpersonal/short-content exclusions still pass.
  • After the fixes: bash plugins/composio/test.sh passes all 4 tests, including 8 word-boundary cases added in response to review. The new test reproduced substring corruption before the fix (I liked became User likesd); singular/plural friends and case normalization remain covered.
  • git diff --check passes.
  • scripts/pr-preflight --lane local --pr-body-file ../omi-notion-pr.md passed all 21 selected checks, including workflow contract tests and source closure for 15 runtime images. The 90-day failure-class history ratchet reports a shallow-clone skip locally; full-history CI remains authoritative for that check.
  • actionlint -shellcheck '' .github/workflows/repo-checks.yml passes. Missing plugin setup fails with an explicit instruction; after setup, UV_OFFLINE=1 bash plugins/composio/test.sh passes without installing dependencies.
  • The additional selected backend subset passes 26 workflow-contract tests and one changed-files test. test_changed_files_reports_delete_rename_and_file_type_change fails at Path.symlink_to() with Windows privilege error 1314, before its assertions. That test and scripts/changed-files are unchanged from the base. The update uses the repository's explicit PRE_PUSH_SKIP_BACKEND_UNIT_TESTS=1 push hatch for this environment limitation; Linux CI must still verify this test. No backend test success is claimed for the subset as a whole.
  • Live Notion/OMI services were not accessed; network and persistence boundaries use synthetic fixtures.

Review follow-up: formatting now matches whole phrases at word boundaries and explicitly supports both my friend and my friends. Unsupported forms retain the existing User note: fallback. The broader suggestion to associate provisioning with manifest entries is tracked in #13396; the current single-plugin setup remains offline at test execution time.

Product invariants affected: none.

Failure-Class: none

The existing failure-class registry has no matching case-normalization contract for this plugin. The root cause and durable coverage are described above. This fixes the existing shared keyword predicate; it does not add a separate guard or fallback. The regression reproduces #13302 through production behavior.

Developed and verified with OpenAI Codex assistance. The small bounty proposed in #13302 remains subject to maintainer approval.

Normalize personal keywords at the existing comparison boundary. Add offline keyword and FastAPI extraction-route regressions and register the plugin runner in the shared check manifest.

Validation: 3 plugin tests pass after failing on the original keyword/route cases; local preflight passed (shallow-history ratchet deferred to CI); git diff --check passed.
@nbhby

nbhby commented Sep 9, 2026

Copy link
Copy Markdown
Author

The branch is pushed and the bounded local pre-push gate passed without skip hatches. Upstream Actions currently show action_required with no jobs (for example Repo Checks), so there is no upstream test verdict yet. Could a maintainer approve the fork workflow runs if this contribution is welcome? The proposed reward in #13302 remains unapproved; this PR does not assume an award.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 5 files

Confidence score: 3/5

  • plugins/composio/test.sh runs in both local and ci lanes from .github/checks-manifest.yaml, while uv run --isolated recreates the environment and downloads dependencies from PyPI on every run; this can make checks slower or unreliable when package availability or network access is limited.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/composio/test.sh">

<violation number="1" location="plugins/composio/test.sh:6">
P2: This check runs in both the `local` and `ci` lanes via `.github/checks-manifest.yaml`, but `uv run --isolated` builds a fresh, ephemeral environment and downloads fastapi/uvicorn/pydantic/httpx/etc. from PyPI on every invocation. That contradicts the repo-checks job contract, which states manifest checks "consume only Python stdlib + Git; do not install code-test tools," and the AGENTS.md rule that CI tests be hermetic (no network). Any PR or `make preflight` touching `plugins/composio/**` now requires live PyPI (and a managed 3.11 if uv lacks one) or the check fails red, even though the underlying unittest suite is fully offline and only needs stdlib + the plugin source. Make the dependency provisioning hermetic: e.g. install pinned deps at CI startup into the cached uv path (add `plugins/composio/requirements.txt` to the job's `cache-dependency-glob`) and have test.sh reuse that environment instead of `--isolated`, consistently with how the backend jobs pre-sync deps.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/composio/src/notion.py Resolved
Comment thread plugins/composio/test.sh Outdated
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"
exec uv run --isolated --no-project --python 3.11 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This check runs in both the local and ci lanes via .github/checks-manifest.yaml, but uv run --isolated builds a fresh, ephemeral environment and downloads fastapi/uvicorn/pydantic/httpx/etc. from PyPI on every invocation. That contradicts the repo-checks job contract, which states manifest checks "consume only Python stdlib + Git; do not install code-test tools," and the AGENTS.md rule that CI tests be hermetic (no network). Any PR or make preflight touching plugins/composio/** now requires live PyPI (and a managed 3.11 if uv lacks one) or the check fails red, even though the underlying unittest suite is fully offline and only needs stdlib + the plugin source. Make the dependency provisioning hermetic: e.g. install pinned deps at CI startup into the cached uv path (add plugins/composio/requirements.txt to the job's cache-dependency-glob) and have test.sh reuse that environment instead of --isolated, consistently with how the backend jobs pre-sync deps.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/composio/test.sh, line 6:

<comment>This check runs in both the `local` and `ci` lanes via `.github/checks-manifest.yaml`, but `uv run --isolated` builds a fresh, ephemeral environment and downloads fastapi/uvicorn/pydantic/httpx/etc. from PyPI on every invocation. That contradicts the repo-checks job contract, which states manifest checks "consume only Python stdlib + Git; do not install code-test tools," and the AGENTS.md rule that CI tests be hermetic (no network). Any PR or `make preflight` touching `plugins/composio/**` now requires live PyPI (and a managed 3.11 if uv lacks one) or the check fails red, even though the underlying unittest suite is fully offline and only needs stdlib + the plugin source. Make the dependency provisioning hermetic: e.g. install pinned deps at CI startup into the cached uv path (add `plugins/composio/requirements.txt` to the job's `cache-dependency-glob`) and have test.sh reuse that environment instead of `--isolated`, consistently with how the backend jobs pre-sync deps.</comment>

<file context>
@@ -0,0 +1,8 @@
+set -euo pipefail
+
+cd "$(dirname "${BASH_SOURCE[0]}")"
+exec uv run --isolated --no-project --python 3.11 \
+  --with-requirements requirements.txt \
+  python -m unittest discover -s tests -v
</file context>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 6a1869c. Dependency provisioning is now a separate setup-tests.sh step creating an ignored plugin .test-venv. test.sh only runs that interpreter; it invokes neither uv nor pip and reports an explicit setup error if the environment is absent. CI Hygiene prepares the environment before checks when the shared manifest selects this test, and the uv cache key includes the plugin requirements. The metadata-only job is unchanged. Verified both the missing-environment failure and passing tests after setup with UV_OFFLINE=1.

…riants

Address the case-variant review by matching and replacing with the same casing policy, preserving rule priority and proper names. Assert full extracted strings and exercise mixed-case text through the real route. Regression tests failed before this fix and pass afterward.
Move uv dependency provisioning to a separate setup script and CI preparation selected by the manifest. Keep test.sh offline, fail explicitly without setup, and cache requirements in CI. Validation: offline plugin suite, actionlint, diff hygiene and all 21 local preflight checks passed.
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @nbhby — this is a well-verified fix, and both earlier review findings are clearly resolved at the current head.

What I checked:

  • plugins/composio/src/notion.py — root cause from Composio Notion extraction drops first-person memories due to keyword case mismatch #13302 confirmed: contains_personal_info() lowercased the input but compared mixed-case keywords, so no first-person sentence ever matched. The keyword.lower() comparison fixes it with minimal churn, and the rewritten format_as_memory() keeps the original rule priority (e.g. i am|i'm before i like) and the User note: fallback while matching and substituting case-insensitively. Sentence-length filtering in extract_memories_from_text() is untouched.
  • plugins/composio/tests/test_notion_memories.py — good coverage: case variants assert complete output strings (not just non-empty), short/non-personal content stays excluded, and the third test drives the real POST /api/notion/extract-memories route with mocked Notion responses and mocked persistence. I ran the suite offline at this head: 3/3 pass.
  • .github/checks-manifest.yaml — the new composio-notion-memory-tests entry follows the existing schema (id/command/triggers/lanes/reason) and runs in both lanes.
  • .github/workflows/repo-checks.yml — the provisioning step only probes selection (run_checks.py --output json implies --list; nothing executes there), installs the plugin's pinned requirements.txt when the check is selected, and leaves workflow permissions at contents: read / pull-requests: read. The uv cache-glob extension is straightforward.
  • plugins/composio/setup-tests.sh, test.sh, .gitignore, README.md — clean setup/runner split: provisioning happens only in setup-tests.sh; the runner just executes the venv interpreter with no network or installs and fails with a clear message when setup is missing. The README additions match the scripts' actual behavior.

Two non-blocking notes:

  1. format_as_memory() still uses prefix substring matching, so "I liked" → "User likesd" and "my friends" → "User's friends". That's pre-existing behavior faithfully preserved (the right call for a regression-scoped fix); a word-boundary pass would be a good follow-up.
  2. The workflow setup step re-derives selection by hardcoding the check id. Fine for one check; if more plugins adopt provisioning, a manifest-level setup concept may age better.

Since this adds a lane to shared CI and the fork workflows haven't been approved to run yet (so there's no upstream verdict), maintainer sign-off on the CI integration is the remaining gate, along with the bounty question in #13302. The code change itself looks mergeable to me.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior positive-signal Automation verified a genuine fix/quality contribution python labels Sep 9, 2026
@nbhby

nbhby commented Sep 10, 2026

Copy link
Copy Markdown
Author

Follow-up on the automated review note: the current head (6a1869cc) no longer runs uv run --isolated from plugins/composio/test.sh. The workflow provisions the pinned plugins/composio/requirements.txt once via setup-tests.sh, and the runner reuses .test-venv without network access. The dependency file is included in the uv cache dependency glob. The focused offline suite was run after this change; please re-run the repository check at the current head when convenient. The proposed bounty remains unapproved; this comment is only a technical follow-up.

Address the non-blocking review in BasedHardware#13304. Preserve friends singular/plural and rule priority; unsupported forms retain User note. Added 8 formatting cases, reproduced substring failures before the fix, and passed 4 offline tests plus all 21 local preflight checks. The shallow-history ratchet remains deferred to full-history CI.

Failure-Class: none
@nbhby

nbhby commented Sep 10, 2026

Copy link
Copy Markdown
Author

Addressed the word-boundary suggestion in a separate follow-up commit: replacements now match complete phrases, preventing I liked from becoming User likesd and preventing matches inside words such as Miami. The explicit my friends? rule preserves both singular and plural output. Unsupported forms use the existing User note: fallback; sentence filtering and replacement priority are unchanged.

The regression test reproduced the substring failures before the change. The offline plugin suite now passes all 4 tests, including 8 new formatting cases and the existing FastAPI extraction-route test with synthetic Notion responses. All 21 selected local preflight checks pass, with the shallow-history ratchet deferred to full-history CI. The additional backend tests reproduced the already documented Windows symlink privilege error (1314); the other 27 cases pass. The push uses the documented backend-test hatch for that limitation, not a claim of an entirely green backend suite. No live Notion or Omi account was used. This update was developed and tested with Codex assistance.

For the provisioning suggestion, I opened #13396 to track the duplicated check-to-setup association and the coverage needed for a manifest-level provisioning phase. The current single-plugin setup/runner split remains functional. Keeping that shared runner change separate makes its cross-check behavior independently reviewable.

@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification at the new head fe39cc8e - the word-boundary pass resolves the earlier formatting note cleanly:

  • plugins/composio/src/notion.py - format_as_memory() now wraps each pattern as \b(?:...)\b and substitutes case-insensitively, so I liked ... falls through to User note: instead of User likesd ..., Miami likes ... no longer matches, and the explicit my friends? rule keeps both singular and plural forms. Rule priority and the sentence-length filter in extract_memories_from_text() are unchanged.
  • plugins/composio/tests/test_notion_memories.py - the word-boundary cases are real regression coverage: I ran the full suite offline at this head in a clean Python 3.11 environment with the plugin's pinned requirements (4/4 pass), and the same suite against the pre-fix notion.py fails 14 cases - including the case-variant and extraction-route tests - so the tests genuinely pin the fixed behavior.
  • plugins/composio/test.sh - confirmed it fails fast with the explicit setup message (exit 1) when .test-venv is absent, and performs no installs or network access itself.
  • .github/checks-manifest.yaml / .github/workflows/repo-checks.yml - the selection probe still only reads run_checks.py output (unchanged from main) before provisioning, and installs only the pinned plugins/composio/requirements.txt (byte-identical to main). The check-id hardcoding stays as previously noted - fine while this is the only provisioned check.

Remaining before merge: maintainer sign-off on the new shared-CI provisioning step (workflow-review) and approving the fork's workflow runs so an upstream verdict exists. The code and tests look good at this head.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

Preserve both independent plugin check additions. Composio offline tests: 4 passed. PR diff whitespace check passes. Merge-only pre-commit formatter bypassed because it selects upstream Dart/backend/ARB files and requires unavailable toolchains; upstream content is preserved.
@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open on 520518f69b19.

DIRTY composio Notion first-person + extra workflow files; 0-checks not MERGE.

This touches .github/workflows/** (workflow CODEOWNERS). I am not fake-approving that path.

I am not approving or merging this SHA.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving 520518f69b19. origin/main plugins/composio/src/notion.py still replaces exact I am / I like phrases. This SHA case-folds those replacements and tests the route. It also edits .github/workflows/repo-checks.yml, which is not this tip. detail=str(e) at notion.py:253 is a different sink. mergeable CONFLICTING/DIRTY.

— Astar, on behalf of @aryanorastar

@undivisible

Copy link
Copy Markdown
Collaborator

No longer needed: Referenced #13302 is COMPLETED by merged #13524; main Notion matching lowercases keywords.

Closing.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @nbhby 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Composio Notion extraction drops first-person memories due to keyword case mismatch

4 participants