Skip to content

feat: install fctl in sandboxes and let agents name their sessions - #33

Merged
kalaspuff merged 8 commits into
mainfrom
fctl/9-let-s-have-fctl-installed-in-the-image-w
Oct 18, 2026
Merged

kalaspuff merged 8 commits into
mainfrom
fctl/9-let-s-have-fctl-installed-in-the-image-w

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Session lists showed each session's first prompt, cut off ("Work on issue https://github.com/…", "Can you implement …"), because a session's title is the first line of its task. Now the agent names the session after the work, describes it in a sentence or two, and renames it when the work turns to something else.

In the sandbox

  • The default image installs fctl in /usr/local/bin with fctl.sh's installer. fctl host image build passes its own version (FCTL_VERSION) and download_base (FCTL_DOWNLOAD). A version that isn't published falls back to the latest release.
  • New: fctl edit [SESSION] --title … --description …. In a sandbox with no session given, it talks to fctl-agent over a new session socket beside the host's (agent.session.sock, FCTL_SESSION_SOCKET). The agent needs no fctl credentials and can only reach its own session. Anywhere else the command goes through PATCH /sessions/{id}, so people can rename and describe sessions too. fctl show prints the description.
  • At each Claude start, fctl-agent writes ~/AGENTS.md (beside the checkout in ~/workspace) saying when and how to name the session, and imports it from Claude's user memory (~/.claude/CLAUDE.md). Not a file above the checkout: Claude Code's default instructionFiles mode skips an AGENTS.md there whenever the repository has a CLAUDE.md, and a CLAUDE.md there would switch off an AGENTS.md-only repository's own instructions. I checked with Claude Code 2.1.302's /context that the import loads ~/AGENTS.md once in all four cases: a repo with a CLAUDE.md, a repo with only an AGENTS.md (which still loads), a repo with neither, and --setting-sources user. fctl-agent writes the file only when the sandbox's fctl edit --help works. Otherwise it logs once that the session keeps its first title.

Control plane

  • fctl-agent keeps the agent's title and description in the session state it reports (new optional SessionState.title and .description), which the host already re-sends after reconnects. A new event kind would have broken older CLIs, which reject event kinds they don't know. The agent's fctl edit call shows in the transcript anyway.
  • SessionDO applies a reported value only when it differs from the agent's previous report, so a person's rename stands until the agent renames the session again. It validates the value again, broadcasts the summary and writes it through to D1. Renames through the API write through as well, so a racing write-through can't leave the old title in D1.
  • Sessions get a description (migration 0004). PATCH /sessions/{id} sets it or clears it with "", and account exports include it. Titles now reject control characters, since terminals print them.

Web: the session page shows the description under the title. Lists already update from the feed's session summaries, so renames show up there live.

Also

  • Process-driver agents get the host's own fctl first on their PATH.
  • fake-claude learns rename <title>.
  • The docs cover all of this, and ADR 0007 records the choices.
  • cargo xtask dev couldn't bootstrap a fresh checkout, so I fixed that too. It posted the fake Claude credential to /me/claude (the route is /me/claude/token) with a 33-character token (the API wants at least 40).

Compatibility: the protocol changes are optional fields and a new socket. Older hosts and agents keep working, and their sessions keep their first title. Migration 0004 runs before the Worker deploys, as usual. Agents name sessions once hosts run a release with this change and have rebuilt their image (fctl host image build). Process-driver hosts need no rebuild.

