Visual Primitives and Tool Calling in Multimodal Agents: A Practical Guide
This article examines why multimodal agents often see clearly but still fail to reason reliably, focusing on two gaps: perception and reference. It compares structured visual primitives such as points, boxes, and polygons with tool-calling approaches that delegate detection, counting, cropping, OCR, and path search to deterministic programs. It also explains why benchmark results and production behavior diverge, proposes a four-layer evaluation breakdown, and outlines engineering practices for stable visual reasoning pipelines, including unified reference protocols, verifiable intermediate results, context compression, observability, and fallback strategies. Readers will find selection guidance, common pitfalls, and sample pseudocode for evaluation and runtime handling.
1. Background: Why Multimodal Agents See but Cannot Explain
A recent experimental multimodal model release drew attention from developers. The debate was not about benchmark scores but about a more fundamental question: when a model handles dense counting, localization under heavy occlusion, or path planning, does it operate on objects directly in a continuous visual space, or does it convert the image into a natural-language description and reason over that?
Two gaps are widely discussed in the industry:
- Perception gap: insufficient input resolution, tiling strategy, or encoding causes detail loss, so the model cannot see clearly.
- Reference gap: even when details are visible, the model still refers to objects in natural language within its reasoning chain (“the cup on the left”, “the third person”). In dense or similar-target scenes, such references are not unique, and the logic breaks down.
The idea behind visual primitives is to replace natural-language references with structured, unambiguous pointers, such as points, bounding boxes, and polygons, which act as addressable handles during reasoning. A more engineering-oriented route is “thinking with images plus tool calling”: the model does not hold geometric pointers itself but calls external tools for detection, counting, cropping, zooming, OCR, and path search, outsourcing uncertain perception tasks to deterministic programs.
The two routes are not mutually exclusive. In practice, a hybrid architecture is more common: the model handles planning and decisions, tools handle precise perception, and structured primitives pass unambiguous references between them.
2. How the Two Technical Routes Work
2.1 Visual Primitives
The core idea is to include geometric objects in the model’s vocabulary and output protocol so the model can point to image regions during reasoning instead of describing them. The advantages are:
- Stable reference: coordinates or geometric structures are inherently unique, reducing ambiguity.
- Short chain: no frequent external calls are needed, keeping latency and cost controllable.
- Composability: points, boxes, and polygons can form hierarchical references, making composite references such as “this person’s left hand” easier to express.
The costs are also clear: the precision of geometric output depends on encoder resolution and training coverage. If the vocabulary, training data, and inference configuration are inconsistent, a method may be reproducible in a paper but unstable in production.
2.2 Tool Calling (Thinking with Images)
The model outputs call intent and arguments, and the runtime executes deterministic algorithms and returns structured results. An illustrative protocol is shown below (pseudocode that expresses a convention only and does not refer to any specific product):
{"tool": "detect","args": { "target": "person", "region": {"type":"box","xyxy":[120,80,640,720]} },"expect": { "items": [{"id":"i1","box":[...]}, {"id":"i2","box":[...]}] }}
The advantages are precision and auditability: every step has inputs, outputs, and confidence scores, which makes tracing easier. The cost is a longer chain and a larger failure surface, requiring timeouts, retries, fallbacks, and result validation.
3. Why Papers and Production Results Diverge
Many disputes are not about model capability but about inconsistent evaluation configurations and engineering constraints. It helps to break evaluation into four layers and locate issues layer by layer:
- Input layer: whether resolution, number of tiles, and compression quality are consistent.
- Protocol layer: whether the structured primitive vocabulary is enabled and whether the tool whitelist is consistent.
- Orchestration layer: whether system prompts, context length, maximum steps, and timeout policies are consistent.
- Metric layer: use absolute error for counting, IoU thresholds for localization, and executable success rate for planning, rather than a single accuracy number.
A reusable evaluation skeleton:
def evaluate(case, cfg):img = load(case.image, max_side=cfg.max_side)trace = []for step in range(cfg.max_steps):out = model.plan(img, trace, tools=cfg.tools, primitives=cfg.primitives)if out.type == "tool":res = runtime.call(out.tool, out.args, timeout=cfg.timeout)trace.append({"tool": out.tool, "args": out.args, "res": res})if not res.ok:trace.append({"fallback": cfg.fallback_policy})elif out.type == "answer":return score(case, out.answer, trace)return score(case, None, trace, exhausted=True)
4. Engineering Practice: Designing a Stable Visual Reasoning Chain
- Define task layers clearly: delegate recognition, counting, and localization to tools, and leave comparison, planning, and explanation to the model.
- Unify the reference protocol: use the same geometric structures and ID system across the chain to prevent natural-language references from creeping back in.
- Enforce verifiable intermediate states: attach confidence scores and bounding boxes to every tool result, and trigger re-sampling or zoom retries when confidence is low.
- Compress context: return only necessary fields and thumbnails to control context growth.
- Ensure observability: log inputs, outputs, latency, and failure reasons for each step, connect to logging services and monitoring alerts, and build a regression baseline.
- Plan for elasticity and cost: heavy compute tasks can be moved to container platforms and object storage for batch processing, with queues used to smooth peaks.
An illustrative runtime wrapper:
class Runtime:def call(self, tool, args, timeout):try:r = registry[tool](**args)return {"ok": r.conf >= 0.6, "data": r.items, "conf": r.conf}except Exception as e:return {"ok": False, "error": str(e)}
5. Selection Guidance and Common Pitfalls
- If tasks mainly involve dense counting and fine-grained localization and are latency-sensitive, prioritize structured primitives or “primitives plus lightweight tools”.
- If tasks are open-ended and the tool ecosystem is mature, prioritize tool calling to gain precision and auditability.
- Pitfall 1: treating benchmark scores as production performance while ignoring differences in resolution and protocols.
- Pitfall 2: letting the model refer to objects in natural language, which accumulates ambiguity.
- Pitfall 3: lacking a fallback strategy, so a single tool failure breaks the whole chain.
6. Conclusion
The stability of a multimodal agent depends on whether references are unambiguous, whether perception is verifiable, and whether orchestration can degrade gracefully. Whether you use structured visual primitives or external tool calling, the core is to turn uncertain perception into addressable, verifiable, and traceable engineering objects. In related practice at Baidu AI Cloud, such capabilities are typically delivered through combinations of common categories such as container platforms, object storage, logging services, and monitoring alerts, helping teams build reproducible and operable visual reasoning systems.
