Upgrading Visual and Tool Capabilities in Multimodal Agents: A Technical Analysis

    This article explores the technical evolution from post-hoc visual adaptation to native multimodal architectures. It details the components of a unified multimodal model—including visual encoders, cross-modal projection layers, and language backbones—emphasizing end-to-end joint optimization. Additionally, it covers native resolution visual encoding strategies, multi-agent parallel orchestration to reduce latency, and provides practical recommendations for engineering implementation and system evaluation.

    1. Background: From Post-Hoc Visual Adaptation to Native Multimodal

    Early multimodal systems predominantly adopted the approach of “first training a language model, then attaching a visual encoder.” While this method is cost-effective and quick to deploy, it presents two significant issues. First, because the visual and language modules are trained in separate stages, their semantic spaces are difficult to fully align. This often results in degraded language capabilities or interference between visual understanding and text reasoning. Second, visual inputs typically undergo fixed-size cropping or scaling, leading to the loss of detail during the preprocessing phase—such as small text in tables, fine lines in charts, or control text in UI screenshots.

    The native multimodal design approach places vision and text within the same training process, allowing both modalities to mutually constrain each other during end-to-end optimization. Although this design imposes higher demands on data ratios, training stability, and engineering infrastructure, it enables the model to achieve more consistent performance across tasks like visual QA, document understanding, and UI manipulation.

    2. Composition of a Unified Multimodal Architecture

    A typical unified multimodal model can be broken down into three main components.

    2.1 Visual Encoder

    The visual encoder is responsible for converting images or video frames into a set of feature vectors. Unlike traditional approaches, it must simultaneously support arbitrary resolutions, arbitrary aspect ratios, and handle the temporal dimension of videos. The encoder’s output format is typically a sequence, with the sequence length varying according to the input size.

    2.2 Cross-Modal Projection Layer

    The dimensionality of visual features and the embedding dimensionality of the language model generally differ, and their distributions are inconsistent. The projection layer—usually a small network consisting of one or two linear layers with an activation function—maps visual features into the language model’s embedding space. Although the projection layer is lightweight, it dictates the form in which visual information enters the language model. Its design must address information bottlenecks to avoid over-compression.

    2.3 Language Backbone

    The visual projected tokens are concatenated with text tokens and fed together into the language backbone. The backbone can be a dense architecture or a Mixture of Experts (MoE) structure. When using an MoE structure, each token only activates a fraction of the expert parameters, allowing for expanded model capacity while keeping inference costs controllable.

    2.4 Why End-to-End Joint Optimization is Emphasized

    Joint optimization means that the visual encoder, projection layer, and language backbone are updated together under the same loss function. The advantage is that visual features are learned in a direction that benefits downstream reasoning, rather than merely aiming for reconstruction or classification metrics. The trade-off is increased training complexity, requiring more careful design of learning rates, freezing strategies, and data sampling ratios. A common practice is phased training: first, freeze the language backbone to train the visual encoder, and then unfreeze all parameters for joint fine-tuning.

    3. Implementation of Native Resolution Visual Encoding

    3.1 Patching and Variable-Length Sequences

    Visual encoders typically slice an image into fixed-size patches, flattening each patch into a one-dimensional vector. Traditional methods scale all images to a uniform size, resulting in a fixed sequence length. Native resolution approaches, however, retain the original image dimensions, performing only necessary boundary cropping, so that each image yields a sequence of different lengths. The example below demonstrates this process:

    1. import numpy as np
    2. def image_to_patches(img: np.ndarray, p: int = 14) -> np.ndarray:
    3. """Splits an H x W x C image into an N x (p*p*C) patch sequence.
    4. Crops only to a multiple of p without scaling, preserving original pixel details."""
    5. h, w, c = img.shape
    6. h, w = h - h % p, w - w % p
    7. img = img[:h, :w]
    8. x = img.reshape(h // p, p, w // p, p, c)
    9. x = x.transpose(0, 2, 1, 3, 4)
    10. return x.reshape(-1, p * p * c)
    11. img = np.random.rand(480, 640, 3)
    12. print(image_to_patches(img).shape) # (1530, 588)

    Different images result in different sequence lengths. During training, multiple variable-length sequences can be concatenated into a long sequence, recording the start and end positions of each segment. This is used to construct a block-diagonal attention mask, preventing different images from attending to one another.

    3.2 Unified Representation of Image and Video

    Video can be viewed as a set of image frames along the temporal dimension. A straightforward approach is to design a separate temporal module for video, but this increases structural complexity and makes it difficult to transfer image capabilities to video. Another approach is to group several consecutive frames into a spatiotemporal volume, packing each patch in both space and time, and then passing it to the same encoder.

    The example below groups 4 consecutive frames as a temporal unit:

    1. def video_to_spatiotemporal_patches(frames: np.ndarray, p: int = 14, t: int = 4) -> np.ndarray:
    2. """Splits a T x H x W x C video into a spatiotemporal patch sequence.
    3. Every t frames form a temporal unit, and each spatiotemporal patch contains the p x p region across t frames."""
    4. T, H, W, C = frames.shape
    5. T, H, W = T - T % t, H - H % p, W - W % p
    6. frames = frames[:T, :H, :W]
    7. x = frames.reshape(T // t, t, H // p, p, W // p, p, C)
    8. x = x.transpose(0, 2, 4, 1, 3, 5, 6)
    9. return x.reshape(-1, t * p * p * C)

    The advantage of this representation is that images and videos share the same patching rules. An image can be treated as a special case where t=1. The encoder only needs to learn a single joint spatial-temporal attention pattern, eliminating the need to maintain a separate branch for video.

    3.3 Engineering Benefits and Trade-offs

    The benefits of native resolution encoding are primarily threefold: retaining detail, reducing preprocessing logic, and unifying the image and video pipelines. The trade-off is an uncontrollable sequence length. A massive image might generate thousands of patches, and the computational cost of attention grows quadratically with sequence length. In actual deployment, it is usually necessary to set a maximum pixel budget; if this budget is exceeded, the image is scaled down proportionally. This scaling information should be logged to facilitate troubleshooting.

    4. Multi-Agent Parallel Orchestration

    4.1 Sequential Execution Latency Bottleneck

    When agents handle complex tasks, a common workflow is “plan, retrieve, call tool, aggregate.” If all steps are executed sequentially, the total latency equals the sum of the time consumed by each step. When a task contains multiple independent subtasks—such as querying three documents simultaneously or scraping data from five pages concurrently—sequential execution causes significant idle waiting time.

    4.2 Dependency Graph and Parallel Scheduling

    A more rational approach is to model the tasks as a Directed Acyclic Graph (DAG). Nodes represent subtasks, and edges represent data dependencies. Nodes without dependencies can be executed in parallel; subsequent nodes only start once their prerequisite nodes are complete. Below is a simplified scheduler example:

    1. import asyncio
    2. async def execute(graph: dict[str, list[str]], runners: dict) -> dict:
    3. """The keys of 'graph' are task names, and values are lists of dependency task names.
    4. The keys of 'runners' correspond to task names, and values are async functions,
    5. with parameters being the outputs of dependency tasks in order."""
    6. done: dict = {}
    7. remaining = dict(graph)
    8. while remaining:
    9. ready = [n for n, deps in remaining.items() if all(d in done for d in deps)]
    10. if not ready:
    11. raise ValueError("Circular dependency detected in task graph")
    12. outputs = await asyncio.gather(
    13. *(runners[n](*(done[d] for d in graph[n])) for n in ready),
    14. return_exceptions=True,
    15. )
    16. for name, out in zip(ready, outputs):
    17. done[name] = out
    18. del remaining[name]
    19. return done

    This code executes tasks by layers, with tasks in the same layer running concurrently. Note that return_exceptions=True returns exceptions as results. Downstream tasks must check whether their inputs are exception objects; otherwise, errors will propagate silently.

    4.3 Failure Isolation and Result Aggregation

    Parallel orchestration must address three main issues:

    • Timeout control: Each subtask should have an independent timeout to prevent a single slow task from stalling the entire process.
    • Failure isolation: When a subtask fails, its downstream dependencies should be marked as skipped or degraded, rather than aborting the entire process.
    • Result aggregation: The aggregation node must clarify the source and status of each input, facilitating the generation of a traceable final answer.

    In practice, the speedup brought by parallelism depends on the dependency structure. If most tasks are serially dependent, parallelism offers little benefit. Therefore, before introducing parallel orchestration, it is crucial to analyze the critical path length of the task graph to estimate the theoretical speedup ceiling.

    5. Engineering Implementation Recommendations

    1. Evaluate the resolution distribution of business data first. If most inputs are low-resolution screenshots, the benefits of native resolution are limited and will only increase computational costs.
    2. Set a pixel budget for visual inputs and record the scaling ratio for each instance to ensure reproducible results.
    3. For video inputs, prioritize fixed temporal unit segmentation and save frame indices in the metadata for easy location of the time segment corresponding to an answer.
    4. For tool-calling tasks, draw a dependency graph first to distinguish genuine data dependencies from artificially imposed execution orders.
    5. Parallel scheduling must be paired with rate limiting and retry strategies to prevent concurrent requests from overwhelming downstream services.

    6. Evaluation and Validation Methods

    Evaluation should cover three categories of metrics: task accuracy, end-to-end latency, and resource consumption. Visual tasks can be subdivided into subsets such as fine-grained recognition, document understanding, chart reasoning, and video temporal QA, and evaluated separately to avoid relying solely on an aggregate score. For agent tasks, record the duration and failure reasons of each subtask, and use critical path analysis to identify the true bottlenecks.

    When conducting comparative experiments, fix the random seed, dataset version, and inference parameters, and repeat at least three times to take the mean. If using live traffic for A/B testing, monitor both the error rate and user feedback simultaneously to ensure that performance improvements are not achieved at the expense of stability.