Skip to content

Coding Sessions

A coding session serves a code-specialized language model on an RCC GPU node and connects it to a coding tool that reads and edits source code in your project folder or git repository. No prompt, file content, or completion leaves the cluster. The command-line tools (aider, opencode) run in the terminal where your code already lives, over SSH, with no graphical display needed and no copy of the repository on your laptop. A session holds its node (GPUs, or CPU cores for a CPU session) from start until you stop it, busy or idle. Usage is reported to you as the tokens the session consumed, printed when you stop it (see Billing and Service Units for the policy behind it).

The command is ai-session code, the coding counterpart to the browser-chat ai-session chat on Getting Started. The difference in shape: a coding tool is an interactive program you drive by hand, not a background server, so ai-session code starts the session and the gateway — the small always-on connection point the service runs on the login node — and then prints a short READY box telling you how to start a client, which you run yourself in the repository you want to edit. The default client is aider (which requires your project folder to have a git project); Continue, opencode and Cline, and Claude Code connect to the same endpoint. The pipeline is the same three pieces described on AI Sessions on RCC: a model server on a GPU node, the gateway (which gives every session one stable web address in the standard OpenAI API format that most AI tools can talk to, and records token counts), and your client.

Quick Start

Step Description Command Run on
0 Put ai-session on your PATH (once per shell) module load ai-session Login node
1 Start the session; wait for the READY box ai-session code (first run: add --account <acct> --partition <part>) Login node
2 Check whether it is ready (from any terminal) ai-session status Login node
3 In the git repository you want to edit, start a client aider, or eval "$(ai-session env)" then opencode Login node or Local machine
4 Stop the session, free the node, print the tokens consumed ai-session stop Login node

Step 1: Start the session and gateway

Run this on the login node, inside tmux or screen, so that an SSH disconnect does not take the connection point down with it:

ai-session code

The command submits the model server to a GPU node, waits until the model is loaded (typically several minutes for the default 27B model), starts the gateway, and prints a READY box. Leave this terminal running.

Before the job is submitted it prints usage is reported as the tokens this session consumes (shown when you stop it). While the model loads, a banner says the session is not ready yet:

==================================================================
  vLLM is starting -- PLEASE WAIT. The session is NOT ready yet.
  Do not start opencode or aider (or open an SSH tunnel) until
  you see the READY box with the connection settings. Progress
  is shown below; from another terminal, `ai-session status`
  shows it too.
==================================================================

Progress lines with the elapsed time follow, for example [1:40] compiling and warming up the model .... The stages, in order, are: waiting for a compute node; loading the model weights; compiling and warming up the model; starting the API server; finishing start-up. If the model server stops while loading, start-up ends at once with the path of the server log rather than waiting out the time limit.

Options: --account NAME and --partition NAME name the Slurm account and GPU partition to run under — required on your first session and then remembered in ~/.ai-session/config (see Getting Started); --time HH:MM:SS sets the session time limit (default 02:00:00; the session ends after this even if you forget to stop it, which caps how long it can hold the node); --model KEY serves a different registered model; --agent enables native tool calling, required by opencode and Cline and by Claude Code but not by aider or Continue; --cpu runs the session on a CPU-only node instead (see CPU sessions).

A running session holds its node whether or not you send requests

ai-session code reserves GPUs until the session ends. Stop it as soon as you finish: ai-session stop

Is it ready? ai-session status

ai-session status is the ready flag. Run it from any terminal on the same login node; it costs nothing. It prints one of:

session: STARTING -- compiling and warming up the model (1:40 elapsed).
  NOT ready yet: do not open the tunnel. Run `ai-session status` again in a minute.
session: READY -- open the tunnel now.
  client settings: ai-session connect
session: FAILED -- the model server stopped while loading.
  log: <path to the server log>

Verification — the start command ends with a READY box of this form:

================ READY -- coding session: qwen3.8_27B ================

  In your git repository on this login node (<login-node>):

    eval "$(ai-session env)"     # loads the URL, access key and model

  then start a client:

    opencode      (first: module load opencode)
    aider

  From your laptop instead, open a tunnel first, then copy the settings
  that `ai-session connect` prints:

    ssh -N -f -L <GW_PORT>:localhost:<GW_PORT> <cnetid>@<login-node>.rcc.uchicago.edu

  Access key: <key>
  (lab members may use it too; their usage is recorded under you, <cnetid>)
