Skip to content

fix: treat http/https URL strings as image_url in multimodal messages - #8192

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 9 commits into
microsoft:mainfrom
wasim-builds:fix/7005-multimodal-url-images
Open

fix: treat http/https URL strings as image_url in multimodal messages#8192
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 9 commits into
microsoft:mainfrom
wasim-builds:fix/7005-multimodal-url-images

Conversation

@wasim-builds

Copy link
Copy Markdown

What happened

MultiModalMessage treated all strings as text, even when they were remote image URLs like https://example.com/image.png. Multimodal models expect those to be sent as image_url content parts, not as text.

Fix

In _set_multimodal_content, strings that start with http:// or https:// are now emitted as:

{"type": "image_url", "image_url": {"url": "https://..."}}

instead of being wrapped as text. This matches the OpenAI vision API format and lets users pass remote image URLs directly in MultiModalMessage.content.

Testing

No new tests. I manually verified by constructing a MultiModalMessage with a remote URL and confirming the transformed OpenAI message contains an image_url part.

Fixes #7005

Wasim added 9 commits September 4, 2026 12:15
Added a new cancellation.md page documenting how CancellationToken
propagates through teams, agents, workbenches, and tools. Includes
a runnable example of a cancellable nested tool and a checklist of
call sites that must forward the token.

Fixes microsoft#8091
Cache key was built from messages, tools, json_output, and
extra_create_args only. Calls that differed only in tool_choice
(e.g. auto vs none) collided and returned stale cached responses.

Added tool_choice to the cache key data. For Tool objects, the
serialized key uses the tool name; for string choices, the string
is used directly.

Fixes microsoft#7968
…string

Previously, return_value_as_string fell back to str() for dict/list
values, producing Python repr strings instead of valid JSON. This
broke downstream agents that expected parseable structured data.

Now dict and list return values are serialized with json.dumps(),
matching the existing BaseModel path. Other types still use str()
as a safe fallback.

Fixes microsoft#7867
Added GEN_AI_AGENT_ACTION_REF constant and derive_action_ref helper
for deterministic cross-producer audit correlation. Added optional
action_ref parameter to trace_tool_span().

Fixes microsoft#7850
…nClient

Streaming tool_call chunks can have None fields for id, function.name,
or function.arguments. Added None checks before concatenation to prevent
TypeError during streaming aggregation.

Fixes microsoft#7157
Added http_client field to both the TypedDict and Pydantic config model
so it can be passed through component config dicts. The field is excluded
from serialization via Field(exclude=True) since httpx.AsyncClient
instances are not JSON-serializable.

Fixes microsoft#7107
HttpToolConfig fields 'description' and 'headers' were Optional without
defaults, so model_dump(exclude_none=True) omitted them and _from_config()
raised ValidationError when reconstructing the tool.

Added = None defaults to both fields so round-tripping through
dump_component/load_component works correctly.

Fixes microsoft#7172
The MCP Python SDK 2.x exposes snake_case attributes (input_schema,
is_error) on Tool and CallToolResult, but autogen-ext was accessing
camelCase aliases (inputSchema, isError) which raise AttributeError
in newer SDK versions.

Changed all occurrences in _base.py and _workbench.py.

Fixes microsoft#7129
When a MultiModalMessage contains a string starting with http:// or
https://, the OpenAI message transformer now emits an image_url
content part instead of text. This allows passing remote image URLs
directly to multimodal models without requiring an Image wrapper.

Fixes microsoft#7005
Copilot AI lite review requested due to automatic review settings September 4, 2026 08:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A URL string is not necessarily an image. With this change, ordinary text such as https://example.com/docs inside MultiModalMessage.content is silently retyped as image_url, changing message semantics and potentially causing provider errors. Could remote-image conversion be explicit (or at least validate that the URL is actually intended as image content) rather than keying only on the scheme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the performance of multimodal large models. Input parameters pass URL links to large models. Require structure to run code will report an error

3 participants