How surfaces boot¶
OpenSRE can be reached in several ways — the opensre CLI, the interactive
shell, the gateway daemon (chat channels), the gateway's web app, scheduled
cron commands, and even a plain Python script embedding the agent. Each of
them starts up by running the same shared setup —
configure_process(<profile>), which runs the ordered steps in
infrastructure/process/boot.py — rather than assembling
its own startup sequence. A surface's own code is responsible only for its
channel and UX (rendering to a terminal, replying in chat, serving an HTTP
route, parsing CLI arguments) plus any prerequisites specific to that
surface; some surfaces do a little of their own setup before or after the
shared steps run (see "Where each surface calls it" below).
What the shared setup does¶
Startup is a short checklist of setup work that has to happen in the same order every time:
- Load the environment — read configuration and secrets.
- Start error reporting — so failures later in startup are still captured when the selected profile owns Sentry.
- Register adapters — connect the agent to the integrations and tools it can use.
- Register scheduled-delivery adapters — bind outbound delivery for scheduled work. Agent runners are constructed by the scheduler host at startup rather than stored globally.
- Log capability warnings — flag anything the sandbox can't do in this environment.
- Preload the LLM client modules — so a long-running process doesn't end up mixing old and new versions of those modules after a later code change.
- Pull skills — start a background refresh of the skill catalog. A pulled release applies on a later turn, never mid-turn.
Not every surface needs every step. A profile is just a name for "the subset of this checklist a given surface needs" — the CLI needs far less than the gateway daemon does. Running the shared setup with a profile performs exactly those steps, in the order above, and running it again for a surface that's already started is a harmless no-op.
The six profiles¶
| Profile | What it sets up | Used by |
|---|---|---|
| CLI | Environment, skills pull. | The opensre command |
| Gateway | Environment, error reporting, adapters, capability warnings, LLM preload, skills pull. | The gateway daemon (chat channels) |
| Web | Environment, error reporting, adapters. | The gateway's standalone web app |
| Scheduler worker | Environment, error reporting, adapters, scheduled-delivery adapters, skills pull. | The opensre cron start daemon |
| Scheduled command | Environment, adapters, scheduled-delivery adapters. | One-off CLI commands that create, run, or dispatch scheduled work |
| Embedded | Environment, adapters. | Driving the agent from another Python program |
Where each surface calls it¶
- CLI —
surfaces/cli/startup.pyruns the CLI profile first, then handles CLI-only setup: its own error reporting (tolerant of a missing dependency duringopensre update), terminal output styling, and keyboard-interrupt handling.main.py, the module-level entry point (python main.py), delegates straight into this same CLI path — it does not use the embedded profile.python -m surfacesis that same entry. (The embedded profile only appears inmain.py's docstring, as an illustrative example for someone embedding the agent in their own script.) The interactive shell runs inside this same already-started CLI process, so it doesn't start up again. - Interactive shell's saved loops — when a saved prompt loop needs its
own background scheduler,
surfaces/interactive_shell/runtime/loop_scheduler.pyruns the scheduled-command profile. Slash commands inloops_cmds.pyreload through that module; they do not boot a second profile themselves. - Gateway daemon —
gateway/core/lifecycle/controller.pysets up its own logging, readiness state, and credentials first, then runs the gateway profile before connecting chat channels. When it also hosts the scheduler, the controller installs the scheduled-delivery adapters and constructs the gated scheduler runners at that later lifecycle stage. - Gateway web app —
gateway/web/webapp.pyruns the web profile as soon as the module loads, so both the in-process gateway and a standalone web server have everything they need before handling a request. - Scheduled/cron CLI commands — one-off commands like
cron runinsurfaces/cli/commands/cron.pyandsentry_digest.pyrun the scheduled-command profile.posthog_report.pychecks that the PostHog integration is configured first, then runs the same profile. The long-runningcron startdaemon uses the scheduler-worker profile instead, since it needs its own error reporting and only needs to register task runners once, not on every run. - Embedded Python usage —
surfaces/embedded.pystart_embedded_session()runs the embedded profile and thenAgentSession.start. That is the call to use from another Python program. It isconfigure_process(EMBEDDED_PROFILE)followed bystart;startitself does not register adapters, becausecoremay not import the hosts above it.
Why it works this way¶
Keeping one shared startup checklist means every surface gets the same
guarantees — nothing is skipped, and nothing runs out of order — no matter
how it's launched. It also means adding or changing a startup step only
needs to happen in one place. For how this fits into OpenSRE's broader
package layout, see docs/ARCHITECTURE.md.
Markdown source: View on AtomGit·Content from the open-source project op/opensre