agentscope-ai / agentscope-ai/agentscope

feat(realtime): support context management for the realtime agent

オープン
#2,566 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
Help Wanted
主要言語
Python
スター
31.5k
フォーク
3.5k
平均マージ
1日 23時間
マージ済み PR(30日)
95

説明

**Background**
Context management for `RealtimeAgent` differs fundamentally from the standard `Agent` class:

- Runtime context is maintained on the API side, not locally
- On session recovery, context must be re-injected — either merged into the system prompt/instructions, or replayed as text messages to the model. This implies a summarization step: a compressed summary of prior context should be prepended to the system prompt when resuming a session
- Compressed context segments should be offloaded to a local workspace, consistent with how `Agent` handles this
- Truncation strategy for tool results should align with the existing `Agent` behavior

> Two open questions to resolve before implementation:
> - **Token counting**: Realtime APIs may not expose token usage in the same way as standard chat APIs — the counting mechanism needs to be clarified first, as it gates the truncation/compression trigger
> - **Compression timing**: Unlike `Agent`, compression in `RealtimeAgent` can potentially run concurrently with the ongoing conversation — the concurrency model needs to be decided

**Changes**
- Add a `ContextConfig` class for `RealtimeAgent`, mirroring `Agent`'s `context_config`, with the following fields:
- `context_length`: maximum allowed context size
- `tool_result_limit`: cap on individual tool result size
- `compression_prompt`: a `ChatModelBase` instance used for compression
- `compression_prompt`: prompt template for compression
- `compression_schema`: structured output `BaseModel` for compression result
- `compression_summary`: the summary template
- Add a `workspace` parameter to `RealtimeAgent` for offloading truncated and compressed tool results

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。