Skip to content

Services

A campaign gives its populations three services: a fleet of model replicas, tool services that call the application's MCP servers, and a store. Locally the store is made with the campaign; under Dragon start_services() starts it. start_services() also starts the application's MCP servers and the tool services; each population makes its own fleet. stop_services() stops the tool services, then the MCP servers, and close() stops whatever is left.

The model fleet

Each population has one Flowgentic Fleet. Its replicas are:

  • the application's stub, by default: definition.stub(r) for each of PopulationConfig.stub_replicas replicas (1). A stub is a Flowgentic transport whose replies depend on the agent and its messages only, so a run needs no model server;
  • model servers, with PopulationConfig.model set: one Flowgentic HTTPTransport per OpenAI-compatible server, such as vLLM. See Model servers.

The fleet sends each agent's calls to one replica and admits a call while the replica's live context in flight stays under cap_tokens (235,000 tokens) and its requests in flight under cap_requests (96), whichever binds first. With cap_tokens=0 only the requests count. The caps hold per replica across every population: each population gets 1/populations of each cap (Flowgentic's share).

A model server that goes away is waited for, up to outage_s (1,800 s), and the calls go again once it is back: see Failures.

Caveat: caps across many populations

Flowgentic gives a process max(1, int(cap × share)) of each cap, so with many populations the shares stop adding up to the cap:

Populations Cap per server Each population gets All populations, per server
8 96 requests 12 96, the cap
100 256 2 200: the servers run at 78 % of their caps
300 256 1 300: past the cap

Every population sends to every server. Flowgentic 0.7.0 has exact shares and each process routing to a subset of the servers (Fleet(process=...), layout="pack"); AUTONMI does not use them yet.

Tool services and MCP servers

An application with MCP tools starts its MCP servers in definition.services(run_dir, servers), with CampaignConfig.mcp_servers servers (4), and returns their URLs. The campaign passes RUN/services as run_dir, for the servers' logs. AUTONMI then starts the tool services, which call those servers for the agents:

  • one tool service per population, at most toolservices (8): population i uses service i mod min(toolservices, populations);
  • each service has max(mcp_clients, servers) MCP clients (mcp_clients is 8), with mcp_per_client (16) calls in flight on each; its clients take the servers in turn, starting from a different server for each service;
  • a call that takes longer than 120 s fails;
  • locally a service is a thread on queue.Queues; under Dragon a Dragon process on Dragon queues, on the mini-app's node, beside the MCP servers, which listen on 127.0.0.1.

start_services() waits for every tool service to report that it is ready, and stop_services() for every one to report that it is done, each for at most CampaignConfig.service_timeout_s (120 s): past it they raise TimeoutError, and a service that fails makes them raise RuntimeError. As it stops, each service writes its calls' times into RUN/services/toolservice-<k>-times.npy and reports its stats; once every one has reported, stop_services() writes them into toolservice-<k>.json.

An application without MCP servers returns ([], []), and no tool service starts.

The store

The store holds the agents' saved state while they are suspended, and whatever the application's tasks write, such as simulation results. autonmi.store.open_store(spec) opens it in any process, as one of Flowgentic's stores:

Spec Store Where
memory:<name> flowgentic.store.MemoryStore, a dictionary in this process, shared by its threads locally
radex:<descriptor> flowgentic.store.RadexStore, RaDEX on a Dragon distributed dictionary, started through RHAPSODY's DragonDataBackend under Dragon

Under Dragon the dictionary has CampaignConfig.store_managers managers (4) of store_manager_gib (2 GiB, the most allowed) on every node of the runtime. A task opens the store from pop.store_spec, or Campaign.store_spec for the mini-app's own tasks. A memory: store is shared only by the threads of one process: a task in a spawned process (spawn_pool, GpuPools) that opens it gets a new, empty store, and its writes never reach the population. Locally, write results to the store from the agents' process, or return them as the task's value. Both stores are Flowgentic KeyValueStores, and hold float64 tensors (put_tensor, get_tensor).

Async code calls the store through autonmi.store.awaited, never directly: an async tool, a step, a callback on the population's event loop. await awaited(pop.store, "put", key, value) awaits the store's own async call when it has one (Flowgentic's RadexStore after 0.7.0), and otherwise runs the call on a thread. A call made on the loop holds every agent of the population while it waits, and under Dragon a call waits as long as the manager that holds its key: seconds, on a slow node. Sync code that runs off the loop, such as a simulation task, calls the store directly. The conformance kit's tool-calling toy (autonmi.conformance.toy) shows both: its double task puts its value directly, and its async report tool awaits the store.