Skip to content

Conversation

OskarStark
Copy link
Contributor

@OskarStark OskarStark commented Sep 11, 2025

Q A
Bug fix? no
New feature? yes
Docs? tbd
Issues Refs #19
License MIT

This is a first draft, lacking tests and feedback and everything 😄 I didn't even tried the example yet, but this is how it could look like. Ofc technical agent in this example could also be a MultiAgent and so on...

While the example and the HandoffRule class looks ok, I am not happy with the MultiAgent class.

CleanShot 2025-09-30 at 09 12 44@2x

@carsonbot carsonbot added Agent Issues & PRs about the AI Agent component Feature New feature Status: Needs Review labels Sep 11, 2025
@OskarStark OskarStark self-assigned this Sep 11, 2025
@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch 4 times, most recently from 170c10b to 4952511 Compare September 17, 2025 13:11
@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch from e6ec748 to c6014d8 Compare September 24, 2025 11:13
@OskarStark OskarStark changed the title [Agent] Add multi agent [Agent] Add MultiAgent Sep 26, 2025
@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch 3 times, most recently from 8f8a195 to 9b52de4 Compare September 26, 2025 19:17
@OskarStark
Copy link
Contributor Author

OskarStark commented Sep 26, 2025

@chr-hertel WDYT about:

$multiAgent = new MultiAgent(
    orchestrator: $orchestrator,
    handoffs: [
        new Handoff(to: $technical, when: ['bug', 'problem', 'technical', 'error']),
    ],
    fallback/default: $general
    logger: logger(),
);

This way we can always fallback in any case, and when/triggers can be required.

also not the to: and when: wording in the Handoff

@chr-hertel
Copy link
Member

@chr-hertel WDYT about:

$multiAgent = new MultiAgent(
    orchestrator: $orchestrator,
    handoffs: [
        new Handoff(to: $technical, when: ['bug', 'problem', 'technical', 'error']),
    ],
    fallback/default: $general
    logger: logger(),
);

This way we can always fallback in any case, and when/triggers can be required.

also not the to: and when: wording in the Handoff

giphy

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

this really looks promising, some thoughts tho:

  • why using that json part in system prompt instead of structured output?
  • we should slice down the multi agent class
  • also great use case for prompt templates
  • docs should explain the difference between using an agent as tool and this approach

@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch from 434301b to 1daadce Compare September 28, 2025 10:53
return $targetAgent->call($originalMessages, $options);
}

private function buildAgentSelectionPrompt(string $userQuestion): string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in a follow up we could make this configurable for the multiagent

@OskarStark OskarStark added the AI Bundle Issues & PRs about the AI integration bundle label Sep 28, 2025
@carsonbot carsonbot changed the title [Agent] Add MultiAgent [AI Bundle][Agent] Add MultiAgent Sep 28, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chr-hertel are you fine adding these methods here?

return null;
}

public function getUserMessageText(): ?string
Copy link
Contributor Author

Choose a reason for hiding this comment

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

or shall we add a asText or toString to UserMessage?

Copy link
Member

Choose a reason for hiding this comment

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

Does that work with the different kind of contents like Image or audio?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it should ignore Image and Audio as those are not texts

@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch 4 times, most recently from 73055cd to 511f31f Compare September 29, 2025 17:50
@chr-hertel
Copy link
Member

Alright, this is great, no doubt about it - i like that with handoffs we can share the context between agents - different to agents as tools where we basically isolate them.

but one thing that still made me wonder - why do we differentiate between multi-agent and agent - a bit confusing even when we think of an agent that has other agents as tools, but is not called multi agent.

this is why i ended up with one idea, why not combine?

agents:
    orchestrator:
        model: 'gpt-4o-mini'
        prompt: '...'
        tools: [...]
        handoffs: [...]

don't know how tho. just thinking it would be cool :D

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

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

good to merge with green pipeline

@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch 3 times, most recently from 521b687 to 2017b73 Compare September 30, 2025 09:34
@OskarStark
Copy link
Contributor Author

Its green, but lets keep it open for know, I will try to get into your idea @chr-hertel

@OskarStark OskarStark force-pushed the feature/orchestrated-multi-agent branch from f250d33 to 6e217e3 Compare October 1, 2025 11:04
@OskarStark OskarStark merged commit 637012d into symfony:main Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent Issues & PRs about the AI Agent component AI Bundle Issues & PRs about the AI integration bundle Feature New feature Status: Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants