A session is a running instance of an agent on a specific wallet. Starting an agent creates a session that ties together your run/unwind functions, a wallet, an execution mode (auto or manual), and the user’s asset allocations.Sessions persist across execution cycles — your run function is called repeatedly at intervals, not just once.
User starts agent | v +--------+ | Created | -- Session initialized, assets allocated +----+---+ | v +---------+ | Running | -- run() called on each interval +----+---+ | +---- User pauses --> Paused (session open, no run cycles) | | | +---- User resumes --> Running | +---- User stops --> Stopped (session ends) | +---- User unwinds --> unwind() called --> Stopped
Circuit calls your run function on a recurring interval defined by runtimeIntervalMinutes in circuit.toml:
runtimeIntervalMinutes = 15
By default (schedule = "rolling"), the interval starts after the previous run completes — not from the start of execution. If you set schedule = "fixed" in circuit.toml, runs align to clock boundaries instead (e.g. every 60 minutes at :00, every 15 minutes at :00, :15, :30, and :45). Each cycle is independent: your function receives a fresh AgentContext each time. To persist state between cycles, use Memory.
Called when a user wants to unwind. It receives the session portfolio to close, which may be a subset of total holdings.
def unwind(agent: AgentContext, portfolio: SessionPortfolio) -> None: for balance in portfolio.balances: # Reverse each balance (e.g., swap back to starting asset) for position in portfolio.positions: # Close each market exposure (Hyperliquid perp or Polymarket position)
Configured via allowedExecutionModes in circuit.toml:
auto — Transactions execute immediately
manual — Transactions become suggestions for user approval
Your code is identical in both modes. Circuit routes the request based on the session’s mode. In manual mode, the response includes suggested and suggestionId fields.
All pending suggestions are automatically soft-deleted at the beginning of each run execution. Pass an expiresAt timestamp (ISO 8601) to supported suggestion-producing methods if you need a shorter expiry window.
Users can pause a running agent from the Circuit dashboard. While paused:
The session stays open and asset allocations remain in place
No run cycles are executed — the agent is effectively idle
Memory and session state are preserved
When the user resumes, execution picks up on the next scheduled interval as if the agent had never stopped. No data is lost.Pausing is useful when a user wants to temporarily halt an agent during volatile market conditions or while reviewing activity, without fully unwinding positions.
Multiple agents per wallet — a wallet can run different agents simultaneously (Hyperliquid agents included). However, the same agent cannot run twice on the same wallet.
Shared Hyperliquid collateral — multiple Hyperliquid agents can share a wallet, each allocated a slice of its USDC collateral. They share account-level liquidation risk (the account nets their positions), so manage exposure accordingly.
Session memory persists across run cycles within a session, but is cleared when the session ends.
agent.portfolio reflects holdings at the start of each run execution — not live balances.
Uncaught exceptions in run or unwind are caught by the SDK automatically. The execution is marked as failed and the error is logged.