Visual Primitives and Tool Calling for Multimodal AI Agents: A Practical Guide

    This article explains why multimodal AI agents often fail at precise reference even when they can see an image, and how to fix it with structured visual primitives. It defines point, box, and polygon primitives, compares embedding primitives directly in the model with tool-based "thinking with images" workflows, and outlines a five-step agent loop from task parsing to verification. It also covers reproducible configuration baselines, evaluation metrics for reference accuracy, counting error, and path feasibility, plus how general cloud capabilities support production deployment.

    1. The Starting Problem: Why Multimodal Agents “See but Cannot Explain”

    Once multimodal agents move into real business workflows, the most common failure is not that the model “cannot see the image at all.” It is that the model sees the image but cannot refer to objects reliably. Typical symptoms include:

    • Counting errors on dense small objects
    • Bounding box drift in complex scenes
    • Maze or path-planning reasoning that breaks midway through the chain
    • Contradictory conclusions for the same image across different sessions

    The industry groups these issues into two gaps. The first is the perception gap: input resolution, tiling strategy, and encoding methods cause fine details to be lost. The second is the reference gap: the model still describes positions and objects in natural language while reasoning, and the ambiguity of language makes multi-object and overlapping-object scenarios collapse quickly.

    A more reliable engineering approach is therefore to decouple “seeing the image” from “pointing at the image”: the vision encoder supplies detail, structured primitives carry precise reference, and the reasoning chain only composes and computes over those primitives.

    2. Abstract Definition and Structured Representation of Visual Primitives

    A visual primitive can be understood as an unambiguous pointer constructed in continuous visual space. It does not rely on natural language description; it anchors objects directly with computable structures. Three common primitive types are:

    • Point: for anchors, center localization, and keypoints
    • Box: for candidate region cropping, local zoom, and object boundaries
    • Polygon: for irregular contours, occluded regions, and fine segmentation approximation

    At the tokenization and serialization level, these primitives are usually wrapped in paired tags to form closed structures, which makes them easy for the model to generate and for a parser to validate:

    1. <point>x,y</point>
    2. <box>x1,y1,x2,y2</box>
    3. <polygon>x1,y1;x2,y2;...;xn,yn</polygon>

    In practice, three layers of constraints are recommended for primitives: normalize coordinates to a fixed range, unify numeric precision, and strictly validate closing tags. When parsing fails, fall back to regenerating the primitive instead of letting the model keep guessing in natural language.

    3. Two Technical Routes: Embedded Primitives vs. Tool-Based Reasoning

    Two routes are common in the industry. The first treats primitives as an internal model capability, producing and operating on primitives directly during reasoning. The second is the tool-based “thinking with images” route, where the model calls external vision tools for cropping, zooming, annotation, and re-recognition, then feeds the intermediate outputs back as new inputs.

    The difference lies in controllability and observability. The tool-based route has the advantage that every step can be logged, reproduced, and swapped for a different implementation, which suits agent frameworks better. The embedded-primitive route feels smoother end to end, but debugging and regression costs are higher. For most teams, the recommendation is to first build a tool-based closed loop to carry primitives, then gradually consolidate high-frequency primitive operations into internal capabilities.

    4. Agent Loop Design: From Primitives to Verifiable Conclusions

    A robust loop typically has five steps:

    1. Task parsing: determine whether the task is counting, localization, path planning, or attribute recognition
    2. Coarse localization: generate a candidate box list and cap the count to avoid noise explosion
    3. Local zoom: crop by box and resize uniformly to mitigate the perception gap
    4. Fine localization: output a point or polygon on the zoomed image to form a unique reference
    5. Review and convergence: deduplicate, detect conflicts, and resample when necessary

    Illustrative pseudocode:

    1. def solve(image, task):
    2. boxes = propose_boxes(image, task, max_k=16)
    3. points = []
    4. for b in boxes:
    5. crop = zoom(image, b, scale=2.0)
    6. p = model.point(crop, prompt=task)
    7. points.append(to_global(p, b))
    8. points = dedup(points, iou_thr=0.6)
    9. return verify(task, points)

    The key is being able to fall back: any failed validation at any step triggers a limited number of retries, rather than endless self-persuasion.

    5. Configuration and Runtime Environment: Making Experiments Reproducible

    Agent framework configuration is often organized as structured files or startup parameters. Model identifiers, temperature, max steps, and tool allowlists should all be declared explicitly. A common problem in practice is that documentation and the real entry point disagree, causing users to trial-and-error repeatedly. Three baselines are recommended:

    • Version baseline: pin framework and dependency versions, and roll out upgrades gradually
    • Configuration baseline: keep configuration templates in version control and prohibit implicit local overrides
    • Evaluation baseline: fix the sample set and scoring scripts, and emit structured reports

    Illustrative configuration (neutral example):

    1. {
    2. "model": "vision-agent-default",
    3. "temperature": 0.0,
    4. "max_steps": 8,
    5. "tools": ["crop", "zoom", "annotate"]
    6. }

    6. Evaluation Methods: Turning “Looks Right” into “Measurably Right”

    Evaluation should cover three metric families: reference accuracy (the proportion of points within a distance threshold of the ground-truth center), counting error (absolute and relative error), and path feasibility (collision rate and step count). The intermediate primitive sequence must also be recorded so failures can be attributed to perception or to reasoning. Stratified sampling is recommended, with a set proportion each for sparse scenes, dense scenes, occluded scenes, and low-light scenes, so that aggregate metrics do not hide local collapse.

    7. Engineering Deployment and General Cloud Capabilities

    At the deployment level, general cloud capabilities can support the loop: object storage holds samples and primitive traces, message queues decouple asynchronous inference tasks, container platforms host elastically scaling agent services, and logging plus monitoring with alerting track failure rates and latency percentiles. Baidu AI Cloud can provide standardized resources and operational support in these general categories, helping teams move smoothly from an experimental environment to production without changing the core reasoning logic.

    8. Conclusion

    The stability bottleneck of multimodal agents is shifting from “can it see” to “can it refer precisely and verify.” A primitive system built from points, boxes, and polygons, combined with a tool-based reasoning loop, strict configuration baselines, and stratified evaluation, is the more reproducible engineering paradigm available today.