How I verified it

  • Unit tests for the validators, the session socket's wire format, the supervisor's edit handling (validation, clearing, another session's id, persistence across restarts), the CLI's choice between the socket and the API, the user-memory import, fake-claude's parsing and shell quoting.
  • cargo xtask check --quick passes: format, generated types, Biome and TypeScript, Clippy native and wasm, cargo test, Vitest. The web checks ran against a stub of @hyperstructure/design, which this sandbox can't fetch.
  • End to end with cargo xtask dev and fake-claude. fctl run -p playground "rename Fix the flaky login test" started a session whose transcript shows the agent's fctl edit call; fctl show and fctl sessions (from D1) then had the new title and description. The sandbox's ~/.claude/CLAUDE.md imports ~/AGENTS.md. On a second session:
    • a person's rename survived the agent's later state reports;
    • the agent's next rename replaced it;
    • a description the person cleared stayed cleared.
  • The image's install step, run on its own: a published version installs, an unpublished one (9.9.9) falls back to the latest, and only fctl stays in the install directory.

Not verified, or needing a person

  • I couldn't build the image (no Docker here) or run container build --build-arg on a Mac. Apple's command reference lists --build-arg.
  • I couldn't look at the session page: the design package is private. The change is one truncated line under the title; it needs a look in both themes and at phone width.
  • hyperstructure/fctl-site's legal/privacy.md may need a line if it lists what a session stores, since sessions now keep a description written by the agent or the owner. This session's token can't reach that repository.
  • The Remote Control name in the Claude apps keeps the session's first title.

Refs #28: ~/AGENTS.md is where fctl-wide instructions for every project's agents could go, if that's decided.

Session: https://app.fctl.sh/s/ses_01M565EJZSBP0VB1A7YG98K718

fctl-sh Bot and others added 8 commits October 18, 2026 00:31
Sessions are titled with the first line of their task, so the session
list shows prompts rather than work. Agents now report a title and a
description for their own session:

- fctl-agent serves a session socket beside the host's
  (agent.session.sock, FCTL_SESSION_SOCKET for Claude). A program in
  the sandbox sends one edit request; the agent validates it and keeps
  the title and description in the session state it reports, which the
  host passes on and re-sends after every reconnect. No credentials
  for the control plane enter the sandbox.
- SessionDO applies an agent's title or description only when it
  differs from the agent's previous report, so a person's rename
  stands until the agent renames the session again. It validates both
  again and writes them through to D1.
- Sessions gain a description (migration 0004), which owners can also
  set or clear with PATCH /sessions/{id}.
- At Claude's start, fctl-agent writes ~/AGENTS.md with how to keep the
  title and description current, and imports it from Claude's user
  memory (~/.claude/CLAUDE.md), which loads in every repository without
  displacing the repository's own CLAUDE.md or AGENTS.md. It does so
  only when the sandbox's fctl can edit the session.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`fctl edit [SESSION] --title … --description …` renames a session or
says what it is about. In the sandbox of the session it edits it asks
fctl-agent over the session socket and needs no sign-in, which is how
agents name their own session; anywhere else it goes through the API.
`fctl show` prints the description.

The default image installs fctl in /usr/local/bin with fctl.sh's
installer, at the host's version (`fctl host image build` passes it as
FCTL_VERSION; an unpublished version falls back to the latest release).
Process-driver agents get the host's own fctl first on their PATH, so
`cargo xtask dev` sessions can rename themselves too, and fake-claude
does with `rename <title>`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The session page's header shows the session's description, one line
with the full text on hover, below the title the agent keeps current.
Lists already update live from the session summaries the dashboard feed
sends, so agent renames appear there as they happen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`fctl host image build` passes download_base as FCTL_DOWNLOAD next to
FCTL_VERSION, so hosts that mirror releases elsewhere get the image's
fctl from the mirror too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The architecture, security, CLI, development, getting-started and
self-hosting docs describe the session socket, `fctl edit`, the
sandbox's ~/AGENTS.md and rebuilding the image after an upgrade. ADR
0007 records why agents go through fctl-agent rather than holding a
token, why the title travels as session state, and why the instructions
are imported from Claude's user memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`cargo xtask dev` posted the fake-claude token to /me/claude, which has
no POST route, so a fresh dev stack stopped while bootstrapping
("adding a Claude credential: HTTP 404"). The route is
/me/claude/token, as fctl-client uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The control plane wants a setup token of at least 40 characters; the
dev bootstrap's fake one had 33, so it was refused once it reached the
right route.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l-installed-in-the-image-w