=======================================================================

`ai-session connect` shows these settings again; `ai-session stop` ends the session.

On a session started without --agent, the opencode line adds -- needs a session started with --agent. If the command exits with an error instead, see Troubleshooting.

Step 2: Run the coding tool

Open a second terminal, change into the git repository you want to edit, and start a client. No configuration file is needed for aider or opencode:

cd /path/to/your/repo
aider                                   # reads the running session's settings itself
module load opencode                    # opencode needs a session started with --agent
cd /path/to/your/repo
eval "$(ai-session env)"
opencode

aider requires the working directory to be inside a git repository; run git init first if necessary. Per-client setup and usage:

Before running any autonomous agent, read Agent responsibilities and risks: an agent acts with your full cluster permissions, can read anything you can read (including shared project directories), and its actions and the node time it uses are your responsibility.

To run the tool on your laptop instead of the login node, first open the SSH tunnel (next section).

Verification — on the login node, confirm the connection point answers before starting the client (exits 0 when healthy):

curl -sf "http://127.0.0.1:<GW_PORT>/__gateway/health"
  • Replace <GW_PORT> with the port printed at start.

Step 3: Stop the session

Run this on the login node the moment you stop working:

ai-session stop

It meters the session, releases the node, shuts down the connection point, deletes the access key, and prints a TOKEN USAGE box as its last output: the model and where it ran (for example 4 x a100 GPU or cpu), tokens in, out, and total, the number of requests, the job id, and the path of the receipt file written under your state directory. ai-session receipt prints the newest box again. No SU figure is printed. ai-session stop and ai-session status hold no node themselves; only the running session does.

Verification — ai-session status afterwards reports no session running and no access key set.

Connection parameters

Every client uses the same four values. After the session is up, one command loads them into your shell:

eval "$(ai-session env)"

This sets AISESSION_BASE_URL, AISESSION_API_KEY, AISESSION_MODEL, and AISESSION_DEVICE (gpu or cpu); OPENCODE_CONFIG_CONTENT, an inline opencode configuration, so opencode needs no opencode.json; and OPENAI_API_BASE, OPENAI_API_KEY, and AIDER_* settings for aider. The same lines are written to ~/.ai-session/env (mode 600). Note that it replaces any OPENAI_API_KEY you had in that shell with the session key. Run it again after each new session start; the key changes every time. ai-session connect prints the literal values and ready-to-paste setup for every client.

Parameter Value
Base URL $AISESSION_BASE_URL — http://localhost:<GW_PORT>/v1; the port is derived from your numeric user ID (8400 + UID % 90), so it differs per user
API key $AISESSION_API_KEY — the session access key (see below)
Model name qwen3.8_27B (default), or gemma4_31B / qwen2.5_72B / qwen3_4b, or qwen2.5_0.5B on a CPU session; must equal the model you started
Context window 32768 tokens for coding sessions (8192 for chat sessions)

The model name is the identifier the server exposes. Clients that route through litellm (aider, Continue) prefix it with openai/ to select the standard format, for example openai/qwen3.8_27B.

The session access key

Starting a session mints a random access key, and every request to the session must carry it. ai-session code prints it in the READY block and saves it, readable only by you, at <state-dir>/logs/gateway/session_key (mode 600); ai-session connect and ai-session status (first six characters only) also show it. eval "$(ai-session env)" loads it as AISESSION_API_KEY; aider and ai-session claude load it themselves. Use it as the API key in every client.

Because the connection point binds to 127.0.0.1 and accepts only requests carrying the key, no one else on the shared login node can use your session by accident, and you can deliberately share it with your lab: give a labmate the key, have them open their own tunnel to your GW_PORT, and set the key as the API key in their client. All of their usage is recorded under you, the starter — one key per session, no per-person split. A request without the key is refused with HTTP 401. ai-session stop deletes the key file, so the key stops working when the session ends and the next start mints a fresh one. Only a gateway RCC staff start by hand with no key configured is keyless, in which case any non-empty string works.

Remote access from your laptop

The connection point listens on 127.0.0.1:<GW_PORT> on the login node where you started the session, so a client on your laptop needs a forwarded port. Run this on your local machine and leave it running:

