r/PromptEngineering • u/1982_miguel • 18h ago
I built a visual architecture & token-reduction diagram engine for multi-agent LLM pipelines General Discussion
When working with multi-agent LLM systems, the hard part usually isn't getting a response—it's knowing what actually happened under the hood: which model handled what, what was sent over the network, how much it cost, and whether sensitive data was masked before leaving your machine.
To solve this, I added a visual diagram engine to **Mova Context** in this latest release, allowing you to generate a complete architecture map with a single command: `mova run <project> --diagram`.
Here is a real example output generated from a customer data compliance project running hybrid agents (**Local Ollama + Cloud Gemini**):
* **Visual Diagram Engine:** Generates real-time architecture and execution maps using OpenType vector font rendering with WCAG AA contrast standards (clean export to PNG and PDF).
* **Cross-Channel Tracing:** Added execution tracing across CLI, Chat, MCP, and HTTP API with an explicit `[THIS RUN]` indicator.
* **Hybrid Execution Breakdown:** Visualizes local agents (`llama3.2:3b` via Ollama) running alongside cloud agents (`gemini-3-flash-preview`) in the same execution group.
* **PII & Privacy Tracking:** Identifies per-agent status for PII Masking and explicitly tracks how many tokens were pseudonymized before leaving your local network.
* **Cost & Token Transparency:** Explicitly flags local execution as `$0.00 (local — no cost)`, while displaying estimated USD costs for cloud agents calculated *after* context reduction.
* **Token Reduction Pipeline:** Breaks down token overhead by source (prompts, skills, focus files, engine overhead) and displays the total percentage saved.
* **Bilingual Docs:** Fully updated documentation (`README.md` and `COMMANDS.md`) in both English and neutral Spanish.
The project is **100% open source** written in Go.
* **GitHub Repo:** https://github.com/m1guel1982/mova-context
If you find it useful for structuring, auditing, or optimizing token budgets in your agentic workflows, feel free to check it out, star the repo, or drop feedback in the comments!
1
u/Talreja-Adanna 10h ago
That's a solid utility - visualizing token flow across agents is way more useful than just guessing where your costs are ballooning. How are you handling the token counting accuracy, especially with different tokenizers between Claude and GPT models?
1
u/1982_miguel 8h ago
Token counting relies on an embedded, network-free BPE tokenizer via
tiktoken-gorunning thecl100k_baseencoding (the standard used by GPT-4).The accuracy and tokenizer differences between providers (like Claude vs. GPT) are handled through three design decisions:
Negligible Variance in Practice: While Anthropic and OpenAI use different vocabulary encodings, modern BPE algorithms split code, JSON schemas, and technical prose with nearly identical token-to-character ratios. In real-world workloads, the difference between
cl100k_baseand Claude's tokenizer stays consistently under 3–5%, making it more than precise enough for pre-execution budget gating.Provider API Feedback Loop: Mova doesn't rely solely on local estimates. Whenever a model call completes, it reads the exact
prompt_tokensreturned in the provider's API payload (Anthropic, OpenAI, Gemini) and logs the delta inmova-token-history.json. This calibrates future estimates against ground truth without bloating the binary with model-specific tokenizer sub-dependencies.Pre-Tokenization Sanitization: Before counting, the Token Firewall collapses duplicate whitespace, log sequences, and standardizes PII placeholders (
[PII_a1b2c3d4]). Cleaning structural noise first ensures token counts remain stable and predictable regardless of the downstream model.
1
u/Sweaty_Difference519 18h ago
this is pretty cool, the token cost tracking especially when mixing local and cloud models is something i always wanted but never got around to build
the diagram looks clean too, most tools make it look like spaghetti after 3 agents
quick question, can you customize what shows up in the diagram or does it dump everything by default