Skip to content

[Platform] Rework AssistantMessage#1853

Draft
valtzu wants to merge 1 commit intosymfony:mainfrom
valtzu:rework-assistant-message
Draft

[Platform] Rework AssistantMessage#1853
valtzu wants to merge 1 commit intosymfony:mainfrom
valtzu:rework-assistant-message

Conversation

@valtzu
Copy link
Copy Markdown
Contributor

@valtzu valtzu commented Apr 1, 2026

Q A
Bug fix? no
New feature? no
Docs? todo
License MIT

Rework AssistantMessage to better model the APIs and

  1. Allow any platform-specific content that needs to be sent back to the server on next call
  2. Retain original order of blocks/parts
  3. Allow attaching metadata to blocks/parts instead of just the message.
  • e.g. with Gemini, several parts in the assistant message can have thoughtSignatures

Looking for feedback before proceeding further as this change is quite enormous at this late stage

Before

new AssistantMessage(
  content: 'Hello',
  toolCalls: [
    new ToolCall('id1', 'function1', ['param1' => 'value1']),
    new ToolCall('id2', 'function2', ['param2' => 'value2']),
  ],
  thinkingContent: 'foo',
  thinkingSignature: 'bar',
),

After

new AssistantMessage(
  new MultiPartResult(
    new ThinkingResult('foo', 'bar'),
    new TextResult('Hello'),
    new ToolCallResult([new ToolCall('id1', 'function1', ['param1' => 'value1'])]),
    new ToolCallResult([new ToolCall('id2', 'function2', ['param2' => 'value2'])]),
  ),
),

@chr-hertel
Copy link
Copy Markdown
Member

Thanks @valtzu, I like that proposal - and I'd skip the Collection - is more consistent with UserMessage.

cc @OskarStark @fabpot WDYT?

@OskarStark
Copy link
Copy Markdown
Contributor

Sounds like a good and flexible approach

@chr-hertel chr-hertel added Platform Issues & PRs about the AI Platform component Status: Needs Work labels Apr 5, 2026
@fabpot
Copy link
Copy Markdown
Member

fabpot commented Apr 6, 2026

I like it a lot!

@OskarStark
Copy link
Copy Markdown
Contributor

@valtzu can you finish this one?

@valtzu
Copy link
Copy Markdown
Contributor Author

valtzu commented Apr 7, 2026

@OskarStark Sorry I was afk the whole Easter; I'll try

Thanks all for comments

@valtzu
Copy link
Copy Markdown
Contributor Author

valtzu commented Apr 8, 2026

Ok I think I may have taken a too big bite here. I'm struggling quite much on how to glue results & contents.

It could be easier to start from the lower layer (in a separate PR) and add some MultiPartResult/CollectionResult first to tackle #1053 – and only then think of how to map that to AssistantMessage

@valtzu
Copy link
Copy Markdown
Contributor Author

valtzu commented Apr 12, 2026

I'm struggling quite much on how to glue results & contents.

After #1900 this could be adjusted to use ResultInterface instead of ContentInterface which would solve the issue.

@valtzu valtzu force-pushed the rework-assistant-message branch from ffa33ae to a90024f Compare April 18, 2026 21:50
@valtzu valtzu changed the title [Platform] Rework AssistantMessage & ContentInterface [Platform] Rework AssistantMessage Apr 18, 2026
@valtzu
Copy link
Copy Markdown
Contributor Author

valtzu commented Apr 18, 2026

After #1900 this could be adjusted to use ResultInterface instead of ContentInterface which would solve the issue.

I tried this (pushed here) – it mostly works, but one of the issues is that as result objects contain raw results (AsyncResponse) they cannot be serialized.

Still somehow using ContentInterface felt more fitting (though much bigger change and something I cannot finish myself)

@chr-hertel
Copy link
Copy Markdown
Member

yeah, having second thoughts as well. i agree that ContentInterface would be cleaner and maybe try to keep Message classes and Result classes decoupled

new AssistantMessage(
    new Thinking('foo', 'bar'),
    new Text('Hello'),
    new ToolCall('id1', 'function1', ['param1' => 'value1']),
    new new ToolCall('id2', 'function2', ['param2' => 'value2']),
),

@xprojects-de
Copy link
Copy Markdown
Contributor

i think that´s great and i like it!

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

Labels

Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants