A page plugin that compares the agent harnesses behind magpie's gateway by agent: input tokens, cache hits, failures, latency and estimated tool-definition size. A local service on 127.0.0.1:3496 reads magpie's usage ledger, and a read-only gateway hook writes tool counts, sizes and names to <config>/harnessweight/tools.jsonl. Since the review at e0a0ae97 (7c6cd626a, then main merged in): - Port 3492 -> 3496 (window-warmup has 3492; 3496 is used by no other package). - Config dir: input.directory, then a cwd probe, then an absolute XDG_CONFIG_HOME, then ~/.config/magpie. A relative XDG is ignored. - tools.jsonl is append-only. Past 8 MiB it is renamed to tools.jsonl.1. Age is checked at most hourly. Appends from two hosts are serialized by a cross-process lock that is skipped after 100 ms. - MAGPIE_ADDR is honoured; the UI has English and Chinese (zh-TW and ja read English); preview PNGs dropped; /%E0 returns 400. Run at 961b20e63c7e00e1dcca723bc2aa1d302f5dd9a3, in WSL (magpie-desktop, Node 22.23.4): - node --test test/*.test.mjs in the package: 60 pass, 0 fail. - bun scripts/check.mjs: clean (registry.json ok; the package has hooks, so check skips it). - Probes against createHandler: - Origin null without the token: 403. With the token: 200. - A foreign Origin, a loopback Origin on another port, a file:// Origin, a rebound Host and a localhost Host on another port: all 403. - The index HTML carries the token and no ACAO. - ..%2f: 400. /%E0: 400. - Rollover with 40-tool rows (1306 B each), 9.5 MiB written: the file peaked at 8,388,590 B (cap 8,388,608) with one rename to .1. Append p50 was 1.35 ms, p99 9.2 ms and max 24 ms. - Portable dir: the hook's cwd probe and the service's input.directory gave the same tools.jsonl. - Broken by hand: - Size rotation turned off: two rollover tests went red. - The Host check removed: the service test "other hosts, other origins and path traversal are refused" went red. Co-authored-by: webkubor <29485642+webkubor@users.noreply.github.com>
2.6 KiB
HarnessWeight
A magpie page for comparing the agents behind your gateway: requests, input and output tokens, cache reads, failures, latency and estimated tool-definition size. The dashboard groups requests by agent, not model. A read-only gateway hook records tool counts and JSON sizes after each response and observes in-flight request counts in memory.
Install
magpie plugin add @magpie-community/page-harnessweight
Open HarnessWeight in magpie. Usage history is read from magpie's existing local ledger; tool-size samples accumulate after installation. The service listens on loopback, port 3496 by default. Change the port plugin option if that port is in use.
Reading the dashboard
- Input includes fresh input, cache reads and cache writes. Cache rates and input tokens are usage measurements, not a currency amount; pricing depends on the model and provider.
- Tool-definition tokens are an estimate: the serialized JSON byte count divided by 3.5. They are not measured with the model's tokenizer. Tool definitions may be cached; their size is not a direct bill.
- In flight is derived from hook start and response callbacks. Missing callbacks may leave counts visible until expiry (15 minutes). It does not reflect activity outside the gateway.
- Session duration is the span between the first and last recorded request for a session in the chosen period, including idle time. Sessions longer than six hours are excluded from duration aggregates; a missing session ID cannot be measured.
- Protocols are inferred from recorded endpoints for the selected period. They are not a list of the agent's current configuration.
Data and security
The sandboxed page asks for no bridge reads; it navigates to the plugin's local service. The service reads magpie's local usage ledger and queries its local gateway for agent display names and icon keys. The hook writes request metadata, tool names, counts and sizes locally. It does not store prompts, tool arguments or credentials and does not modify the request.
The local service validates Host and Origin and requires a per-process random token on data APIs. No telemetry is sent by this plugin.
Configuration options include port, usageLog, dataDir, gatewayUrl and agents; see the project documentation for details.
Development
bun test
Agent icons are from the community page-agent-office icon collection and LobeHub; see app/icons/NOTICE. Brand marks belong to their respective owners.
MIT © webkubor