microsoft / microsoft/simplechat

Bug: define and test multi-agent @ mention behavior

Open
#936 1 comment 0 reactions 1 assignee Claimed by @paullizer View on GitHub
bug
Dominant language
Python
Stars
152
Forks
116
Avg merge
7h 7m
Merged PRs (30d)
122

Description

## Summary

We need explicit regression coverage and a product decision for messages that contain multiple AI `@` targets, especially multi-agent prompts like `@researcher` alongside `@msgraphagent`.

The current collaborative explicit invocation code appears to resolve only one AI target from a message. If multi-agent invocation is intended, the implementation likely needs to change. If it is not intended, the UI should prevent or clearly reject multiple AI targets instead of silently choosing one.

## Why this matters

A user can type something like:

```text
@researcher @msgraphagent summarize the latest account context and draft next actions
```

Without explicit handling, the UI may make it look like both agents were requested while only one target is actually routed.

## Code context

Likely frontend control path:

- `application/single_app/static/js/chat/chat-messages.js`
- `resolveCollaborativeExplicitInvocationTarget(messageText)` builds the full target list, sorts it, and returns the first matching target.
- `buildCollaborativeSendContext()` accepts a single `explicitInvocationTarget`.
- For an agent target, it sets a single `messageData.agent_info` object.
- For a model target, it updates the single model selection fields.
- `stripExplicitCollaborativeTargetText()` strips only the resolved invocation target from the displayed message text.
- `buildCollaborativeInvocationTarget()` returns one invocation chip/target.
- `application/single_app/static/js/chat/chat-collaboration.js`
- `insertInvocationTargetMention()` and send metadata currently appear to model one AI invocation target.
- `application/single_app/route_backend_chats.py`
- The request processing reads one `agent_info`/agent selection from the request and forces agent enablement for that single explicit agent.

This means multi-`@` AI target input probably becomes single-target execution, with the second `@agent` left as plain text or ignored for routing.

## Expected behavior to decide

Option A: Support multiple AI targets.

- Multiple agent tags in one message should intentionally invoke each mentioned agent or route through the multi-agent orchestration flow.
- The UI should render all selected invocation targets clearly.
- Metadata should preserve all requested targets, not just the first resolved match.

Option B: Do not support multiple AI targets yet.

- The mention UI or send path should prevent more than one AI invocation target in a message.
- The user should get a clear warning when multiple AI targets are present.
- The app should avoid rendering a request as if multiple agents will participate when only one can respond.

## Acceptance criteria

- Add a regression test for a collaborative message containing both `@researcher` and `@msgraphagent`.
- The test should verify the chosen behavior explicitly: either both targets are invoked/persisted, or the second target is blocked with a clear user-facing warning.
- Include order coverage so `@researcher @msgraphagent ...` and `@msgraphagent @researcher ...` do not accidentally pass by matching only the longest or first display name.
- If multiple AI targets are unsupported, verify model + agent combinations are also rejected or handled deterministically.

## Regression test ideas

- Frontend unit/functional test around target resolution in `chat-messages.js` using seeded `window.chatAgentOptions` for `researcher` and `msgraphagent`.
- Collaboration send-path test that asserts metadata does not silently collapse multiple AI tags without user feedback.
- Backend request test if multi-agent orchestration is selected as the intended behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.