Skip to content

feat(dev-api): add /v1/dev/user/ask and the "omi ask" CLI command - #10314

Closed
aryanorastar wants to merge 17 commits into
BasedHardware:mainfrom
aryanorastar:feat/cli-omi-ask
Closed

aryanorastar wants to merge 17 commits into
BasedHardware:mainfrom
aryanorastar:feat/cli-omi-ask

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

omi ask "<question>" — ask a natural-language question and get an answer grounded in your own Omi conversations, from the terminal or any Developer-API caller. No desktop app required.

omi ask "what did I decide about pricing last week?"
omi ask "what did I promise Sarah in yesterday's standup?"
omi --json ask "open questions from my last 3 meetings" --limit 3

The context that lives in your conversations, made queryable where developers actually work — the terminal, scripts, CI — not just the app.

How

  • Backend — POST /v1/dev/user/ask (conversations:read scope). Semantically searches the caller's conversations (search_conversations), then synthesizes a cited answer from the most relevant ones (qa_rag) — the same retrieval + RAG the chat surface already uses. Read-only; locked conversations are excluded by the search layer; no LLM call (no cost) when nothing relevant is found.
  • CLI — a thin top-level omi ask command (--limit, --timezone, --json) that renders the answer plus its conversation sources.

Deliberately small: it reuses the existing search + RAG rather than adding new machinery, and grounds on conversations (staying out of the memory-compat rollout path).

Rate limiting / cost guard

Addressing @Git-on-my-level's review — the endpoint invokes an LLM per call, so it now carries a dedicated per-key budget instead of riding the cheap list-read limit:

  • New dev:ask policy — 25 / hour, per key — in utils/rate_limit_config.py, sized like the billable dev:conversations LLM-create path and tighter than the dev:conversations_read list limit (60/hr) the endpoint would otherwise have used.
  • Enforced in a dedicated dependency get_uid_with_conversations_read_ask (conversations:read scope + dev:ask), fail-closed on the per-app/key identity via the shared dev-API check_api_key_rate_limit. A leaked or overused key is capped, and a Redis outage denies rather than opens.
  • Route-policy manifest updated: rate_limit none → dev:ask / api_key / fail_closed / dependency.

Tests

  • backend/tests/unit/test_dev_ask_endpoint.py — returns a grounded, cited answer from the retrieved conversations; makes no LLM call when nothing relevant matches; and (regression for the review) asserts the endpoint is bound to the rate-limited dependency, which enforces exactly dev:ask and is tighter than the list-read limit.
  • sdks/python-cli/tests/test_ask.py — the command POSTs the question and renders the answer + sources; --json emits the raw payload.

Regenerated the public + app-client OpenAPI contracts and the derived TS + Swift clients for the new endpoint.

Product invariants affected

none

Failure-Class: none

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces needs-tests PR introduces logic that should be covered by tests labels Jul 22, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for putting this together — the feature is coherent with the Developer API/CLI direction, and I like that it reuses the existing conversation search + cited RAG path rather than inventing a second retrieval stack.

I do think this needs changes before maintainer sign-off:

  • POST /v1/dev/user/ask is a new public Developer API endpoint that can invoke an LLM on demand, but the route policy explicitly declares rate_limit: none and the implementation does not add a quota/cost guard. Even with conversations:read auth, a leaked or overused developer key could turn this into an unbounded billable endpoint over sensitive user conversation data. Please put this behind an appropriate per-user/key rate limit or existing usage budget before merge.
  • The current check run has Backend unit suite failing. It looks outside this endpoint from the log I inspected, but this PR should either get a green rerun or have maintainers mark the failure as pre-existing before merge.

Given the endpoint exposes sensitive conversation-derived answers and a billable LLM path, this should get human maintainer review for the product/security posture even after those fixes.


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

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Thanks for the review — both points addressed.