# Conflicts:
#	crates/fctl-agent/src/prompt.rs
#	crates/fctl-agent/src/supervisor.rs
@kalaspuff
kalaspuff merged commit 3cfb7d8 into main Oct 18, 2026
4 checks passed
@kalaspuff
kalaspuff deleted the fctl/9-let-s-have-fctl-installed-in-the-image-w branch October 18, 2026 01:00
fctl-sh Bot added a commit that referenced this pull request Oct 18, 2026
Conflicts with sandbox limits (#31), fctl in sandboxes and agent-named
sessions (#33) and claude.ai connectors (#32):

- The system prompt takes the repositories' paths and the sandbox's size;
  AGENTS.md and the size line from main stay as they are.
- The supervisor keeps both new fields and functions; the spec keeps
  `grants` and `session_wants` and passes main's adjusted settings.
- ADR 0007 is main's (agents name their sessions); the repositories ADR
  becomes 0008.
- The project page keeps main's start button and sandbox hint next to the
  Repositories tab.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kalaspuff pushed a commit that referenced this pull request Oct 18, 2026
On a machine without `worker-build`, `cargo xtask dev` built everything
and then failed when wrangler started the control plane:
`crates/fctl-control/wrangler.toml` builds the Worker with `worker-build
--dev`, and only `cargo xtask deploy` installed it (CI installs it in a
step of its own). xtask then kept waiting for the health check, which
gives up after five minutes.

`cargo xtask dev` now calls `util::worker_build()`, as `deploy` does. It
installs worker-build 0.8.7, the version of the `worker` crate in
`Cargo.lock`, with `cargo install` when it isn't on the PATH. The call
comes first, right after `npm ci`, so a machine that can't build
worker-build finds out in seconds, not after the other builds.
`docs/development.md` lists worker-build in the setup, with what its
build needs on Debian and Ubuntu: `pkg-config` and `libssl-dev`, because
on Linux its HTTP client links OpenSSL.

I found this while checking #34 on a fresh clone. #33 had already fixed
the Claude credential bootstrap that #34 reports, but `cargo xtask dev`
never got far enough to run it.

## How I verified it

From a fresh clone (no `.fctl-dev/`, `crates/fctl-control/.wrangler/`,
`node_modules` or `web/dist`), in a sandbox with Rust but no
worker-build:

- **Before, on `main`:** `[custom build] /bin/sh: 1: worker-build: not
found`, then `Running custom build 'worker-build --dev' failed`, while
xtask went on waiting for the health check.
- **Without OpenSSL's headers:** it stops after 25 s, before the other
builds, with openssl-sys's "The system library `openssl` required by
crate `openssl-sys` was not found".
- **With them:** it installs worker-build, builds and bootstraps. `POST
/api/v1/setup`, `/auth/tokens`, `/me/claude/token`, `/projects` and
`/runners` all return 201, and it reaches "fctl dev is running" in 79 s.
Vite serves the app at http://localhost:5173 (`npm ci` fetched the
design package). Two fake-claude sessions ran to the end: `write
notes.md` committed a file, and `rename Check the dev bootstrap` renamed
its session with `fctl edit`.
- A restart on that state reaches "fctl dev is running" in 6 s and adds
nothing. With `.fctl-dev/token` deleted, it signs in with the password
and makes a new token.
- `cargo xtask check` passes.

## Not changed

- When `wrangler dev` exits before it is healthy (any failing first
build, a compile error included), `cargo xtask dev` still waits the full
five minutes, because `wait_for` doesn't watch the wrangler process.
- #34 left a question for a person: whether CI should run the bootstrap.
It is now #53, with this as a second break CI didn't catch.
- #41's question, whether the default sandbox image should include Rust
and `libssl-dev`, was answered by #45, which added both along with
`pkg-config`.

Fixes #41
Refs #34

Session: https://app.fctl.sh/s/ses_01M56GFH2FJV0NW90ZNRFWKEA3

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant