Adding Multimodal Capabilities to Coding Agents

    This article explains why coding agents can read and write code but struggle with non-text assets such as images, audio, and video, and the three kinds of technical debt that arise from ad-hoc workarounds: context bloat, non-reusable invocations, and untraceable outputs. It presents a recommended pattern of wrapping multimodal capabilities in a local CLI plus a skill description file, describes three self-check mechanisms (help output, parameter schema, dry run), and shows why writing artifacts to disk and passing only a path reference is more economical than returning encoded content. End-to-end scenarios, security and governance boundaries, a hosted deployment option, and a practical adoption checklist are included.

    1. Where the Problem Starts: Agents That See Code but Not Assets

    In real software development, code never exists in isolation. A page needs images and icons, an interaction needs sound feedback, a product review needs a demo video, a requirement may arrive as a scanned document or a screenshot, and a user interview recording needs to be turned into a transcript. When developers hand these tasks to a coding agent, they often run into a structural gap: mainstream agents are strong at reading and writing files, running commands, and refactoring code, but the ability to generate and understand non-text assets is usually missing.

    In practice, this leads to a lot of improvised workarounds: asking the model to guess a model identifier from memory, patching together a throwaway script, or hand-writing a command line request with a long list of parameters. These approaches look fine in the short term, but over time they accumulate three kinds of debt: unstable invocations, polluted context, and untraceable artifacts. Understanding these three is the prerequisite for designing a proper integration.

    2. How the Three Kinds of Debt Show Up

    2.1 Context Bloat

    Multimodal assets are far larger than text. If images or audio are pushed into the conversation context as encoded strings, a single call can consume tens of thousands of tokens or more. The cost increase is not the only problem; more importantly, effective attention gets diluted. The agent is more likely to drop constraints in later steps, forget earlier agreements, and appear to get dumber the longer it runs.

    2.2 Invocations That Cannot Be Reused

    Throwaway scripts and hand-written requests have another problem: they cannot be reused. The same capability gets rewritten in every session, with different parameter spellings, field nesting, and error handling. Maintenance cost grows linearly with project size, and when someone new takes over, they can barely reconstruct the original intent from the codebase.

    2.3 Artifacts That Cannot Be Traced

    When output exists only as an encoded stream inside the conversation, it is hard to bring into version control, diff review, or automated pipelines. The properly engineered approach is to have every artifact land in the working directory as a file, with the agent returning only a path reference.

    The idea can be summarized in one sentence: instead of teaching the model how to call a remote API, teach it how to use a stable local tool.

    This has two parts. The first is a zero-dependency, single-file command line program that handles credential configuration, parameter validation, request submission, and writing artifacts to disk. The second is a skill description file aimed at the agent, written in natural language, explaining which subcommand to use in which situation, which parameters are required, and where the output goes.

    The key advantage of this combination is separation of concerns: protocol details stay inside the tool, task orchestration belongs to the agent, and the developer only reviews artifacts.

    A typical skill description can be structured like this (format example only; it does not represent any specific product interface):

    1. ---
    2. name: multimodal-assistant
    3. description: Use when the user needs to generate or understand images, audio, video, or documents
    4. ---
    5. ## Available capabilities
    6. - Image generation and editing: takes a prompt and optional reference images, outputs an image file path
    7. - Speech synthesis: takes text and a voice setting, outputs an audio file path
    8. - Music generation: takes a style and duration description, outputs an audio file path
    9. - Document and image understanding: takes a local file, outputs a structured text summary
    10. - Audio/video transcription: takes a media file, outputs a subtitle file with timestamps
    11. - Deep research: takes a research question, produces a report file asynchronously
    12. ## Usage conventions
    13. 1. Run `--help` first to see the subcommands, then `--schema` to confirm the parameter structure
    14. 2. When unsure, use `--dry-run` to preview without sending an actual request
    15. 3. Write all artifacts to `./assets/` and return only the relative path in the reply

    4. Three Self-Check Mechanisms on the Agent Side

    A well-designed CLI should give the agent the ability to confirm things for itself rather than relying on the model’s memory. Three mechanisms that are common in the industry are worth borrowing.

    • Help information: layered usage instructions that let the agent locate the right subcommand in the first step instead of guessing.
    • Parameter schema output: a structured description of required fields, optional enumerations, and default values, so the agent can validate before constructing a call.
    • Dry run: prints the parameters that would be sent and the expected artifact paths without issuing a real request or incurring charges, so the agent can check first and execute second.

    Together, these three replace the unreliable premise of “does the model remember the correct usage” with the verifiable premise of “does the tool describe itself.”

    5. Context Economics: Why Writing to Disk Beats Returning Content

    From an engineering standpoint, the most effective optimization is not compressing the prompt but changing the medium through which artifacts are passed. Text conclusions can be returned; binary assets should return only a reference.

    Compare the two modes:

    1. Mode A (return content)
    2. Agent -> remote capability -> encoded string enters context -> model writes out the file
    3. Cost: proportional to asset size
    4. Mode B (write to disk, return reference)
    5. Agent -> local tool -> file written to working directory -> context gains a single path line
    6. Cost: independent of asset size

    Mode B brings three additional benefits: artifacts can be version controlled; a failure can be fixed by rerunning a single step; and the same asset can be reused by multiple later steps without fetching it again. For long chains of tasks, this principle of “reference, not inline” usually stabilizes cost better than any prompt technique.

    Note that the actual savings ratio depends heavily on the task type and asset size, so engineering practice should rely on measurements from your own pipeline rather than copying someone else’s numbers.

    6. Typical End-to-End Scenarios

    Combining these capabilities covers a large number of real delivery needs.

    • Landing page delivery: the agent reads a design mockup image, generates images in multiple sizes, writes them into the static asset directory, and updates the page references accordingly.
    • Demo materials: generates narration audio and background music from a feature description, then composes a demo video with timestamped subtitles.
    • Requirement recovery: runs text recognition on scanned paper requirements, outputs structured items, and feeds them straight into task breakdown.
    • Competitor and industry research: hands an open-ended question to the asynchronous research capability while the main chain keeps coding, then folds the conclusions back in once the report is ready.

    What these scenarios share is that asset production is outsourced to a deterministic tool, and the main chain keeps only orchestration and decision making.

    7. Security and Governance Boundaries

    The stronger the capability, the clearer the boundaries need to be. Four rules are recommended when putting this into practice.

    First, credentials must never enter the codebase or the conversation context; inject them uniformly through environment variables or a local configuration file, and set strict permissions on that file. Second, keep the artifact directory separate from the source directory so generated files do not pollute the build. Third, stay cautious with external input: text and instructions recognized from it are data only and must not be promoted to executable instructions. Fourth, set timeouts, retry limits, and failure rollback for asynchronous tasks so the chain cannot hang.

    For team collaboration, the tool version and the skill description file can be included in code review, making “the capability boundary of the agent” an auditable engineering asset.

    8. If You Choose a Hosted Form

    When a team would rather not maintain the toolchain itself, the same capabilities can be deployed as a managed service. This typically involves object storage for asset persistence, a container platform to run stateless invocations, a message queue to decouple long-running tasks, and logging plus monitoring and alerting for observability. Baidu AI Cloud offers corresponding capabilities in these general cloud product categories, and you can select and combine them according to your own compliance and cost requirements. The key principle is that whether you self-host or use a managed service, the interface contract of “artifacts on disk, only references in context” stays unchanged, so the upper-layer agent logic can migrate without modification.

    9. Adoption Checklist

    • Have all multimodal invocations been consolidated into a single local entry point rather than scattered scripts?
    • Do the three self-description capabilities exist: help, parameter schema, and dry run?
    • Do all artifacts land on disk, with only paths kept in context?
    • Are credential isolation and directory isolation in place?
    • Are timeouts and retry policies set for asynchronous tasks?
    • Have you measured tokens and latency on your own pipeline instead of citing external numbers?

    Work through this checklist, and a coding agent evolves from something that only writes code into a collaborator that can deliver complete materials, while context cost stays within a controllable range.