1. Rate limit / cost guard. You're right that riding dev:conversations_read (a cheap list-read limit, 60/hr) left the billable LLM path effectively unbounded. The endpoint now carries a dedicated per-key budget:

  • New dev:ask policy — 25/hour, per app/key identity — in utils/rate_limit_config.py, sized like the billable dev:conversations LLM-create path and strictly tighter than the list-read limit.
  • Enforced in a dedicated auth dependency get_uid_with_conversations_read_ask (conversations:read scope + dev:ask), fail-closed via the shared dev-API check_api_key_rate_limit (_enforce_rate_limit(..., fail_closed=True)) — a leaked/overused key is capped, and a Redis outage denies rather than opens.
  • Route-policy manifest updated to match reality: rate_limit none → dev:ask / api_key / fail_closed / dependency.
  • Regression test (test_ask_endpoint_is_bound_to_the_dev_ask_rate_limited_dependency) asserts the endpoint is wired to the rate-limited dependency, that it enforces exactly dev:ask, and that dev:ask is tighter than the list-read limit — so a future edit can't silently drop it back to the loose read budget.

2. Failing Backend unit suite. It was a stale-base failure outside this endpoint (as your log inspection suggested). Rebased onto latest main; make preflight passes 28/28 locally and the fresh CI run should be green.

Agreed this warrants human maintainer review for the product/security posture given the sensitive-data + billable-LLM surface — ready for that look.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

dev-api feature — approved; not auto-merged (feature, outside desktop)

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the follow-up. I re-reviewed the current head (9ecd1d0d) and the dedicated dev:ask budget plus fail-closed dependency/route-policy regression test addresses the main cost-guard concern from my earlier review.

I’m not dismissing the prior change request yet because this head is still not green: Backend unit suite is failing in tests/unit/test_desktop_release_scripts.py::test_codemagic_produces_canonical_app_and_strictly_verifiable_dmg, and Hermetic Backend E2E is failing in TestSurfaceDefaultAccessMatrix::test_surface_excludes_archive_and_respects_grants[agent_tools] (which also fails the Backend Hermetic Merge Gate). These look outside the ask endpoint, but this PR still needs either a green rerun or maintainer confirmation that the failures are unrelated/pre-existing before merge.

Given this exposes a new public Developer API surface over sensitive conversation data and a billable RAG call path, I’d still keep needs-maintainer-review/security-review on it for human product/security sign-off even after CI is resolved.


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

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Thanks — agreed both failures are outside this endpoint, and I checked rather than asserting it. Evidence:

test_desktop_release_scripts.py::test_codemagic_produces_canonical_app_and_strictly_verifiable_dmg — I ran it against a clean checkout of current main (no changes from this PR):

pytest backend/tests/unit/test_desktop_release_scripts.py::test_codemagic_produces_canonical_app_and_strictly_verifiable_dmg
→ 1 passed

So it isn't a defect in this diff — it was failing against the older base this PR sat on, and main has since moved past it. This PR is backend dev-API + CLI only and touches no desktop release scripts.