ssh -N -L <GW_PORT>:localhost:<GW_PORT> <cnetid>@<login-node>.rcc.uchicago.edu
  • Replace <GW_PORT> with the port printed at start (both occurrences).
  • Replace <cnetid> with your CNetID.
  • Replace <login-node> with the login node named in the start output; the tunnel must target that node, not an arbitrary one.

ai-session code prints a ready-made tunnel command in the READY box with the node filled in — the same single-connection form, with -f added so the tunnel backgrounds itself once connected. Open it only after the READY box appears (or ai-session status reports READY), then copy the client settings from ai-session connect. Only if your network cannot reach the named login node directly, jump through the round-robin alias as a fallback (this authenticates twice): ssh -N -L <GW_PORT>:localhost:<GW_PORT> -J <cnetid>@midway3.rcc.uchicago.edu <cnetid>@<login-node>. The client on your laptop then uses http://localhost:<GW_PORT>/v1 as its base URL. When the client runs on a login node, no tunnel is needed; use the same localhost URL directly. For what an SSH tunnel is and how to debug one, see Getting Started.

Choosing a model

The code preset serves qwen3.8_27B (Qwen3.8-27B). Three other served models are reachable with --model:

  • ai-session code --model gemma4_31B — the second coding option, and the cheapest capable one. See Choosing between the two coding models.
  • ai-session code --model qwen3_4b — the small model, for debugging, quick questions, or simple edits. It holds one GPU at the 1.0 SU/h floor, and it is the cheapest option for --agent clients and MCP tools (see opencode and Cline and Agent responsibilities).
  • ai-session code --model qwen2.5_72B — the general 72B model, for mixed code-and-prose work or when the larger general model is specifically wanted. It is also the model behind the web interface.

The right GPU configuration is chosen for you in each case.

Model key Parameters GPUs it runs on Prefill (tok/s) Decode (tok/s) Reservation floor
qwen3_4b (cheapest; debugging, simple edits, tool calling) 4B 1 x A100-80GB 22167 5114 1.0 SU/h
qwen3.8_27B (default; thinking model, accepts images) 27.8B 2 x A100 — — 2.0 SU/h
gemma4_31B (alternative; thinking off by default) 30.7B 2 x A40 2301 349 1.0 SU/h
gemma4_31B (on A100 40GB — slower and dearer, see below) 30.7B 2 x A100 3337 336 2.0 SU/h
qwen2.5_72B 72B 4 x A100-80GB 2914 1191 4.0 SU/h

Throughput figures are aggregate, measured by the billing benchmark at concurrency 64 over prefill-heavy, decode-heavy, and balanced request mixes. They are the basis of the per-token charge, not the latency one user perceives (next section). The reservation floor is the minimum charge for a session — the GPU-type weight times the number of GPUs times the hours held; a session bills the larger of the metered token work and this floor. The canonical rate table and the full formula are on Billing and Service Units. Advanced serving overrides are handled by RCC staff; ask them, or see the staff guide in the repository.

Each of these reserves GPUs until you stop the session

The session holds its GPUs from the moment it starts, busy or idle. Stop with ai-session stop.

Choosing between the two coding models

Both are Apache-2.0, both handle tool calling, both accept images. They differ in how they spend your GPU time.

qwen3.8_27B (default) gemma4_31B
size 27.8B, 51.8 GiB 30.7B, 58.3 GiB
thinking on by default (reasoning_effort low/medium/xhigh) off by default, opt-in
runs on A100, H100 A40, A100
cheapest floor 2.0 SU/h (2 × A100) 1.0 SU/h (2 × A40)
our code benchmark 50.0% 66.7%

Start with the default. qwen3.8_27B is the code preset and reasons before answering, which suits hard problems.

Reach for gemma4_31B when you want cheaper, faster turnaround. It scored higher on our own frozen coding benchmark and its A40 configuration is the least expensive way to run a capable coding model here.

The two benchmark figures are not like-for-like

Both were measured on the same frozen 60-problem subset with the same harness and the same greedy decode — but with thinking disabled. That is Gemma's own default mode; it is not Qwen's, whose default is reasoning_effort: xhigh. So 50.0% is a lower bound for qwen3.8_27B and the 16.7-point gap flatters Gemma. Wherever you see the two numbers together, read them with this caveat.

