Docs / Models and sandbox / The mock model
The mock model
The mock model is a scripted stand-in for a real model. It answers from a JSON file, so a run needs no GPU, no key and no network, and the same script gives the same replies.
Run with a script#
$ python3 -m swarmlabre demo out-demo/ $ python3 -m swarmlabre run out-demo/demo.elf --mock out-demo/mock-script.json --out out/
--mock SCRIPT answers every model request from a JSON file, so the run needs no GPU, no key and no network. [model] mock in the configuration does the same. The tests, the demo and the golden cases all use a scripted mock. The run itself still needs Docker and the two images; Analyse a file covers them.
demo writes a harmless ELF file and the script that analyses it. --variant two writes a second sample, demo2.elf, with mock-script2.json:
$ python3 -m swarmlabre demo out-demo/ --variant twoThe second sample holds a string stored as UTF-16. Its script has the Static role dispute a finding, a planning answer that settles the dispute and sends Crypto/Config back for a second round, and a repeated post that the board refuses as a duplicate. The recorded demo run in the repository was made with it.
The script#
A script is a JSON object with three keys.
| Key | Holds |
|---|---|
model | the model name the run reports. The default is mock-1. |
roles | an object that maps a role id to a list of steps, in order |
orchestrator | a list of answers to the planning calls SwarmLabRE makes between rounds, in order. After the list the answer is a plan with no tasks. |
A step is an object with an optional text, an optional tool and the tool's args. A step with a tool makes the agent call that tool, for example bash or read. A step with no tool is the role's final answer. These are the second and third steps of the Strings/IOC role in the demo script. The first reads the prepared strings and the second posts a finding with swarm-post.
[
{
"tool": "bash",
"args": {
"command": "head -40 /prep/strings.txt"
}
},
{
"tool": "bash",
"args": {
"command": "python3 /skills/rea-swarm/scripts/swarm-post --kind ioc --title 'C2 URL' --value http://c2.example.test/beacon --off 0x95 --confidence high --detail 'A URL on a reserved example domain.'"
}
}
]How a step is chosen#
The turn of an agent is the number of assistant messages already in the conversation it sends. The reply is the step at that index of the agent's role. After the last step the reply is "Nothing more to add.". A reply therefore depends only on the request and never on the order in which six agents arrive, which is what lets a mock run and a replay stay independent of how the agents interleave. A tool call gets an id made from the role and the turn, so the ids repeat from run to run.
A planning call is a request with no tools from the orchestrator. Each one takes the next entry of orchestrator.
What the mock does not do#
The mock does not read the sample or the prepared files. The offsets in its posts are written into the script, so a script fits the one file it was made for. The board checks every post against the real file, so a script with a wrong offset gets the same refusals as a model would; The board lists them. The mock reports that it honours the seed, because its replies do not depend on sampling.
A run with the mock shows the pipeline and its checks. It says nothing about how well any model analyses a file. demo.py in the package builds the two demo scripts and shows how a script takes its offsets from the generated file.