Skip to content

Conversation

@bojan2501
Copy link
Contributor

Addresses 3558
Refactored code for better readability.
Bumped version of ag-ui libs.

@DouweM
Copy link
Collaborator

DouweM commented Dec 12, 2025

@bojan2501 Can you have a look at the missing test coverage please?

@bojan2501
Copy link
Contributor Author

I think this is it.
Let me know if I break something.
Also if something needs to be fixed. Will try to find some time to work on it.

@bojan2501
Copy link
Contributor Author

@DouweM To be honest I do not understand why the checks are failing now.

return builder.messages

@classmethod
def load_binary_part(cls, part: BinaryInputContent) -> BinaryContent | ImageUrl | VideoUrl | AudioUrl | DocumentUrl:
Copy link
Collaborator

Choose a reason for hiding this comment

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

These methods really shouldn't be part of the public interface, so please make them private, either has class methods, or if that doesn't work, as private functions in the module, outside of the class

)
events = await run_and_collect_events(agent, run_input)

assert events == simple_result()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's drop all of the tests above because they're not verifying that the binary content actually made it through. I'd rather expand the test_messages test

assert not loaded_messages


def test_load_binary_part() -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather test this at the load_messages level so we can verify these end up in the correct Pydantic AI message history, not just individual parts

AGUIAdapter.load_binary_part(BinaryInputContent(id='some_id', mime_type='text/plain'))


def test_add_assistant_tool_parts() -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't need to test these helper methods directly, as all of these features have already been tested through the existing tests, except for the new binary content. So I'd expect for the only new tests to be related to those binary parts.

If these tests were necessary because of the refactoring of the original massive method into separate ones, I'd prefer to revert that and have a massive method again, which was 100% test-covered.

@bojan2501
Copy link
Contributor Author

bojan2501 commented Dec 17, 2025

@DouweM
You were right, i made this too complex.

  1. So I reverted all changes.
  2. Bumped ag-ui lib to latest version.
  3. Updated existing method load_messages to handle new type of messages.
  4. Updated test_messages test with new content.
  5. Added # noqa: C901 as the method load_messages is complex.

bab3876#diff-84321598744d84dbee2318e634c74c9aae39a1c253f1c4bd17ebf9ef2f807b11

I see now that something went wrong, and there is a conflict.
Funny thing is that I used two different editors and two agents to test development.
In the end had to revert and do all by hand.

Should I cancel this pull request and create fresh one? Could be much more easy for review.

…sages. Updated existing tests to test new content. Bumped ag-ui version.
@DouweM DouweM force-pushed the feature/3558-Add-Support-For-Multi-Modal-Messages-AG-UI branch from bab3876 to 6c206fc Compare December 17, 2025 16:30
@DouweM
Copy link
Collaborator

DouweM commented Dec 17, 2025

@bojan2501 I've fixed this branch PR as follows:

git co feature/3558-Add-Support-For-Multi-Modal-Messages-AG-UI # your branch git fetch origin # my origin remote points at the canonical repo git reset --hard origin/main # reset to match main branch, removing all history on the branch git cherry-pick bab3876a9315ae058e6d3b9e197425afdec38e1c # apply just the commit with the intended changes git push -f # force push to overwrite branch history

Let's see what CI says!

@DouweM DouweM merged commit 9357c7f into pydantic:main Dec 17, 2025
30 checks passed
@tseaver
Copy link
Contributor

tseaver commented Dec 21, 2025

@bojan2501 What was the rationale for adding an exception to ActivityMessages passed by the client as part of the message history?

There is nothing in the AG-UI spec which requires such: you've now required clients to do this filtering, which might or might not be desirable. For instance, agents implemented as graphs with human-in-the-loop or client-side tool calling might use the ActivityMessage content to reconstruct their place in the graph's flow in a new run.

@bojan2501
Copy link
Contributor Author

Hi @tseaver,
Apologizing for the issue.

My intention was to add support for Multi Modal messages.
And while I was checking the implementation I did not find how to handle ActivityMessages.
Also checks/hooks were complaining that not all cases were covered...
So I added exception as this type of Message is not yet supported.

I could review this again.

@tseaver
Copy link
Contributor

tseaver commented Dec 21, 2025

@bojan2501 Thanks for the reply.

If the translation to pyadantic_ai.ModelMessage isn't clear, then ISTM cleaner just to ignore it: the message is (likely) the result of events emitted from the agent involved (including message IDs passed as part of those events), if not the LLM.

@DouweM
Copy link
Collaborator

DouweM commented Dec 22, 2025

@tseaver Feel free to submit a new PR to remove the error!

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