For gemma4_31B, prefer A40 over A100 — it is faster and cheaper

This inverts the usual ordering, so it is worth stating plainly. Measured at TP=2:

2 × A40 2 × A100 40GB
decode 349 tok/s 336 tok/s
KV cache 9.17 GiB (51,325 tokens) 4.71 GiB (26,342 tokens)
cost per 1k output tokens 0.000797 SU 0.001652 SU
reservation floor 1.0 SU/h 2.0 SU/h

An A40 card is 46 GiB against a 40 GiB A100, and this model needs 30.4 GiB per GPU — so the A40 has roughly double the room left for cache. That lets it keep more requests in flight, which more than offsets its slower silicon. Combined with half the GPU-tier charge, A40 works out 2.1× cheaper per token. Pass CONSTRAINT=a40 to pin it.

ai-session code --model gemma4_31B

Gemma can think if you ask it to, per request:

{"chat_template_kwargs": {"enable_thinking": true}}

We measured what that costs: 5–12× the tokens and 5–12× the wall time, with no improvement on the two problems we tried. Under GPU-time billing that is a 5–12× cost multiplier, so leave it off unless a problem genuinely needs it.

qwen3.8_27B: floor billing, and a word about thinking

The coding default has a measured rate for the H100 tier but not for A100, which is where it runs by default. Until an A100 record is measured, its sessions bill the reservation floor for the GPUs held — 2.0 SU/hour — with no token-metered component. Budget on wall-clock, not on tokens.

Separately: this model thinks by default at reasoning_effort: xhigh, which can generate a large number of reasoning tokens and hold the GPU longer than you expect. Pass low or medium for routine edits; keep xhigh for genuinely hard problems.

CPU sessions

--cpu runs a session on a CPU-only node and holds no GPU. It serves one model only, the 0.5-billion-parameter qwen2.5_0.5B (Qwen2.5-0.5B-Instruct); any other --model is refused, and so is --lora. Give a CPU-only partition (amd or caslake) with --partition the first time; it is remembered in ~/.ai-session/config separately from your GPU partition.

ai-session code --cpu --partition amd            # for aider
ai-session code --cpu --agent --partition amd    # for opencode or Claude Code

Measured on amd (16 cores, vLLM 0.26.0 CPU build): the model is ready about 2 to 3 minutes after the job starts. Clients connect exactly as on a GPU session.

A CPU session is for trying the service and checking that a client is wired up correctly, not for coding work: a 0.5B model produces poor edits and cannot use tools reliably. For the same reason opencode and Claude Code run on a CPU session with their tools turned off, because the tool definitions are most of their prompt and a CPU node reads prompts slowly:

Client Prompt with tools Prompt without tools Reply with tools Reply without tools
opencode 15,122 tokens 2,006 tokens about 2.5 min 4 s
Claude Code 15,000–24,000 tokens 5,859 tokens 229 s 32 s

A CPU session also holds its node until you stop it; stop it with ai-session stop, which prints the same TOKEN USAGE box.

Context window and prompt sizing

Coding sessions serve a 32768-token context, within the native context length of every coding model offered. Chat sessions default to 8192.

The aider metadata file declares the split as 28000 input tokens and 4096 output tokens, leaving headroom so that prompt plus generated tokens cannot exceed 32768. If your added files exceed the input budget, aider reports the prompt as too long; see Troubleshooting.

Single-stream generation latency on a two-GPU coding session is on the order of tens of milliseconds per output token — roughly 15 to 30 tokens per second as perceived by one interactive user. The aggregate throughput figures in the table above are much higher because they sum across 64 concurrent requests.

Build your own agent

The listed clients are not the only way to use a session. Because every session exposes the OpenAI chat-completions protocol at the session URL, you can write your own agent in any framework that speaks the standard format (PydanticAI, LangGraph, smolagents, or the OpenAI Agents SDK), pointing it at $AISESSION_BASE_URL with $AISESSION_API_KEY as the API key and a served model name. A runnable, self-contained PydanticAI example ships with the service; the Build your own agent section walks through it.

Every served model populates tool_calls correctly, so any of them works as the reasoning engine for a tool-calling agent; pick on capability and cost as above. Before running an autonomous agent, read Agent responsibilities and risks: it acts with your full cluster permissions and its actions are your responsibility.