Vision and Tool Use: Technical Approaches for Multimodal AI Agents
This article explains how multimodal AI agents combine visual understanding with tool calls. It covers joint text-vision training and data mixing, how perception results turn into tool invocations, parallel orchestration based on dependency graphs, evaluation design, and the architecture and security practices needed for production systems.
1. Background: From Language-Centric to Natively Multimodal
Large language models were originally built around text. To handle images, a common approach first converts an image into vectors with a separate vision encoder, then connects those vectors to the language model through an adapter layer. This “language first, vision added later” design is simple to implement and lets teams reuse existing language models. It has two clear drawbacks.
First, visual information enters the language model late in the pipeline, so the model cannot use the spatial structure and fine details of an image in early stages. Row and column relationships in a table, the hierarchy of interface controls, and axis ticks on a chart all depend on the visual representation keeping complete information. Injecting vision late can lose that information.
Second, visual and language representations are usually trained separately, so their semantic spaces are not aligned. A model can describe an image, but when it must reason over the image in multiple steps, it often understands the image yet reasons to the wrong conclusion.
Native multimodal design takes a different approach. Text and vision share the same optimization objectives during training, so visual and language capabilities influence each other instead of being stitched together.
2. Joint Optimization of Text and Vision
2.1 What Bidirectional Enhancement Means
The core of joint optimization is bidirectional enhancement.
- Vision helps language: screenshots, scanned documents, charts, and interface images provide factual grounding for language understanding, which reduces the model’s reliance on guesswork.
- Language helps vision: textual descriptions of object attributes, spatial relationships, and steps can guide the model to focus on key regions of an image and improve the stability of fine-grained recognition.
Bidirectional enhancement does not mean that gains in the two capabilities always happen together. Data mixing ratios, learning rate schedules, and loss weights all affect the final results, so ablation experiments are needed to confirm the effect of each choice.
2.2 Organizing Training Data
Multimodal training data usually includes the following types:
- Image-text pairs: images with matching descriptive text, used to build basic alignment.
- Interleaved image-text documents: articles or tutorials where images and text alternate, used to learn image-text relationships in context.
- Text recognition data: scanned documents, receipts, web page screenshots, and their text content, used to improve accurate reading of text.
- Interface and action data: application screenshots, operation steps, and resulting states, used to support later computer control tasks.
- Video frame sequences: frames sampled at fixed intervals with time-based descriptions, used to understand dynamic processes.
The following is an illustrative data configuration that shows how to mix data from different sources by ratio. The actual ratios should be adjusted for the target task.
data_mixture:image_text_pairs: 0.25interleaved_documents: 0.20ocr_documents: 0.15ui_screenshots_with_actions: 0.15text_only_corpus: 0.20video_frame_sequences: 0.05sampling:strategy: weighted_round_robinmax_image_tokens_per_sample: 4096
Keeping text-only data matters. Training on image-text data alone tends to degrade language ability, so a portion of the text corpus is usually retained.
2.3 Coupling the Vision Encoder with the Language Model
During joint training, you need to decide whether the vision encoder is updated. The common approaches are listed below.
| Approach | Advantages | Disadvantages |
|---|---|---|
| Freeze the vision encoder and train only the adapter layer | Low cost, stable training | Visual representations are hard to tune for the task |
| Staged training: align first, then jointly train | Balances stability and expressive power | More complex pipeline, hyperparameters must be tuned across stages |
| End-to-end joint training | Most thorough coordination between vision and language | High requirements for data quality and compute |
In practice, staged training is the more reliable choice. First, freeze the language model and train the vision-to-language alignment. Then unfreeze all parameters at a smaller learning rate and optimize jointly.
3. Coordinating Visual Input with Tool Calls
The practical value of multimodal capabilities shows up in whether they can drive tools to complete tasks. A typical flow works like this: the model receives an image, extracts structured information, then decides which tool to call and which parameters to pass.
3.1 Typical Processing Pipeline
- Perception: identify text, controls, tables, and charts in the image.
- Structuring: organize perception results into fielded descriptions, such as control type, position, and text content.
- Planning: determine the next action based on the user’s goal.
- Invocation: generate a tool call request, including the function name and parameters.
- Validation: check whether the parameters match the interface definition and whether the result matches expectations.
3.2 Tool Definition Example
Tool definitions usually use a general structured format, which helps the model generate valid parameters. The example below only illustrates the idea. The function names and fields are fictional.
tool: click_elementdescription: Click a specified control on the pageparameters:element_id: string, unique identifier of the control, taken from the perception resultaction: enum[click, double_click], type of actiontimeout_ms: integer, maximum time to wait for the control to become available, default 5000tool: extract_tabledescription: Extract structured data from a table region in an imageparameters:region: object, bounding box of the table areaoutput_format: enum[rows, csv], output format
3.3 Common Risks and Mitigations
Visual tool calling has three main risks.
- Perception errors: misidentified controls can cause clicks at the wrong position. Mitigations include capturing screenshots before and after critical actions for comparison, and setting rules to validate results.
- Parameter hallucination: the model may generate control identifiers that do not exist. Enforce strict parameter validation at the tool layer and reject unknown identifiers.
- Instruction injection: images may contain text such as “ignore previous instructions.” The system should treat text in images as data to process, not as a source of instructions.
4. Parallel Agent Orchestration
4.1 The Latency Bottleneck of Sequential Execution
When a single agent processes tasks sequentially, each step waits for the previous one to finish, including model inference and tool responses. When a task contains several independent subtasks, such as retrieving three documents and comparing their conclusions, sequential execution adds up all the waiting time. Total latency then grows linearly with the number of subtasks.
4.2 Task Decomposition and Dependency Graphs
Parallelization requires representing the task as a directed acyclic graph (DAG). Nodes are subtasks, and edges represent dependencies. Nodes without dependencies between them can run at the same time.
Total execution time depends on the critical path of the dependency graph, which is the longest chain of dependent subtasks, not the total number of subtasks. The first step in parallel design is therefore to analyze the critical path. If the critical path is long, adding parallelism yields limited gains. If most subtasks are independent, the gains are usually noticeable.
4.3 Role Division
A common orchestration structure has three roles.
- Orchestrator: decomposes the task, builds the dependency graph, assigns subtasks, and monitors progress.
- Worker: handles one subtask each, with its own context and restricted tool permissions.
- Aggregator: collects worker results, resolves conflicts, and produces the final output.
The following pseudocode shows the concurrent scheduling approach based on a dependency graph.
function run_plan(plan, budget):completed = {}while not all_done(plan):ready = [t for t in plan.tasksif t not in completed and all(d in completed for d in t.deps)]if ready is empty and no_running_tasks():raise error("dependency graph contains a cycle or a missing node")batch = ready[:budget.max_concurrency]results = parallel_execute(batch, timeout=budget.per_task_timeout)for task, result in results:if result.failed and task.retries < budget.max_retries:schedule_retry(task)else:completed[task.id] = resultreturn aggregate(completed, plan.output_spec)
4.4 Key Points for Concurrency Control
More concurrency is not always better, so it needs matching controls.
- Concurrency limits: cap the number of workers running at the same time to prevent overloading downstream services.
- Timeouts and retries: set a timeout for each subtask, and use a limited number of retries with exponential backoff after failures.
- Context isolation: workers share only the intermediate results they need, which avoids cross-contaminating their contexts.
- Budget control: parallel execution multiplies model calls and token consumption, so set an overall budget cap.
- Idempotency: tool calls with side effects, such as submitting a form, must be designed so that retries do not execute the action twice.
4.5 Estimating the Benefit
The latency reduction from parallel