TestSurfaceDefaultAccessMatrix::test_surface_excludes_archive_and_respects_grants[agent_tools] — a canonical memory surface/access-matrix assertion (short-term memory not surfaced). This PR adds a conversations-grounded ask endpoint and touches no memory surface or grant path. The same failure is currently hitting other unrelated PRs (it also appeared on #10262, a conversation-merge change), which points at main, not either diff.

I've now rebased onto latest main so both run against current state — the release-scripts case should clear outright, and the memory-E2E case will show whether it's still live on main independent of this PR. test_dev_ask_endpoint.py → 3 passed and make preflight → 28/28 locally on the rebased head.

Agreed on keeping needs-maintainer-review / security-review for the human product/security pass on the sensitive-conversation + billable-RAG surface.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Both are handled in the current tip (7fede1a28c) — I believe the review predates the rate-limit commit:

1. Rate limit (the billable-endpoint concern). POST /v1/dev/user/ask is bound to get_uid_with_conversations_read_ask (dependencies.py:317), which requires conversations:read and enforces a dedicated dev:ask budget of 25 requests/hour per key (rate_limit_config.py) — a tight per-key cap on the LLM path, distinct from the cheap list-read limit. The route policy declares policy_name: dev:ask, not none. Test test_ask_endpoint_is_bound_to_the_dev_ask_rate_limited_dependency pins that binding and that dev:ask is strictly tighter than the list-read limit.

2. Backend unit suite. As you suspected, that's outside this endpoint — it's the pre-existing app-client OpenAPI drift from the memories baseline toggle (#8728), fixed in #10482. /v1/dev/user/ask is in the committed public spec and export_openapi.py --surface public --check passes on this branch.

Agree it warrants human review for the product/security posture given the sensitive-data + billable-LLM surface — flagging @Git-on-my-level for that. Nothing code-side outstanding that I can see; happy to adjust the cap if 25/hr is the wrong number.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick update here. The dedicated dev:ask rate limit, fail-closed dependency wiring, route-policy entry, and regression test address the original unbounded billable-LLM/cost-guard concern from my first review.

I do need to keep this in changes-requested state on the current head (7fede1a) because the generated API client/spec artifacts are still stale:

  • Public Developer API contract fails at backend/scripts/generate_ts_openapi_types.py --check, reporting the four TS generated clients as stale (desktop/windows/.../omiApi.generated.ts, web/app/..., web/admin/..., and web/personas-open-source/...).
  • Backend unit suite also fails the generated-client tests: tests/unit/test_app_client_swift_generator.py::test_swift_dto_file_is_generated_from_app_client_openapi and tests/unit/test_app_client_ts_generator.py::test_typescript_schema_types_are_generated_from_app_client_openapi.
  • The Desktop Swift aggregate is red because the Swift test suite was cancelled; the backend unit output also indicates desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift is out of date and should be regenerated with python generate_swift_openapi_types.py.

Please regenerate the checked-in TS/Swift API client artifacts from the current OpenAPI output and rerun the contract/unit checks. After that, this still needs human maintainer/security-product sign-off before merge because it adds a public Developer API + CLI surface over sensitive conversation data and a billable cited-RAG path, but I do not see the earlier rate-limit blocker remaining.


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

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Regenerated the stale client artifacts — done on the rebased head.

Verified with the .openapi-venv + full pytest venv:

generate_{dart,ts,swift}_openapi_types --check  → all OK
export_openapi --check {public,app-client,integration}  → all up to date
test_dev_ask_endpoint (3) + test_app_client_swift_generator + test_app_client_ts_generator → 18 passed
ratchet check (developer.py) → OK

That clears the generate_ts_openapi_types.py --check, the Swift/TS generator unit tests, and the OpenAPI-contract failure you flagged. The desktop-swiftlint red is a local sourcekitd tooling issue on my side only (Sources/Generated/ is swiftlint-excluded); CI runs the real linter. Still yours for the human product/security pass on the sensitive-conversation + billable-RAG surface — no code blocker outstanding that I can see.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for continuing to tighten this up. The rate-limit/cost guard and regenerated client artifacts look addressed on the current head, and CI is green now.

I need to request one more change before this is safe for maintainer sign-off: the new ask endpoint hydrates the search hits directly with conversations_db.get_conversations_by_id(...) but does not re-apply the privacy filters that the normal conversation search route applies after hydration.

Concretely, search_conversations(...) defaults include_discarded=True, and /v1/dev/user/ask does not override it, so discarded conversations can still be selected and sent into qa_rag. Also, the public /v1/conversations/search route re-checks not conversation.get('is_locked') after fetching Firestore records because the Typesense index can lag; this new endpoint relies only on the index-side is_locked field, so a stale index can leak locked conversation content into the LLM context and returned answer/sources.

Please mirror the existing search-route hardening here: call search with include_discarded=False, hydrate without photos if possible, and filter hydrated conversations with not conversation.get('is_locked') before building the RAG context/sources. A regression test covering discarded and locked hydrated conversations would be useful because this is a sensitive conversation-data + billable RAG surface.

I’m preserving the human-review/security labels: even after this fix, this should still get human product/security sign-off before merge.


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

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main. The stale TS/Swift generated-client blocker is now resolved: a maintainer refreshed the generated API artifacts on main (chore(api): refresh generated API artifacts), so the #8728 drift this inherited is gone. All checks now green (0 failing, 0 pending), MERGEABLE. The rate-limit + fail-closed dev:ask dependency and its regression test are unchanged. Re-requesting review — nothing code-side outstanding on my end; the remaining call is the human product/security sign-off you flagged for the sensitive-conversation + billable-RAG surface.

aryanorastar added a commit to aryanorastar/omi that referenced this pull request Jul 26, 2026
…/user/ask

Maintainer privacy review on BasedHardware#10314: the ask endpoint hydrated search hits with
get_conversations_by_id but did not re-apply the privacy filters the normal
conversation-search route applies after hydration, so sensitive content could
reach qa_rag:

- search_conversations defaults include_discarded=True and the endpoint did not
  override it, so a discarded/deleted conversation could be selected.
- The Typesense search index's is_locked can lag Firestore, so a stale hit could
  surface a since-locked conversation; the endpoint trusted the index-side flag
  only, while /v1/conversations/search re-checks is_locked on the authoritative
  record after fetch.

Pass include_discarded=False, and drop any conversation whose authoritative
record is is_locked before it reaches the LLM — mirroring the post-hydration
filter in /v1/conversations/search.

Verify (.venv): test_dev_ask_endpoint.py 5 passed, incl. two new regressions
(discarded excluded from retrieval; a locked conversation from a stale index is
dropped). Mutation-checked: reverting either filter fails the matching test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Good catch — fixed. The ask endpoint now applies the same two privacy filters as /v1/conversations/search:

  1. Discarded excluded from retrieval — search_conversations(..., include_discarded=False), so a discarded/deleted conversation is never selected (the search default is True).
  2. is_locked re-checked on the authoritative record — after get_conversations_by_id, drop any conversation whose Firestore record is is_locked, so a stale search index can't leak a since-locked conversation into qa_rag. This mirrors the post-hydration not conversation.get('is_locked') filter in /v1/conversations/search.

Two regression tests added (test_dev_ask_endpoint.py): discarded excluded from retrieval, and a locked conversation from a stale index is dropped before hydration. Mutation-checked — reverting either filter fails the matching test; 5 passed total. Ready for re-review.

aryanorastar added a commit to aryanorastar/omi that referenced this pull request Jul 26, 2026
…/user/ask

Maintainer privacy review on BasedHardware#10314: the ask endpoint hydrated search hits with
get_conversations_by_id but did not re-apply the privacy filters the normal
conversation-search route applies after hydration, so sensitive content could
reach qa_rag:

- search_conversations defaults include_discarded=True and the endpoint did not
  override it, so a discarded/deleted conversation could be selected.
- The Typesense search index's is_locked can lag Firestore, so a stale hit could
  surface a since-locked conversation; the endpoint trusted the index-side flag
  only, while /v1/conversations/search re-checks is_locked on the authoritative
  record after fetch.

Pass include_discarded=False, and drop any conversation whose authoritative
record is is_locked before it reaches the LLM — mirroring the post-hydration
filter in /v1/conversations/search.

Verify (.venv): test_dev_ask_endpoint.py 5 passed, incl. two new regressions
(discarded excluded from retrieval; a locked conversation from a stale index is
dropped). Mutation-checked: reverting either filter fails the matching test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
aryanorastar added a commit to aryanorastar/omi that referenced this pull request Jul 26, 2026
…/user/ask

Maintainer privacy review on BasedHardware#10314: the ask endpoint hydrated search hits with
get_conversations_by_id but did not re-apply the privacy filters the normal
conversation-search route applies after hydration, so sensitive content could
reach qa_rag:

- search_conversations defaults include_discarded=True and the endpoint did not
  override it, so a discarded/deleted conversation could be selected.
- The Typesense search index's is_locked can lag Firestore, so a stale hit could
  surface a since-locked conversation; the endpoint trusted the index-side flag
  only, while /v1/conversations/search re-checks is_locked on the authoritative
  record after fetch.

Pass include_discarded=False, and drop any conversation whose authoritative
record is is_locked before it reaches the LLM — mirroring the post-hydration
filter in /v1/conversations/search.

Verify (.venv): test_dev_ask_endpoint.py 5 passed, incl. two new regressions
(discarded excluded from retrieval; a locked conversation from a stale index is
dropped). Mutation-checked: reverting either filter fails the matching test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick privacy fix here. The current backend code now uses include_discarded=False and re-checks is_locked after hydration before building the RAG context, with regression coverage for both paths, so the data-handling blocker from my last review looks addressed.

I still need to keep this in changes-requested state because the current head is not green: Public Developer API contract is failing on backend/scripts/export_openapi.py --check ../docs/api-reference/openapi.json, reporting that docs/api-reference/openapi.json is stale. This looks likely related to the endpoint docstring/contract text changing with the discarded/locked-conversation hardening while the checked-in public OpenAPI artifact was not regenerated.

Please regenerate the public OpenAPI artifact from the current head and rerun the contract check. After that, I would still keep needs-maintainer-review / security-review for David or another human maintainer to make the final product/security call, because this adds a public Developer API + CLI surface over sensitive conversation data and a billable cited-RAG path.


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

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

New capability (/v1/dev/user/ask + omi ask) — approving the implementation; feature merges stay Nik's call.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin @Git-on-my-level need human response — conflicts cleared; product/security merge call for #10314.

Tip a963135345 (merge/main):

Author-clear safeguards unchanged: fail-closed dev:ask 25/hr, include_discarded=False, post-hydration is_locked re-check, OpenAPI/TS/Swift/CLI artifacts.

@kodjima33 APPROVED (approve-only / feature → Nik). Please merge or explicit security hold when ready.

Public Developer API contract failed: TS/Swift footers were stale
(393→394) vs current app-client OpenAPI after the main merge.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Public Developer API contract red after merge/main — fixed on tip d8dabab8aa.

Regenerated checked-in clients from current app-client OpenAPI:

  • 4× omiApi.generated.ts (windows + web app/admin/personas)
  • OmiApi.generated.swift

Local: generate_ts_openapi_types.py --check + generate_swift_openapi_types.py --check OK; test_dev_ask_endpoint.py → 5 passed.

Ready for CI re-check; product/security merge call for Nik still stands once green.

@Git-on-my-level Git-on-my-level added the docs-accuracy Documentation or committed reports need accuracy fixes label Aug 8, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the continued iteration here. The backend shape is much safer now: backend/dependencies.py adds a dedicated get_uid_with_conversations_read_ask dependency, backend/utils/rate_limit_config.py gives the billable RAG path its own dev:ask budget, and backend/routers/developer.py now keeps discarded conversations out of retrieval and re-checks is_locked on the hydrated Firestore records before building the LLM context.

I still think this needs one fix / maintainer sign-off before merge:

  • docs/api-reference/app-client-openapi.json documents POST /v1/dev/user/ask with firebaseBearer security, while docs/api-reference/openapi.json and backend/route_policy_manifest.yaml describe the same route as developer-API-key protected (developerApiKey, developer_api_key, conversations:read). Because these OpenAPI files drive SDK/client generation and are also used by coding/review agents as API-contract documentation, this mismatch can teach agents and generated app clients to call a developer API with the wrong auth scheme. Please either remove this endpoint from the app-client spec or make the security/auth contract consistent with the actual backend route, whichever is the intended product surface.

Other file-specific observations from this pass:

  • backend/routers/developer.py: the endpoint is read-only, limits question length, caps retrieval at 10 conversations, excludes discarded hits, filters locked records post-hydration, and only calls qa_rag after it has at least one unlocked conversation.
  • backend/tests/unit/test_dev_ask_endpoint.py: good regression coverage for grounded answers, empty retrieval avoiding LLM cost, include_discarded=False, locked-conversation filtering, and the dedicated dev:ask dependency.
  • sdks/python-cli/omi_cli/main.py and sdks/python-cli/tests/test_ask.py: the CLI is a thin wrapper over /v1/dev/user/ask, preserves JSON mode, and covers default limit behavior.
  • desktop/macos/Desktop/Sources/Generated/OmiApi.generated.swift and the generated TypeScript clients add the ask helper consistently with the generated contract; that is exactly why the OpenAPI auth mismatch above matters before the generated artifacts are relied on.
  • .github/scripts/product_file_line_count_ratchet_baseline/backend-routers.json updates the router ratchet with a specific justification for this endpoint, including the locked/discarded-conversation guardrails.

Requesting changes only for the API-contract/auth mismatch in the app-client OpenAPI surface. The agent-behavior documentation impact is real here: the changed OpenAPI docs may alter how AI coding/review agents and generated-client workflows reason about this endpoint, so the contract should be unambiguous before human maintainer sign-off.


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

aryanorastar and others added 2 commits August 9, 2026 10:27
The ask route is developerApiKey-only; including it in the Firebase
app-client contract stamped firebaseBearer and mis-taught agents/SDKs.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Addressed review @f2e669416af9

@Git-on-my-level Blocker fixed — removed POST /v1/dev/user/ask from the app-client OpenAPI surface (your preferred option: keep the Firebase app-client contract unambiguous).

  • backend/scripts/export_openapi.py: APP_CLIENT_EXCLUDED_ROUTES + filter in app_client_contract_routes; app-client validate fails closed if the route leaks back in
  • Regenerated docs/api-reference/app-client-openapi.json and the derived TS/Swift clients (ask helpers dropped from app clients)
  • Public openapi.json unchanged: still developerApiKey only (matches route_policy_manifest.yaml / dev:ask)
  • Regression: test_ask_lives_on_public_developer_api_not_app_client_firebase — 6/6 test_dev_ask_endpoint.py passed locally

Also merged latest main into the tip before the fix.

Ready for re-review / dismiss CR; product/security merge call still stands for Nik once green.

@aryanorastar

aryanorastar commented Aug 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Formatting fix @f0a64cbbce

tip f2e669416a was Formatting-red on backend/scripts/export_openapi.py (black 26.5.1 would reformat the new app_client_contract_routes guard).

Pushed f0a64cbbce — black --line-length 120 --skip-string-normalization only; no behavior change.

App-client OpenAPI exclusion from your CR is unchanged:

  • /v1/dev/user/ask kept out of app-client OpenAPI (APP_CLIENT_EXCLUDED_ROUTES)
  • public openapi.json still developerApiKey / dev:ask
  • regression test_ask_lives_on_public_developer_api_not_app_client_firebase

Ready for CI re-check + dismiss CR; product/security merge call for Nik still stands once green.

…lict

Keep main router baselines (apps 2419, mcp_sse 1988) and the BasedHardware#10314
developer.py ask justification at measured 2371 lines.
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level @kodjima33 @beastoin need human response

Conflicts cleared on tip 575602994e (merge/main).

Conflict: only .github/scripts/product_file_line_count_ratchet_baseline/backend-routers.json — kept main router baselines (apps 2419, mcp_sse 1988) and the #10314 developer.py ask justification at measured 2371.

Prior CR (app-client OpenAPI auth mismatch) still on tip from f2e6694 / f0a64cb:

  • /v1/dev/user/ask excluded from app-client OpenAPI (APP_CLIENT_EXCLUDED_ROUTES)
  • public openapi.json remains developerApiKey / dev:ask
  • regression test_ask_lives_on_public_developer_api_not_app_client_firebase
  • local test_dev_ask_endpoint.py → 6 passed

Please dismiss CR once CI re-checks green. Remaining gate: Nik product/security merge for the public billable /v1/dev/user/ask + omi ask surface (needs-maintainer-review / security-review). Author-side clear.

Hygiene rejects shards with version instead of threshold; keep BasedHardware#10314
developer.py raise at 2371 with the required schema keys.
@aryanorastar

aryanorastar commented Aug 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

need human response

Hygiene red on 575602994e was author-side from the conflict resolution: backend-routers.json kept version and dropped required threshold.

Fixed on tip (this push): shard keys are exactly files / raise_justifications / threshold: 1500; developer.py still 2371 with the #10314 ask justification. Local check_product_file_line_count_ratchet.py --base origin/main → OK.

App-client OpenAPI exclusion from your CR unchanged — please dismiss once CI re-greens; Nik product/security merge still the remaining gate.

@Git-on-my-level
Git-on-my-level dismissed their stale review August 9, 2026 21:18

Resolved on ec8e53e: /v1/dev/user/ask is excluded from the app-client OpenAPI and documented only with developerApiKey in the public contract.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution and removed docs-accuracy Documentation or committed reports need accuracy fixes labels Aug 9, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the continued iteration here. The specific API-contract blocker from my previous review looks resolved on this head: backend/scripts/export_openapi.py now excludes POST /v1/dev/user/ask from the app-client Firebase contract, docs/api-reference/openapi.json documents it under developerApiKey, and the new backend test verifies it is absent from docs/api-reference/app-client-openapi.json.

File-specific review notes from this pass:

  • .github/scripts/product_file_line_count_ratchet_baseline/backend-routers.json: the router ratchet is updated only for backend/routers/developer.py, with a specific justification covering the new ask endpoint and the locked/discarded-conversation guardrails.
  • backend/dependencies.py: get_uid_with_conversations_read_ask keeps the required conversations:read scope and adds the dedicated dev:ask rate-limit policy before returning the uid.
  • backend/route_policy_manifest.yaml: the new route is recorded as public developer API, developer_api_key auth, conversations:read, dev:ask, and conversations data-domain, which matches the implementation.
  • backend/routers/developer.py: DeveloperAskRequest bounds the question and limit, retrieval uses include_discarded=False, hydrated Firestore records are filtered for is_locked, and qa_rag is only called when at least one unlocked conversation remains.
  • backend/scripts/export_openapi.py: the app-client exclusion list/validator prevents this developer-API-only route from being emitted into the Firebase app-client OpenAPI surface, resolving the earlier auth-contract mismatch.
  • backend/tests/unit/test_dev_ask_endpoint.py: coverage now exercises grounded answers, no-context/no-LLM behavior, discarded retrieval exclusion, locked-record filtering, the dev:ask dependency, and the public-vs-app-client OpenAPI contract.
  • backend/utils/rate_limit_config.py: dev:ask is capped like the existing billable conversation-create path rather than inheriting the cheaper list-read budget.
  • docs/api-reference/openapi.json: the generated public OpenAPI adds the ask request/response/source schemas and shows developerApiKey security for /v1/dev/user/ask.
  • sdks/python-cli/omi_cli/main.py: omi ask is a thin CLI wrapper over /v1/dev/user/ask, including JSON mode and source rendering.
  • sdks/python-cli/tests/test_ask.py: CLI tests cover the default payload and JSON-mode passthrough for the new command.

I’m leaving this as a positive signal rather than a formal approval because this is still a product/security-sensitive developer API endpoint that answers from user conversation data via an LLM. The agent-behavior documentation impact is now handled more safely: the OpenAPI contract and exporter should steer generated clients and AI coding/review agents toward the developer-API-key auth surface, not the app-client Firebase surface. Human maintainer sign-off is still warranted for the product direction and user-data/RAG exposure before merge.


by AI on behalf of David — product direction and user-data/RAG API exposure need human maintainer sign-off before merge.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin @Git-on-my-level need human response

Author-side clear on ec8e53efe8:

  • David dismissed the app-client OpenAPI CR; positive-signal (no further code changes)
  • APPROVED (kodjima33) + MERGEABLE CLEAN + all checks green
  • Safeguards still in place: fail-closed dev:ask 25/hr, include_discarded=False, post-hydration is_locked re-check, ask kept out of app-client Firebase OpenAPI

Remaining gate is only the human product/security merge for public billable /v1/dev/user/ask + omi ask (needs-maintainer-review / security-review). Please merge or explicit hold when ready.

@undivisible undivisible added human Human-authored pull request workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior labels Aug 10, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Current status is genuinely CONFLICTING/DIRTY against its old base; GitHub also refuses update-branch due to conflicts. The CLI/API implementation has an existing positive approval and green historical checks, but this branch needs a clean refresh onto current main before merge.

@Git-on-my-level Git-on-my-level removed the workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior label Aug 11, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for the continued iteration here. I re-reviewed the current head and the earlier blockers I can verify from the diff look addressed: the ask path now has a dedicated billable-endpoint rate limit, filters discarded conversations before retrieval, re-checks locked conversations after hydration, and keeps the Developer-API-only route out of the app-client OpenAPI contract.

File-by-file notes:

  • .github/scripts/product_file_line_count_ratchet_baseline/backend-routers.json: the ratchet baseline is updated only for the added developer.py route code, and the justification names the privacy/rate-limit boundaries for this endpoint.
  • backend/dependencies.py: get_uid_with_conversations_read_ask() keeps the existing conversations:read scope check and adds a separate fail-closed dev:ask rate-limit policy before returning the uid.
  • backend/route_policy_manifest.yaml: the new route is explicitly recorded as developer-API-key auth with conversations:read, dev:ask, public visibility, and conversations data ownership.
  • backend/routers/developer.py: ask_conversations() strips the question, bounds the request model, calls search_conversations(..., include_discarded=False), filters hydrated Firestore records with not c.get('is_locked'), and only then builds the cited qa_rag context.
  • backend/scripts/export_openapi.py: the app-client exporter now has an explicit exclusion for POST /v1/dev/user/ask and validation that fails if this Developer-API-only route leaks into the firebaseBearer app-client contract.
  • backend/tests/unit/test_dev_ask_endpoint.py: the focused tests cover the grounded-answer path, no-LLM-on-empty retrieval, discarded/locked conversation filtering, the dev:ask dependency, and the public-vs-app-client OpenAPI contract.
  • backend/utils/rate_limit_config.py: dev:ask is capped at the same hourly budget as the existing billable developer conversation-create path and below the cheap list-read budget.
  • docs/api-reference/openapi.json: the public API contract documents /v1/dev/user/ask with developerApiKey security, the bounded request fields, and the cited response shape; I also checked that app-client-openapi.json no longer contains this route.
  • sdks/python-cli/omi_cli/main.py: omi ask is a thin CLI wrapper that posts question, limit, and timezone, emits raw JSON in --json mode, and otherwise renders the answer plus source list.
  • sdks/python-cli/tests/test_ask.py: the CLI tests cover default payload generation/source rendering and JSON-mode output.

Validation I could run locally was limited by this review worker not having the repo Python environments installed (firebase_admin missing for the backend focused test and respx missing for the CLI focused test). I did run a static contract check on the checked-out head confirming the public OpenAPI contains /v1/dev/user/ask with developerApiKey and the app-client OpenAPI does not contain that route. The GitHub checks in the context are green for the backend gates.

Agent/docs behavior impact: docs/api-reference/openapi.json is agent-readable API contract documentation. This update should steer generated clients and coding/review agents to use Developer API key auth for omi ask, while the exporter guard prevents agents from learning the wrong firebaseBearer app-client contract. The guidance looks safer than the previous mismatch, but because this is a new conversation-data + LLM Developer API surface, product/security sign-off should still stay with a human maintainer before merge.

I’m leaving this as a positive signal rather than a formal approval because this remains a new Developer API capability over user conversation data and billable RAG behavior, so maintainer sign-off is needed for the product/security contract and merge timing.


by AI on behalf of David — leaving for human maintainer review on the developer-API data/LLM contract and product direction.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Superseded by clean current-main replacement PR #11452. The verified Developer API/CLI implementation is preserved in a 10-file delta without the stale baseline conflict or historical branch churn.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Superseded by #11452, cleanly based on current main.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @aryanorastar 👋

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

backend Backend Task (python) human Human-authored pull request needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants