Travelling Sales Person Problem: What AI Agent Builders Can Learn From Route Optimization
The travelling sales person problem asks for the shortest route that visits every stop once and returns to the start. For AI engineers, it is more than a classic optimization puzzle: it is a practical...
Author: Fintalio
Travelling Sales Person Problem: What AI Agent Builders Can Learn From Route Optimization
TL;DR
The travelling sales person problem asks for the shortest route that visits every stop once and returns to the start. For AI engineers, it is more than a classic optimization puzzle: it is a practical model for sequencing outreach, routing tasks, scheduling follow-ups, and deciding when an autonomous agent should act versus when a human should intervene.
What Is the Travelling Sales Person Problem?
The travelling sales person problem, often shortened to TSP, is a combinatorial optimization problem. Given a set of cities and travel costs between each pair, the goal is to find the lowest-cost route that visits every city exactly once and returns to the starting point.
In plain terms: a salesperson needs to visit several customers, minimize travel distance or time, avoid duplicate visits, and end up back home.
A small version is easy to understand:
Start: A
Cities:
A, B, C, D
Possible route:
A -> B -> C -> D -> A
Alternative route:
A -> C -> B -> D -> A
Each route has a total cost. The best route is the one with the lowest total cost.
The challenge is that the number of possible routes grows extremely fast. With only a few stops, brute force enumeration is possible. With dozens, hundreds, or thousands of stops, exact solving becomes computationally expensive. That is why TSP is a canonical example of an NP-hard problem.
For developers and AI engineers building autonomous agents, TSP is useful because it captures a broader pattern: the system must decide the best order of actions under constraints. Those actions might be physical visits, sales touches, CRM updates, sequence launches, account prioritization, or human handoffs.
The same 80/20 operating model applies: the AI agent should handle the boring 80%, such as sorting, scoring, formatting, deduplicating, and launching repeatable workflows. Humans should keep the 20% requiring judgment, negotiation, timing sensitivity, or relationship context.
Why the Travelling Sales Person Problem Still Matters
TSP is not just an academic exercise. It appears in many real systems:
- Delivery route planning
- Field sales territory management
- Warehouse picking
- Manufacturing toolpath optimization
- Network routing
- Chip design
- Scheduling and sequencing
- Autonomous agent planning
In revenue operations, TSP is rarely about literal travel anymore. Most outbound work happens across digital channels, including email, LinkedIn, CRM tasks, and call queues. Yet the structure is similar: a system has a set of targets, a set of costs, and a need to choose the best action order.
For example, an AI sales development agent may need to decide:
- Which contacts should be grouped first?
- Which sequence template should apply?
- Which contacts are missing variables?
- Which account statuses indicate a safe launch?
- Which sequence should be paused, resumed, or stopped?
- Which updates require human review?
The route is no longer a map route. It is an operational route through a pipeline.
Raw contacts
|
v
ParseCsv -> CommitCsv -> CreateContactGroup
|
v
ListVariables -> Select template -> LaunchSequence
|
v
Monitor account status -> Pause/Resume/Stop sequence
|
v
Human review for exceptions
The travelling sales person problem gives builders a mental model for reducing wasted movement, whether that movement is across cities, systems, or sales workflows.
The Core TSP Formulation
A standard TSP can be represented as a weighted graph.
10
A ------ B
| \ |
15| \20 |35
| \ |
C ------ D
30
- Nodes represent cities, accounts, contacts, or tasks.
- Edges represent travel distance, time, cost, risk, or effort.
- The route must visit each node once.
- The route must return to the starting point.
- The goal is to minimize total cost.
Mathematically, the problem asks for a Hamiltonian cycle with minimum total edge weight.
In real agent systems, edge weights may be composite scores rather than physical distances. For example:
edge_cost = response_delay_risk
+ context_switching_cost
+ compliance_risk
+ data_missing_penalty
+ human_review_cost
That cost function matters more than the algorithm. A poor cost model optimized perfectly produces bad outcomes. A practical cost model optimized approximately often produces useful outcomes.
This is where RevOps-honest system design matters. The agent should not pretend to be a magic salesperson. It should be excellent at mechanical prioritization, safe execution, and exception routing. Humans still handle judgment.
Exact Versus Approximate Solutions
For small TSP instances, exact algorithms can find the optimal route. Common approaches include:
- Brute force search
- Dynamic programming, such as Held-Karp
- Branch and bound
- Integer linear programming
However, as the number of nodes increases, exact methods become expensive. A brute force TSP over n cities has factorial growth. That means the number of possible routes explodes as n increases.
For larger systems, approximate and heuristic methods are common:
- Nearest neighbor
- Greedy insertion
- 2-opt and 3-opt local search
- Simulated annealing
- Genetic algorithms
- Ant colony optimization
- Lin-Kernighan heuristic
- Constraint solvers with time limits
The practical question is not always, “Is this optimal?” More often it is, “Is this good enough, explainable enough, and safe enough to run unattended for the boring 80%?”
For autonomous agents, this distinction is critical. Many business workflows do not need mathematical optimality. They need:
- Deterministic behavior where possible
- Observable state transitions
- Guardrails
- Retry logic
- Human escalation
- Clear rollback paths
- Cost control
A near-optimal route that is auditable and safe is usually better than a black-box route that is technically clever but operationally fragile.
How TSP Maps to Autonomous Agent Design
An autonomous agent is often framed as a reasoning loop:
Observe -> Plan -> Act -> Evaluate -> Repeat
A TSP-inspired agent adds explicit cost-aware sequencing:
Inputs
|
v
Build nodes: contacts, accounts, tasks, sequences
|
v
Build edges: costs, dependencies, risks, timing constraints
|
v
Optimize route: choose next best action
|
v
Execute safe actions
|
v
Escalate uncertain cases to humans
In a revenue workflow, the “cities” might be contacts. The “route” might be the order in which an agent cleans, groups, and launches contacts into outreach sequences. The “distance” might combine missing data, seniority, account priority, channel risk, and required personalization.
A practical AI sales agent should not attempt to fully replace human sales work. It should compress the repetitive work around data preparation and execution. That is especially relevant for sales development representative workflows, where the definition of the role has shifted from manual list work toward higher-leverage prospecting and qualification. For more context on the role itself, see sdr meaning sales.
A Revenue Workflow Example
Consider a team that has 1,000 new contacts from a conference list. The goal is to prepare contacts, segment them, and launch appropriate outreach, while routing uncertain cases to humans.
A simple TSP-like framing:
Nodes:
- Contact records
- Contact groups
- Sequence templates
- Variables
- Account status checks
- Human review queue
Costs:
- Missing email or name
- Missing company
- Unclear segment
- Sensitive job title
- Existing sequence membership
- Account status risk
- High-value account
The agent does not need to “sell” in the human sense. It needs to run a safe operational route.
Using only verified MCP tools, the workflow might look like this:
ParseCsv
|
v
Validate rows and detect missing fields
|
v
CommitCsv
|
v
ListVariables
|
v
ListSequenceTemplates -> GetSequenceTemplate
|
v
CreateContactGroup
|
v
CreateContact / UpdateContact
|
v
LaunchSequence
For existing campaigns, the agent might use:
ListSequences -> GetSequence
|
v
GetAccountStatus
|
v
PauseSequence / ResumeSequence / StopSequence
For contact management, it might use:
ListContacts -> GetContact
|
v
ListContactGroups
|
v
UpdateContact
The important point is tool discipline. An agent should only call tools that actually exist, and it should understand their operational boundaries. In this environment, the verified MCP tools are:
- ListContacts
- GetContact
- ListContactGroups
- ListSequences
- GetSequence
- ListSequenceTemplates
- GetSequenceTemplate
- ListVariables
- GetAccountStatus
- CreateContactGroup
- UpdateContact
- PauseSequence
- ResumeSequence
- StopSequence
- ParseCsv
- CommitCsv
- CreateSequenceTemplate
- CreateContact
- LaunchSequence
That list is enough to build powerful 80/20 workflows without inventing capabilities that create unsafe expectations.
Why MCP Matters for TSP-Like Agent Workflows
The Model Context Protocol, or MCP, gives AI agents a structured way to interact with external systems through defined tools. For TSP-like workflows, this is useful because the agent needs a reliable action surface.
A route optimizer is only useful if execution is predictable. If the agent decides that the next best step is to create a contact group, update records, or launch a sequence, those actions must map to real tools with clear inputs and outputs.
A clean architecture can look like this:
+---------------------+
| AI Agent Planner |
+----------+----------+
|
v
+---------------------+
| TSP-like Optimizer |
| cost, constraints |
+----------+----------+
|
v
+---------------------+
| MCP Tool Layer |
+----------+----------+
|
+-----------------+------------------+
| | |
v v v
Contacts Sequences Account status
A developer building with the platform’s MCP support can anchor integrations at [MCP for agent workflows :: /#mcp]. The benefit is not just tool access. It is controlled execution: the agent sees a bounded interface instead of improvising unsafe behavior.
This is especially important for LinkedIn-adjacent workflows. A responsible architecture should use a hosted LinkedIn relay, first-party session, or the platform’s LinkedIn infrastructure rather than brittle scraping. The agent should not rely on invented scraping, inbox reading, profile search, or posting tools. Those capabilities are not part of the verified MCP tool surface described here.
Designing the Cost Function
The cost function is the heart of any travelling sales person problem. In a business agent, it determines what the system considers “expensive.”
A simple route optimization problem may use physical distance:
cost(A, B) = kilometers_between(A, B)
An outbound workflow needs richer logic:
cost(contact_i, contact_j) =
segment_switch_cost
+ template_switch_cost
+ missing_variable_penalty
+ account_status_risk
+ compliance_review_penalty
+ human_review_priority
For example, contacts with complete data and a clear segment should have low execution cost. Contacts with ambiguous attributes should have higher cost and may be routed to a human.
Low-cost path:
Complete record -> known segment -> approved template -> launch
High-cost path:
Missing title -> unclear segment -> sensitive account -> human review
This is where the 80/20 framing becomes operational:
- The agent handles the low-cost, high-confidence 80%.
- Humans handle the high-cost, ambiguous 20%.
The system should not bury uncertainty. It should expose it. An honest agent says, “This contact is ready for sequence launch,” or “This contact is missing variables and requires review.”
Constraints Matter More Than Cleverness
Real-world TSP variants include constraints:
- Time windows
- Vehicle capacity
- Multiple salespeople
- Priority customers
- Forbidden routes
- Required precedence
- Service times
- Return-to-base rules
Agent workflows have similar constraints:
- Do not launch sequences when account status is unsafe.
- Do not update contacts without required fields.
- Do not resume paused sequences unless criteria are met.
- Do not stop sequences without a reason code or operator instruction.
- Do not create duplicate contact groups for the same campaign.
- Do not launch a sequence before variables are checked.
A constraint-first workflow might look like:
For each contact:
if required variables missing:
route to review
else if account status unsafe:
do not launch
else:
assign to group and prepare launch
The agent can still optimize within safe boundaries. It can batch similar contacts, select sequence templates, create groups, and launch approved workflows. But constraints should be treated as hard boundaries, not soft preferences.
This is also where “sales echo” patterns can become dangerous if left unmanaged. If a bad message, bad template, or bad segmentation rule repeats across many contacts, automation amplifies the error. A disciplined routing model helps prevent that repetition by checking inputs before launch. The concept is explored further in sales echo.
Example: Building a TSP-Inspired Outreach Agent
Below is a simplified design for an agent that prepares contacts and launches sequences.
+------------------+
| CSV Import |
+--------+---------+
|
v
+------------------+
| ParseCsv |
+--------+---------+
|
v
+------------------+
| Score Rows |
| completeness |
| segment clarity |
| risk |
+--------+---------+
|
v
+---------------------------+
| Low-risk rows |
| CommitCsv, CreateContact |
+-------------+-------------+
|
v
+---------------------------+
| Group by segment |
| CreateContactGroup |
+-------------+-------------+
|
v
+---------------------------+
| Match template |
| ListSequenceTemplates |
| GetSequenceTemplate |
+-------------+-------------+
|
v
+---------------------------+
| Check variables |
| ListVariables |
+-------------+-------------+
|
v
+---------------------------+
| LaunchSequence |
+---------------------------+
High-risk rows -> Human review
The route is not just linear. It may branch based on confidence and constraints.
A developer can implement the optimizer using a simple greedy approach first:
- Parse all rows.
- Score contact readiness.
- Sort contacts by lowest execution cost.
- Batch by segment and template.
- Create or update contacts.
- Create groups.
- Launch sequences only for validated groups.
- Route exceptions to humans.
This is not mathematically perfect TSP. It is TSP-inspired workflow optimization, and that is often enough for production RevOps systems.
Algorithm Choices for Developers
The right algorithm depends on data size, latency, explainability, and cost.
1. Brute Force
Best for very small instances. It checks every possible route and returns the best one.
Pros:
- Exact
- Simple to understand
Cons:
- Does not scale
- Impractical beyond small node counts
Use case:
- Testing optimizer correctness on small datasets.
2. Dynamic Programming
Held-Karp dynamic programming improves over brute force but still grows quickly. It is useful for teaching and small-to-medium instances.
Pros:
- Exact
- More efficient than brute force
Cons:
- Memory intensive
- Still impractical for large workflows
Use case:
- Benchmarking heuristic quality.
3. Greedy Nearest Neighbor
Chooses the next closest unvisited node.
Pros:
- Fast
- Easy to implement
- Good baseline
Cons:
- Can produce poor routes
- Sensitive to starting point
Use case:
- First version of an agent route planner.
4. 2-Opt Local Search
Starts with an initial route and improves it by swapping edges.
Pros:
- Practical
- Easy to add after greedy routing
- Often improves results significantly
Cons:
- Local optimum risk
- Not guaranteed optimal
Use case:
- Improving batch order or task order after initial sorting.
5. Constraint Programming or MILP
Useful when constraints are complex and explainability matters.
Pros:
- Handles business rules
- Can produce high-quality solutions
- Works with time limits
Cons:
- Requires modeling skill
- Vendor or solver complexity
Use case:
- Multi-team routing, capacity limits, territory planning, sequence scheduling.
6. LLM-Assisted Planning
A language model can help interpret messy inputs, explain tradeoffs, and generate plans. It should not be the only optimizer.
Pros:
- Good at natural-language context
- Useful for exception explanations
- Can classify ambiguous cases
Cons:
- Non-deterministic
- Needs guardrails
- Should not bypass constraints
Use case:
- Human review summaries, confidence scoring, route explanations.
A robust system combines deterministic tools with model-assisted interpretation:
Structured data -> deterministic scoring -> optimizer -> MCP tools
|
v
LLM explains exceptions
Vendor Cost Considerations
Costs vary by category. Exact pricing changes frequently, so ranges are safer than point estimates.
Typical monthly ranges:
| Category | Common monthly range | Notes |
|---|---|---|
| Route optimization APIs | €50 to €1,000+ | Depends on vehicles, stops, API calls, and geocoding |
| General automation platforms | €20 to €500+ | Costs rise with tasks, seats, or premium connectors |
| Sales engagement platforms | €50 to €200+ per user | Often priced per seat, sometimes annual contracts |
| CRM enrichment tools | €50 to €500+ per user | Data credits and export limits commonly apply |
| Custom agent infrastructure | €100 to €2,000+ | Depends on hosting, model calls, observability, and engineering time |
| Platform plan referenced here | €69 per month | Single plan, no free tier, no usage-based tiers |
For agent builders, the hidden cost is rarely just subscription pricing. It is operational complexity:
- How many tools must be integrated?
- How many edge cases need human review?
- Can failed actions be retried safely?
- Is the execution layer observable?
- Are pricing tiers predictable?
- Does the tool surface match actual workflow needs?
A single €69 per month plan is easier to reason about than usage-based tiers when building predictable agent workflows. There is no free tier, and teams should budget accordingly.
Where TSP Breaks Down in Sales Workflows
The travelling sales person problem is a useful metaphor, but it is not the whole system.
Sales and RevOps workflows differ from classic TSP in several ways:
-
The graph changes while the agent runs. A contact may reply, an account status may change, or a sequence may be paused.
-
Costs are uncertain. A missing variable is obvious, but buyer readiness is probabilistic.
-
Some nodes should not be visited. A contact may be excluded for compliance, timing, or account ownership reasons.
-
The route may not need to return to start. Many workflows are paths rather than cycles.
-
Human judgment changes the plan. A senior seller may override the route based on relationship context.
Because of this, developers should treat TSP as a planning primitive, not a complete architecture. The agent should be able to re-plan after each meaningful state change.
Plan route
|
v
Execute next safe action
|
v
Check state
|
v
Re-plan if changed
This avoids stale plans and keeps humans in control of the 20% that matters most.
Observability and Guardrails
A production agent needs logs, state, and failure handling. Without observability, route optimization can become a silent failure amplifier.
Minimum useful logs include:
- Input source and timestamp
- Contact or group identifiers
- Selected sequence template
- Variables checked
- Account status result
- Tool called
- Tool response
- Human review reason
- Launch timestamp
- Pause, resume, or stop reason
A safe agent should also support dry runs:
Dry run:
- Parse contacts
- Score readiness
- Propose groups
- Propose templates
- Identify missing variables
- Show launch candidates
- Do not execute LaunchSequence
Then production execution can be limited to low-risk batches. This lets teams validate the route before the agent acts.
Guardrails should include:
- Maximum contacts per launch batch
- Required variable validation
- Duplicate detection
- Account status checks
- Sequence template allowlist
- Human approval for high-value accounts
- Human approval for uncertain segments
- Stop conditions after tool errors
The goal is not to automate every decision. The goal is to automate the repeatable path and surface exceptions cleanly.
Practical Implementation Pattern
A strong first implementation can be built without overengineering.
Step 1: Define Nodes
Nodes might be contacts, groups, templates, or sequence operations.
Contact node:
- id
- company
- title
- segment
- completeness score
- account status
- recommended template
Step 2: Define Costs
Costs should be transparent and adjustable.
if missing required variable: +100
if unclear segment: +50
if account status unsafe: +1000
if template match strong: -20
if high-value account: +human_review_required
Step 3: Define Hard Constraints
Examples:
Do not launch if account status is unsafe.
Do not launch if required variables are missing.
Do not launch without a sequence template.
Do not update contacts outside approved fields.
Step 4: Select a Baseline Algorithm
Start with greedy sorting plus batching:
ready_contacts = contacts
.filter(pass_constraints)
.sortBy(execution_cost)
batches = groupBy(ready_contacts, segment, template)
Step 5: Add Local Improvements
Use 2-opt-like improvements conceptually:
- Merge tiny batches when templates match.
- Split large batches when risk rises.
- Reorder by account priority.
- Push uncertain records to human review.
Step 6: Execute Through MCP Tools
Keep execution bounded to verified actions:
ListSequenceTemplates
GetSequenceTemplate
ListVariables
CreateContactGroup
CreateContact
UpdateContact
LaunchSequence
For ongoing campaign management:
ListSequences
GetSequence
GetAccountStatus
PauseSequence
ResumeSequence
StopSequence
Step 7: Review Exceptions
The human queue should be small and meaningful:
Review reasons:
- Missing required variable
- Conflicting segment
- High-value account
- Unsafe account status
- Duplicate contact risk
- No approved template
This is the 80/20 split in action. The agent clears the repetitive majority while humans handle judgment.
Common Mistakes
Mistake 1: Optimizing Before Defining Costs
Without a good cost function, the algorithm optimizes the wrong objective.
Mistake 2: Treating LLM Reasoning as a Solver
LLMs can help classify, summarize, and explain. They should not silently override deterministic constraints.
Mistake 3: Ignoring State Changes
A plan generated at 9:00 may be unsafe by 10:00 if account status changes. Re-plan often.
Mistake 4: Automating the Human 20%
High-value accounts, ambiguous cases, and relationship-sensitive decisions should stay with humans.
Mistake 5: Inventing Tool Capabilities
Agent reliability depends on the real execution surface. If a tool does not exist, the agent should not plan around it.
FAQ
1. What is the travelling sales person problem in simple terms?
It is the problem of finding the lowest-cost route that visits every location once and returns to the starting point. In agent workflows, the same idea can be used to choose the best order for tasks, contacts, or sequence operations.
2. Is the travelling sales person problem the same as sales routing?
Not exactly. Sales routing can include territories, time windows, capacity, account priority, and human judgment. TSP is a simpler optimization model that helps structure the problem.
3. Should AI agents solve TSP exactly?
Usually not. Exact solutions are useful for small cases, but production workflows often benefit more from fast heuristics, constraints, observability, and human review.
4. How does TSP apply to LinkedIn outreach workflows?
It helps model the order of safe operational actions, such as preparing contacts, validating variables, grouping contacts, and launching approved sequences through a hosted LinkedIn relay or first-party session. It should not rely on scraping or invented tools.
5. What is the best first algorithm for developers?
A greedy sort with clear constraints is often the best starting point. Add batching, local improvements, dry runs, and human review before considering more complex solvers.
Build Practical Agent Workflows With Fintalio
The travelling sales person problem is a useful lens for building autonomous agents that sequence work intelligently. The best production systems do not chase full automation at any cost. They let agents handle the repetitive 80%, keep humans responsible for the judgment-heavy 20%, and execute through a bounded tool layer.
Explore Fintalio to build safer, clearer AI agent workflows with MCP support, predictable pricing, and practical RevOps automation.
Plug LinkedIn into your AI agent
Fintalio is the MCP server for LinkedIn. Connect Claude, Cursor, or your custom agent and ship outreach workflows in minutes — with audit logs and rate-limit awareness baked in.
Get started