Data & Analysis
Deterministic math for financial analysis.
calculatorA reliable math evaluator. Language models are famously shaky at arithmetic, so this tool does the actual sums — ratios, growth rates, percentages — and returns the exact number.
Parses and evaluates arithmetic expressions (addition, subtraction, multiplication, division, powers, parentheses) and returns the exact numeric result. Intended for day-to-day financial math — ratios, growth rates, percentages. For calculus or symbolic algebra, use Wolfram Alpha instead.
When a user asks:
What's the P/E ratio if price is 190 and EPS is 6.13?
the agent calls the tool:
calculator(expression="190 / 6.13")and gets back: 30.9951…
Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.
YAML DSL
# modeling.yaml
name: modeling-crew
process: SEQUENTIAL
agents:
- id: modeler
role: Financial Modeler
goal: Do precise arithmetic without LLM drift
tools:
- calculator
tasks:
- id: modeling-task
agent: modeler
description: Compute Apple's P/E ratio given price=190 and EPS=6.13.Java
import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.CalculatorTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
@Autowired ChatClient chatClient;
@Autowired CalculatorTool calculatorTool;
Agent modeler = Agent.builder()
.role("Financial Modeler")
.goal("Do precise arithmetic without LLM drift")
.chatClient(chatClient)
.tool(calculatorTool)
.build();
Task modelerTask = Task.builder()
.description("Compute Apple's P/E ratio given price=190 and EPS=6.13.")
.agent(modeler)
.build();
SwarmOutput result = Swarm.builder()
.agent(modeler)
.task(modelerTask)
.process(ProcessType.SEQUENTIAL)
.build()
.kickoff();Real scenarios where agents put this tool to work.
Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/CalculatorTool.java in the swarm-ai repository.