Skip to content

Simplify the agent host, the world and the gateway - #455

Merged
SaladDay merged 1 commit into
feature/agent-outside-sandboxfrom
aos/b4-host
Oct 7, 2026
Merged

SaladDay merged 1 commit into
feature/agent-outside-sandboxfrom
aos/b4-host

Conversation

@SaladDay

@SaladDay SaladDay commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

B4 simplicity audit, lane L4: the agent host, the world and the gateway. Net −143 production lines.

Defect fixed: the gateway stops before a view's end is reported. agenthost/doc.go promises that the gateway has stopped before the Process reports the view's end. Before this change, ownedView.end cancelled a context and moved on, while the gateway closed in context.AfterFunc callbacks. Now:

  • gateway.Start returns a synchronous stop, and end waits for it.
  • One connSet tracks every connection in both directions: accepted, dialed upstream, HTTP/2, upgraded MCP and CONNECT tunnels. A connection leaves the set only after it has closed. Adding to a closed set resets the connection.
  • Stop cancels, closes the listeners, waits for the accept loops, then resets every connection.
  • TestStopClosesEveryConnection failed 4 of 20 runs against the previous gateway; it passes every run now.

Deletions:

  • gateway:
    • one model provider and one endpoint, replacing the named model list, its uniqueness check and endpoint map, Endpoints.Placeholder and SessionNetwork;
    • CloseIdleConnections and the transport list;
    • the test's private FUSE world, replaced by fileservicetest plus worldfs.
  • agenthost:
    • the Error struct, replaced by %w wrapping with the same sentinels;
    • the attachLink interface;
    • processTable/procfs, replaced by an injectable task-listing function;
    • the provider's JSON round trip in handoff.
  • worldfs:
    • the Error struct;
    • the hand-written no-op and ENOSYS methods, replaced by an embedded fuse.NewDefaultRawFileSystem(), with errno assertions.
  • agent: the AST test that forced View: nil.
  • agent/mcode: config.yaml, workspace-profile.json and mcp.json are built in memory and written once each. The bytes match the previous output in 7 modes.

Test-only fix: two worldfs tests hung on one CPU, because the test process both serves the FUSE world and touches it. They now pre-poll go-fuse's epoll file and fault a mapping in with MADV_POPULATE_READ. Production never opens world files in its own process.

Testing:

  • The gateway, agenthost and worldfs privileged suites on all CPUs and with --cpuset-cpus=0.
  • The stop, listener, relay and view-end tests at -count=50.
  • Gateway -race -count=50.
  • Unprivileged tests, vet, and the darwin and windows builds.

Blind review (Codex) asked for the complete stop; this PR includes it.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The gateway stops synchronously: gateway.Start takes the Session's network namespace file and returns a stop that closes the listeners and every connection before it returns, so ownedView.end has stopped the gateway before Process.Wait returns. TestViewEndStopsTheGateway checks the order with the real gateway.

The gateway serves one model provider with one endpoint; Model, the names, Endpoints.Placeholder and SessionNetwork are gone. The agent host hands the rewritten Provider to the Executor without a JSON round trip, links with *sandboxlink.AttachLink, and lists running tasks through an injectable function. The agenthost and worldfs Error structs give way to fmt.Errorf with the same sentinels.

worldfs embeds go-fuse's default RawFileSystem in place of its own ENOSYS and no-op methods, and TestUnsupportedErrnos checks the errnos for the operations TestPOSIX skips. The worldfs tests no longer wait on the world they serve while holding a P: each test mount answers the kernel's first poll the way go-fuse's WaitMount does, and TestInstanceChanged faults its private mapping in with madvise. On one CPU, or during a stop-the-world, either wait deadlocked the test with its own world. The gateway's view test serves a fileservicetest world through worldfs.

MiniMax Code writes config.yaml and mcp.json once, from configuration built in memory, with the same bytes as before. The View: nil syntax test is gone; TestRegistryResolvesOnlyDeclaredViews covers the behaviour.
@SaladDay
SaladDay merged commit 86b2b03 into feature/agent-outside-sandbox Oct 7, 2026
20 checks passed
@SaladDay
SaladDay deleted the aos/b4-host branch October 7, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant