How secondly-com/openphone works
1. What this repo is
OpenPhone is not a standalone app repo; it is the OpenPhone-owned control plane for an Android-based phone OS. It contains the Android overlay, privileged assistant app, framework patches, build/release tooling, schemas, and a reference model-broker service. The actual Android source tree is not vendored here; this repo is applied on top of LineageOS 23.2 / Android 16.
2. Top-level architecture
The system is split into four main layers: OpenPhone UI/surface, the privileged assistant runtime, OS-level services/patches, and external model infrastructure. The user interacts with the OpenPhone surface; the assistant turns that into mediated actions; framework services expose device state and execution capabilities; model services provide reasoning, transcription, and realtime voice.
3. Android integration boundary
The overlay/ directory holds the packaged OpenPhone app, resources, and prebuilts that get copied into the Android tree. The patches/ directory modifies upstream AOSP/LineageOS components such as frameworks_base, SystemUI, Settings, system_sepolicy, and build tooling. This is where OpenPhone becomes a system product rather than an app layered on top of stock Android.
4. Privileged assistant runtime
overlay/packages/apps/OpenPhoneAssistant/ is the core app. It is a privileged system component with Compose-based UI (MainActivity, AssistantComposeHost, chat and advanced screens), an AIDL interface, and both Java/Kotlin services. It owns the orchestrator, model adapters, tool execution, policy checks, memory, commitments, watchers, jobs, and audit/export logic.
5. User-facing surfaces
The assistant is exposed through several OS entry points rather than only a launcher icon: an always-available system surface, a Quick Settings tile, a boot receiver, a trigger receiver, a notification listener, and an accessibility service. There is also a pointer overlay/controller for mediated interaction on top of other apps. These surfaces are how the assistant can stay present, be re-entered, and act while the user remains in the phone context.
6. Action execution and OS mediation
Actions are not executed directly against apps from the model layer. They pass through OpenPhone’s action registry/catalog, task registry, framework tool executor, and OS-owned services introduced by platform patches. The framework side includes services such as openphone_agent, openphone_context, and openphone_assistant_data, plus mediated input, screenshot, UI-tree, clipboard, and URL/opening flows. This is the main trust boundary between the assistant and the device.
7. Model and voice layer
The model abstraction is centralized under src/.../model/. It supports multiple backends: Gemini Live voice sessions, OpenAI Realtime voice sessions, OpenAI Responses agent mode, speech transcription, and a local heuristic adapter for fallback or validation. A separate reference Python service in services/model-broker/ brokers model connectivity and deployment, so the assistant can talk to external providers without hardcoding provider-specific access into the app.
8. Context, memory, and proactive automation
The runtime keeps state across turns through several stores: context events/index, memory records, commitments, jobs, watchers, and trajectories. The orchestrator and job scheduler enable background runs, heartbeats, and exact scheduled workflows. Watchers monitor phone state such as notifications, calls, app foreground state, visible screen state, battery, connectivity, and commitments so the assistant can react proactively, not just conversationally.
9. Policy, approvals, and auditability
OpenPhone’s safety model is a first-class subsystem. The policy engine evaluates capabilities and risk, confirmations gate sensitive actions, and audit logging records decisions and evidence. The app also exports trajectories and audit evidence, and the repo includes schemas for action requests/results, audit logs, trajectory events, screen context, and model tools. This makes the system inspectable and reviewable after the fact.
10. Device and platform scope
The first supported target is Pixel 9a (tegu), with generic ARM64 builds used mainly for graph validation. Device notes, bootchain docs, and support matrices live under docs/devices/ and docs/TEGU_BOOTCHAIN.md. The repo also contains Android product manifests for the OpenPhone target and scripts for flashing, device checks, and hardware validation.
11. Build, sync, and release pipeline
scripts/ drives the lifecycle: syncing the Android tree, applying patches, building products, pushing the assistant APK, flashing devices, and running validation/evals. GitHub Actions cover CI, eval, and release workflows. Release artifacts, OTA feeds, and manifests are generated and validated by dedicated scripts and JSON schemas, which indicates a controlled, reproducible release process rather than ad hoc builds.
12. What to draw in an architecture diagram
The key diagram boundaries are: user inputs → OpenPhone surface; surface → privileged assistant; assistant ↔ model broker/external models; assistant ↔ OS services/framework patches; OS services ↔ device context/apps; and assistant/policy ↔ audit/trajectory exports. A separate box should represent the repo’s build/release/tooling plane, because it assembles and validates the system but is not part of runtime execution.
Main entry points: assistant Assistant runtime · scripts Scripts · agent Tool executor · schemas Schemas
Components 21
OpenPhone surface
Packaged Android app and user-facing entry points.
- OpenPhone app · Packaged assistant app and resources injected into the Android tree.
overlay/packages/apps/OpenPhoneAssistant - Assistant UI · Launcher/activity, chat, advanced screens, and shared Compose host.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant - Entry points · QS tile, boot/trigger receivers, accessibility, notification, and pointer overlay entry paths.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant
Assistant runtime
Privileged orchestration, policy, state, and model integration.
- Assistant runtime · Core system assistant component coordinating model calls, tools, state, and safety.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant - Orchestrator · Selects operating mode and drives agent decisions and execution.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/orchestrator - Policy engine · Evaluates capability risk, confirmations, and audit decisions before sensitive actions.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/policy - State stores · Context, memory, commitments, jobs, watchers, and trajectory records.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant - Action catalog · Action registry and tool catalog defining available assistant capabilities.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/actions - Tool executor · Framework tool executor and screen understanding used to execute mediated actions.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/agent - Model layer · Abstracts voice, transcription, and agent backends across providers and local fallback.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/model - Audit export · Trajectory recorder and audit evidence exporter for reviewable action history.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/agent
Platform patches
Android framework and system integration boundary.
- Framework services · Platform-added system services such as agent manager, context, and assistant data.
patches/frameworks_base - Mediation hooks · Foreground context, screenshot, UI tree, clipboard, URL, pointer, and input mediation.
patches/frameworks_base - SELinux policy · Labels and confines assistant-related services and system data access.
patches/system_sepolicy - Settings/SystemUI · System surfaces for agent tile, settings pages, and device/version integration.
patches/packages_apps_Settings
Model infra
External model brokerage and deployment surface.
- Model broker · Reference deployment service that brokers connectivity to external model providers.
services/model-broker/openphone_model_broker.py - External models · Gemini Live, OpenAI Realtime, Responses, transcription, and heuristic fallback.
overlay/packages/apps/OpenPhoneAssistant/src/org/openphone/assistant/model
Build & release
Repo lifecycle, validation, and release automation.
- Scripts · Sync, build, flash, validation, benchmark, release, and device tooling.
scripts - Schemas · Action, audit, trajectory, policy, model tool, OTA, and task data contracts.
schemas - CI & release · Continuous integration, eval, and release workflows for reproducible delivery.
.github/workflows - Manifests · Repo manifest used to sync the Android tree and assemble OpenPhone targets.
manifests/openphone.xml
Connections 25
- OpenPhone app → Assistant UI: contains · The packaged app includes the Compose UI surface and resources.
- OpenPhone app → Entry points: exposes · The app publishes system entry points and background receivers.
- Assistant UI → Assistant runtime: drives · User interactions enter the privileged runtime through UI state and actions.
- Entry points → Assistant runtime: enters · QS, receivers, accessibility, and overlays can start or re-enter the assistant.
- Assistant runtime → Orchestrator: coordinates · The runtime delegates turn and task control to the orchestrator.
- Assistant runtime → Policy engine: checks · Sensitive or risky actions are gated by policy and confirmations.
- Assistant runtime → State stores: persists · Runtime state, jobs, memory, and watchers are stored across turns.
- Assistant runtime → Action catalog: selects · The runtime resolves available capabilities from the action registry.
- Assistant runtime → Tool executor: executes · Approved actions flow into mediated device execution.
- Assistant runtime → Model layer: reasons with · The runtime invokes voice, agent, and transcription backends.
- Assistant runtime → Audit export: records · Decisions and evidence are exported for later review.
- Tool executor → Framework services: calls · Execution uses OS-owned services added by platform patches.
- Tool executor → Mediation hooks: uses · Mediated execution relies on screenshots, UI trees, input, clipboard, and URL flows.
- Framework services → SELinux policy: constrained by · New system services and data paths are labeled and confined by policy.
- Settings/SystemUI → Entry points: adds · System UI and Settings patches add assistant-facing surfaces.
- Model layer → External models: connects · Adapters reach external providers or local fallback logic.
- Model broker → External models: brokers · The reference broker mediates deployment connectivity to providers.
- Scripts → Manifests: syncs · Automation uses manifests to assemble the Android tree.
- Scripts → Assistant runtime: builds · Build and push scripts package and deploy the assistant app.
- Scripts → Framework services: applies · Patch application and build steps produce the platform integration layer.
- Scripts → Model broker: deploys · Tooling supports broker setup, smoke tests, and secret rotation.
- Scripts → Schemas: validates · Release and eval scripts validate generated artifacts against schemas.
- CI & release → Scripts: orchestrates · GitHub Actions run the repository automation in CI, eval, and release flows.
- Schemas → Audit export: defines · Schemas describe exported audit, trajectory, and action records.
- Schemas → State stores: defines · Schemas also capture jobs, tasks, policy, and screen context contracts.