How Jian works
The gateway, hosts, workers, storage, and the lifecycle of an agent turn.
The gateway is the owner of the agent's state and execution. Closing a browser tab does not move or delete that state. Changing from a local gateway to a server gateway selects a different installation, with its own agents and credentials.
Two ways to run a gateway
| Property | Desktop local gateway | Server gateway |
|---|---|---|
| Started by | The desktop app | Your process manager or containers |
| Database | Embedded PGlite in the app's data directory | PostgreSQL |
| Run execution | In-process local executor | PostgreSQL-backed pg-boss jobs |
| Network listener | Loopback only (127.0.0.1) | Configured host/port, normally behind the web service |
| Panel | Mounted inside the desktop app | Web panel; desktop clients can connect too |
| Messaging channels | Disabled | WhatsApp, Telegram, API channels |
| Lifetime | While the app process runs | While the server runs |
| Default time zone | This computer's system zone | Gateway environment/system configuration |
Both run the same gateway services and HTTP contracts. Local mode changes storage, execution, and available channels; it is not a separate toy agent runtime.
Network topology
Desktop on this computer
└─ local gateway (loopback)
├─ embedded database + agent workspaces
└─ configured model providers / integrations
Browser or desktop connected to a server
└─ HTTPS reverse proxy
└─ jian-web :3000
└─ gateway :4310
├─ PostgreSQL + job queue
├─ model providers / integrations
└─ tasks for connected machines
↑ outbound HTTPS polling
Jian Remote on each machineThe production Compose stack publishes the web service, not the gateway or database. Its host port defaults to 4310, forwarded to web port 3000; the gateway's internal API still uses 4310. Development uses a different arrangement: web on 3000, gateway on 4310.
What happens when you send a message
- A panel, channel, schedule, or another agent supplies a request for a profile and conversation.
- The gateway authenticates it, validates the request, persists the message, and creates or finds its run. Request keys keep a retried submission from becoming another turn.
- The run snapshots the relevant profile and model choices. Jian builds model input from instructions, identity, relevant memories, history or a compaction summary, and discovery catalogs for skills and tools.
- The model can answer, load a skill, call a tool, request approval, or ask a question. Tool results become context for subsequent steps.
- Progress and outcomes are persisted. The panel follows that state; channel delivery has its own outcome.
- A run finishes, fails, is cancelled, or waits for a decision. An open objective can queue another slice of work. A qualifying completed turn can trigger a learning review.
A session is the durable conversation. A run is one execution turn. A tool call is one action inside a run. A new reply or automatic continuation can start another run in the same session.
Ownership and isolation
| Agent-specific | Gateway-wide |
|---|---|
| Identity and instructions | Provider connections and credentials |
| Memories and custom skills | Model defaults |
| Conversations and history | MCP servers and GitHub connections |
| Schedules and channels | Connected machines |
| Workspace | Gateway authentication and encryption keys |
Profiles do not receive each other's private records. They can exchange deliberate messages using agent collaboration. Shared integrations and machines are not private per-agent security compartments: every agent can reach the installation's connected machines.
Where the work happens
Gateway file and shell tools act in that profile's workspace on the gateway host. Remote tools act on the selected connected machine, as the local account running its worker. In a container deployment, a gateway path is a container path; it is not a file on the laptop displaying the panel.
The gateway does not run model weights merely because it runs locally. A cloud provider still receives model requests. For a separately hosted compatible model service, the gateway must be able to reach that service's endpoint.
Implementation reference
Local entry point, server entry point, and context assembly.