Documentation
¶
Overview ¶
Command assistant is the AI assistant's load test (B6): it opens many thread streams (SSE) on a running ReputeCast, sends a message in each thread, answers the model requests as a fake OpenAI-compatible provider that streams, and measures each event from its commit to its delivery.
It is a small Go program, not a k6 script, for two reasons. k6 has no SSE client of its own: the extensions (xk6-sse and its forks) need a custom k6 binary built with xk6, a third-party build of a third-party extension that the CI and the orb would have to fetch and trust. And the measure the gate asks for starts at an event's commit, which only the instance knows (each event's row keeps its created_at, written in its committing transaction). It lives under loadtest/ and is not part of the shipped binary.
All in one process, on one machine (the load competes with the instance for its CPUs):
REPUTECAST_DATABASE__URL=postgres://… go run ./loadtest/assistant \ -base http://127.0.0.1:8080 -fake 127.0.0.1:9711 -streams 200 \ -metrics-token …
Or split in roles, so the streams' clients run on another machine:
provider on the instance's machine: the fake model (-fake, -chunks,
-every), and samples of the CPU the instance (-server),
Postgres and the machine use, served at /loadtest/cpu.
setup anywhere that reaches the database and the instance: connects
the workspaces' model to the fake (-fake: its address as the
instance reaches it), adds people with sessions, opens the
threads and writes them to -plan (the clients' input; it
holds sessions).
clients on the other machine: the plan's threads (or, with -db and
no -plan, setup first), driven at -base; prints the server's
own histograms, read from /metrics before and after the run,
as the authoritative measure, the times to first token by the
database (-db), and what this machine's clock alone can time.
collect on the instance's machine: the run's turns by the database
and the CPU used over the run, from the provider's samples.
The clocks of two machines differ, so in split mode no time is taken on one and compared with the other: an event's delay from its commit to its stream is the instance's reputecast_ai_assistant_event_lag_seconds, a turn's time to its first token the database's two timestamps.
The instance needs the Acme sample (reputecast seed), the provider's address allowed (providers.allow_private_networks for a loopback fake), enough assistant workers for every turn at once (worker.concurrency 400 gives the ai_assistant queue 200) and, for the histograms, a metrics token (metrics.token; /metrics on the main listener). Setup, done each run, writes to the database directly, like loadtest/session.sh: development and load test instances only. It connects every workspace's model to the fake, sets the assistant's limits to 10 turns a person and 100 a workspace (the most they take), adds people as Editors and gives them sessions.