agentscope-ai / agentscope-ai/QwenPaw

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

Offen
#7,710 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
35k
Forks
3.1k
Ø Merge
1 T. 13 Std.
Gemergte PRs (30 T.)
228

Beschreibung

## 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).

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

The first file to inspect is `app/chats/models.py` to follow how `SessionSource`, `SOURCE_CHAT_GROUP_IDS`, and `default_chat_groups()` define built-ins. Then read `agents/tools/agent_management.py::build_agent_chat_request` and `agents/memory/proactive/proactive_responder.py::send_proactive_message_via_http` to confirm where the new context markers should be set. Update `app/routers/console.py::_chat_registration_fields` to map those markers to the new source values. Done means new `chat_with_agent`, `submit_to_agent`, and proactive sessions appear in new console groups instead of Uncategorized, verified via related chat/group tests or manual Console checks.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
74/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.