Agentic Cost Savings - Topos Documentation
Contents
Menu
Expand
Light mode
Dark mode
Auto light/dark, in light mode
Auto light/dark, in dark mode
Skip to content
Topos Documentation
Getting Started
Quick Start
Installation
Guides
For Agents
CLI Reference
Concepts
Measures
Concepts
Case Studies
Agentic Cost Savings
Reference
API Reference<br>Core<br>topos.core.category
topos.core.morphism
topos.core.object
topos.core.omega
Evaluation<br>topos.evaluation.characteristic_morphism
topos.evaluation.preferences
topos.evaluation.suggestions
topos.evaluation.suppression
topos.evaluation.policies.base
topos.evaluation.policies.calibration
topos.evaluation.policies.clones
topos.evaluation.policies.composable
topos.evaluation.policies.coverage
topos.evaluation.policies.secure
topos.evaluation.policies.simple
Graphs<br>topos.graphs.base
topos.graphs.ast.dispatch
topos.graphs.ast.object
topos.graphs.ast.types
topos.graphs.ast.providers.base
topos.graphs.ast.providers.native_provider
topos.graphs.ast.providers.tree_sitter_provider
topos.graphs.cfg.builder
topos.graphs.cfg.models
topos.graphs.cfg.object
topos.graphs.cpg.builder
topos.graphs.cpg.models
topos.graphs.cpg.object
topos.graphs.mdg.object
topos.graphs.pdg.object
topos.graphs.uast.mapper_common
topos.graphs.uast.mapper_cpp
topos.graphs.uast.mapper_javascript
topos.graphs.uast.mapper_python
topos.graphs.uast.mapper_rust
topos.graphs.uast.mapper_typescript
topos.graphs.uast.models
Functors<br>topos.functors.probes.ast.complexity
topos.functors.probes.ast.entropy
topos.functors.probes.cfg.complexity
topos.functors.probes.cfg.paths
topos.functors.probes.cpg.danger
topos.functors.probes.cpg.taint
topos.functors.probes.mdg.coupling
topos.functors.probes.mdg.fan
topos.functors.probes.uast.compare
topos.functors.probes.uast.signature
topos.functors.profunctors.ast.compare
topos.functors.profunctors.cfg.compare
topos.functors.profunctors.cpg.compare
topos.functors.profunctors.cpg.topological_coverage
topos.functors.profunctors.mdg.compare
topos.functors.profunctors.pdg.compare
topos.functors.profunctors.uast.compare
topos.functors.profunctors.uast.structural_test_coverage
MCP<br>topos.mcp.cache
topos.mcp.diagnostics
topos.mcp.evaluation
topos.mcp.formatting
topos.mcp.schemas
topos.mcp.security
topos.mcp.security_findings
topos.mcp.server
topos.mcp.resources.docs
topos.mcp.tools.assess
topos.mcp.tools.compare
topos.mcp.tools.coverage
topos.mcp.tools.docs
topos.mcp.tools.evaluate
topos.mcp.tools.inspect
topos.mcp.tools.preferences
CLI<br>topos.cli.main
topos.cli.diagnostics
topos.cli.evaluation
topos.cli.installation
topos.cli.commands.coverage
topos.cli.commands.quality
topos.cli.commands.system
Configuration<br>topos.config
topos.utils.discovery
topos.utils.tree_sitter
Back to top
View this page
Edit this page
Agentic Cost Savings¶
This case study tests a narrow claim: when an agent starts from structurally<br>cleaner code, does the next feature work take less time, fewer tokens, and less<br>money?
In one controlled experiment, the answer was yes. After a Topos-guided refactor,<br>four follow-on Gemini feature sessions used 32.6% fewer tokens , ran 22.9%<br>faster , and had 24.6% lower estimated feature-session cost than the same<br>features on the unrefactored baseline. Including the upfront refactor, this<br>single run cost more overall.
That is not a universal benchmark. It is one synthetic business-software<br>fixture, and more work is needed before making broad claims.
Why this experiment matters¶
Passing tests are not the end of the story for agent-written code. A feature can<br>work and still make the next feature harder to add.
This case study asks whether that extra cost shows up in the agent loop itself:<br>more reading, more tool calls, more tokens, and more time. Topos is already<br>described elsewhere in these docs; here, the question is narrower. Does a<br>Topos-guided structural cleanup make the next agent sessions cheaper?
The setup¶
The fixture was a small healthcare claims engine. It was synthetic, but it had<br>the texture of business software: payment rules, member eligibility, provider<br>networks, deductibles, coinsurance, audit messages, imports, exports, and tests.
The baseline had:
728 total lines.
10 production and test files.
10 passing tests.
83% line coverage.
One overloaded adjudicator.py file at 264 lines.
Topos identified the intended structural problem. The central adjudicator had a<br>SIMPLE score of 0.0, cyclomatic complexity of 34, and a maximum function<br>complexity of 48. In other words, the code worked, but the main decision point<br>had become the place where future changes would get expensive.
The experiment compared two paths from the same baseline:
Condition
What happened
A: no Topos
Gemini added four features directly to the original code.
B: Topos-guided refactor
Gemini first used Topos to refactor the structure, then added the same<br>four features in fresh sessions.
The...