Visual Primitives and Tool Calling for Multimodal Agents: A Practical Guide
This article examines the real bottlenecks in multimodal agents, introduces visual primitives such as points, boxes, and polygons for stable spatial reference, and compares them with tool-based "thinking with images" approaches. It also covers agent framework configuration, observability, evaluation design, and deployment considerations for building reliable image-and-text workflows.
1. The Real Bottleneck in Multimodal Agents
In image-and-text tasks, there is often a clear gap between what a model can “see” and whether it “reasons correctly.” The first issue is commonly called the perception gap: when input resolution is insufficient, targets are too small, or textures are dense, the model simply cannot capture enough detail.
A more hidden problem is the reference gap. Even when image information is fully available in the context, the model still relies on natural language to describe target positions and counts, such as “the third person from the top left” or “the block near the edge.” Natural language is inherently ambiguous. Once targets are dense or boundaries are complex, references drift, and the reasoning chain that follows can collapse.
Therefore, the capability ceiling of a multimodal agent does not depend only on how strong the visual encoder is. It depends on whether the agent can convert visual information into structured symbols that can be reliably operated on during reasoning. This is the problem that visual primitives aim to solve.
2. Visual Primitives: Turning Images into Addressable Spatial Structures
The core idea of visual primitives is to introduce a set of unambiguous pointers into continuous visual space, replacing natural-language descriptions with structured objects. A common primitive set includes points, bounding boxes, and polygons, corresponding to localization, coarse region selection, and fine contour representation. They appear in the vocabulary as paired special tokens, forming a closed syntactic structure so that model outputs are both readable and parseable.
An illustrative token format is shown below (structure only, not tied to any specific implementation):
<point> x_norm, y_norm <\point><box> x_min, y_min, x_max, y_max <\box><polygon> x1,y1 x2,y2 ... <\polygon>
This design brings three benefits:
- Stable reference: Coordinates are deterministic values that do not change with phrasing, so dense counting and precise localization no longer depend on linguistic ambiguity.
- Composability: A point can serve as an anchor, a box as a region constraint, and a polygon as a mask approximation. Together they can form an action sequence of “locate first, select a region next, then trace the contour.”
- Verifiability: Outputs can be parsed and validated by programs, making geometric consistency checks and fallback retries easier within a toolchain.
It is important to note that visual primitives do not replace language reasoning. They turn “looking at an image and describing it” into “looking at an image and operating on it,” leaving language responsible only for planning and orchestration.
3. An Alternative Approach: Tool Calling for Thinking with Images
A mature parallel approach externalizes image operations as tools. Instead of directly producing coordinates, the model issues calls for cropping, zooming, annotation, counting, or region queries, then continues reasoning based on the returned images. This approach is often summarized as “thinking with images.” Its advantages include low implementation cost, strong interpretability, and the ability to reuse mature image-processing capabilities.
The trade-offs between the two approaches can be understood as follows:
- Built-in primitives: Spatial addressing is embedded into the model and vocabulary, resulting in a short pipeline and low latency, but it depends on sufficient alignment during training.
- Tool calling: Capabilities reside in the agent framework, enabling fast iteration and observability, but multi-turn interactions introduce extra latency and context growth.
In engineering practice, the two are not mutually exclusive. A practical approach is to use tools for coarse localization to narrow the range quickly, delegate fine-grained reference to primitive outputs, and finally let the framework perform unified parsing and validation.
4. The Role of the Agent Framework: Why Configuration and Observability Matter
An often underestimated fact is that multimodal capabilities are ultimately delivered through an agent framework, and the framework’s configuration, default parameters, and observability directly affect result stability. Common pain points include inconsistent configuration formats, unclear upgrade paths, and mismatches between default profiles and documentation, causing the same task to behave differently across entry points.
It is recommended to fix four things in your own system:
- Single source of configuration: Use a structured configuration file that specifies the model identifier, temperature, maximum turns, image resolution limit, and so on, avoiding two separate versions in command-line usage and documentation.
- Version locking: Pin dependency and runtime versions, roll out upgrades gradually, and validate with small traffic before full rollout.
- Traceable trajectories: Record the input summary of each turn, tool call parameters, returned image hashes, and final parsing results.
- Fallback on failure: When parsing fails or geometric validation does not pass, automatically switch to strategies such as “crop and zoom again” or “switch to box selection.”
An example configuration structure is shown below:
model: vision-agentruntime:max_turns: 6image_max_side: 1536temperature: 0.2tools:crop: truezoom: trueannotate: trueprimitives:point: truebox: truepolygon: false
5. Evaluation Design: Do Not Look Only at Benchmark Scores
Public benchmark scores reflect only part of the capability. Real-world business scenarios care more about stability. It is recommended to build a three-layer evaluation:
- Perception layer: Small-object recognition, dense counting, and fine-grained texture discrimination, measured by accuracy and repeatability consistency.
- Reference layer: Given a target description, measure the intersection-over-union between output primitives and ground truth, as well as center-point error.
- Task layer: End-to-end completion rate, such as form filling, chart reading, and UI element localization, measured by first-pass rate and average number of turns.
Also introduce a “run the same image multiple times” consistency test: run the same input multiple times, and if the result variance is too large, the reference stage is still unstable, so priority should be given to strengthening primitives or tightening tool strategies.
6. Implementation Suggestions and Integration with General Cloud Capabilities
To support such multimodal agents in production, you can build a closed loop with general cloud capabilities: use object storage to store images and intermediate artifacts, use a message queue to smooth peaks and support asynchronous tool calls, use a container platform to host image preprocessing and parsing services, and use logging and monitoring alerts to track latency, failure rate, and consistency metrics. Baidu AI Cloud offers corresponding capabilities in these general categories, which can be combined as needed, but specific parameters and specifications should be based on the official documentation.
In summary, the key to multimodal agents is not pursuing a single-point metric, but making spatial reference a first-class citizen that is programmable, verifiable, and observable. Whether you choose built-in visual primitives or the tool-based approach of thinking with images, clear configuration and a complete evaluation loop can significantly improve stability and delivery quality in image-and-text scenarios.
