agentscope-ai / agentscope-ai/QwenPaw

[Feature]: Add history groups for inter-agent tool chats and proactive messages

Abierto
#7,710 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
34.9k
Forks
3.1k
Merge medio
1 d 15 h
PR fusionados (30 d)
225

Descripción

## Summary

Add dedicated Console history groups for sessions created by the inter-agent tools (`chat_with_agent`, `submit_to_agent`) and by Proactive messages, so these automated conversations no longer mix into "Uncategorized" and are easy to find.

## Component(s) Affected

- [x] Core / Backend (app, agents, config, providers, utils, local_models)
- [x] Console (frontend web UI)
- [ ] Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
- [ ] Skills
- [ ] CLI
- [ ] Documentation (website)
- [x] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy

## Problem / Motivation

Console history groups chats by `SessionSource` (chat / cron / subagent) into three built-in groups: "Uncategorized", "Scheduled tasks", "Subagents". Only `spawn_subagent` marks its sessions today (`request_context["_spawn_subagent"]=True`, handled by `app/routers/console.py::_chat_registration_fields`).

Sessions from these sources currently all land in "Uncategorized" on the target agent:

- `chat_with_agent` / `submit_to_agent` — inter-agent tool calls; `agents/tools/agent_management.py::build_agent_chat_request` sends no source marker, so the target agent registers the session with the default `source=chat`.
- Proactive messages — `agents/memory/proactive/proactive_responder.py::send_proactive_message_via_http` uses a fixed `proactive_mode:` session id and POSTs `/console/chat` without any source marker.

Note that `app/chats/title_generator.py` already special-cases proactive messages (the `[Agent proactive_helper requesting]` prefix gets a fixed "[Proactive信息]" title), so these sessions are recognized but never grouped.

`check_agent_task` creates no session and needs no group.

## Proposed Solution

Follow the existing `_spawn_subagent` pattern:

1. `app/chats/models.py`: append new `SessionSource` values (at the END so `_source_order` keeps fixed groups ordered), and extend `SOURCE_CHAT_GROUP_IDS` + `default_chat_groups()` with new built-in groups:
- `chat_with_agent` sessions → "Agent chats"
- `submit_to_agent` sessions → "Agent tasks"
- Proactive sessions → "Proactive messages"
2. Inter-agent tools: add `request_context["inter_agent_tool"]` in `agents/tools/agent_management.py::build_agent_chat_request` (e.g. `"chat_with_agent"` / `"submit_to_agent"`).
3. Proactive: add `request_context["_proactive"]=True` in `send_proactive_message_via_http` (or detect the `proactive_mode:` session prefix at registration).
4. `app/routers/console.py::_chat_registration_fields` maps the markers to the new `source` values.
5. `ChatsFile.ensure_system_groups` already backfills missing built-in groups, so existing chat registries need no migration (existing chats keep their current group; only new sessions are grouped).

## Alternatives Considered

- One combined "Inter-agent" group instead of separate groups per tool — works, but loses the foreground/background distinction between `chat_with_agent` and `submit_to_agent`.
- Manual custom groups: users can already create custom groups, but there is no way to auto-assign sessions by source, so new sessions keep reappearing in "Uncategorized".

## Additional Context

Current grouping model: `SessionSource` (chat/cron/subagent) → `SOURCE_CHAT_GROUP_IDS` in `app/chats/models.py`; built-in groups defined in `default_chat_groups()`.

## Willing to Contribute

- [x] I am willing to open a PR for this feature (after discussion).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.