agentscope-ai / agentscope-ai/QwenPaw
[Feature] add /btw side-question command (like Claude Code)
- 主要言語
- Python
- スター
- 34.9k
- フォーク
- 3.1k
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 225
説明
## Summary
Add a `/btw [question]` conversation command that lets users ask a quick **side question** without writing it into the main conversation history or consuming the scroll/context window. This mirrors the well-received `/btw` command in Claude Code (introduced in v2.1.72).
## Component(s) Affected
- [x] Core / Backend (app, agents, config, providers, utils, local_models)
- [ ] Console (frontend web UI)
- [ ] Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
- [ ] Skills
- [ ] CLI
- [ ] Documentation (website)
- [ ] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy
## Problem / Motivation
In long agent sessions, users frequently need a small clarification mid-task — e.g. "what's the expected JSON shape for this tool?", "what does this config key mean?", "what timezone is this timestamp?" — but do **not** want that Q&A to:
1. Consume precious context window (every extra turn pushes the auto-compact threshold closer, and compaction always carries some information loss risk).
2. Interrupt or pollute the main task's conversation flow that the agent is reasoning over.
Today in QwenPaw the only options are: ask directly (pollutes history), or start a brand-new session (loses main-task context). A first-class "side channel" question command solves both. Claude Code's `/btw` has been positively received precisely because it decouples "getting an answer" from "growing the conversation".
**Who benefits:** any user running long, context-sensitive sessions (heavy tool users, multi-step debugging, batch editing) — i.e. the core QwenPaw audience.
## Proposed Solution
Add a new conversation command `/btw [question]` to `agents/command_handler.py` (extending the existing `SYSTEM_COMMANDS` set alongside `/compact`, `/clear`, `/new`):
1. **Routing** — when `/btw ` is received, the agent answers the question in a **hermetic side session**:
- Build a compact *read-only snapshot* of the current state: system prompt + recent N messages (or the active task summary), enough to answer context-dependent questions.
- The side answer is **not** appended to `messages` / scroll history — it is delivered to the user (channel output) only, like Claude Code's behavior.
2. **Isolation guarantees** — the side session must not trigger auto-memory writes, digest/memory-concentration, or `discard_auto_memory_turns`-style bookkeeping. It is ephemeral and discarded after the reply.
3. **No-arg behavior** — bare `/btw` shows the most recent side question + answer (useful for reviewing), or a short usage line if none asked yet.
4. **Concurrency** — while the main loop is paused for a `/btw` answer, the user's next real message resumes the normal main history (compact glue code already exists for queued commands).
This is mostly a backend change; channels/console need only treat the command like other conversation commands, so no per-channel UI work is required.
## Alternatives Considered
- **Ask directly in the main session (current behavior)** — simplest, but grows the context and can trigger premature auto-compaction; the extra turns also become noise when the agent later re-reads history.
- **Start a new session (`/new`, `/start`)** — isolates context but loses access to the ongoing task; users must manually switch back and the two sessions share no state.
- **`/compact` with keep-instructions** — frees space but is destructive (summarization loss) and heavyweight for a one-line question.
- **Answer via a different agent / channel** — no existing mechanism addresses the main-session context pollution; overkill for a short question.
None of these provide the "ask and forget, keep context pristine" semantics of `/btw`.
## Additional Context
- Reference implementation: Claude Code's `/btw` command — https://code.claude.com/docs/en/commands ("/btw [question] — Ask a side question about the current session without adding to the conversation").
- Relevant QwenPaw source: `SYSTEM_COMMANDS` set and `ConversationCommandHandlerMixin` in `agents/command_handler.py`; command routing in `app/channels/command_registry.py`.
- The existing `/compact` machinery (manual force ratio, history snapshot) can be reused for building the side-context snapshot.
## Willing to Contribute
- [ ] I am willing to open a PR for this feature (after discussion).
コントリビューションガイド
評価
この issue はまだ評価されていません。