agentscope-ai / agentscope-ai/agentscope
[Bug]: Model card's context_size is ignored by the app service chat model factory
- Dominant language
- Python
- Stars
- 31.5k
- Forks
- 3.5k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 95
Description
### Prerequisites
- [x] I have searched the existing [issues](https://github.com/agentscope-ai/agentscope/issues) and [discussions](https://github.com/agentscope-ai/agentscope/discussions), and this is not a duplicate.
- [x] This is a bug, not a usage question. (For questions, please use [Discussions](https://github.com/agentscope-ai/agentscope/discussions/new?category=general) instead.)
### Background / Description
`get_model()` in `agentscope/app/_service/_model.py` builds the chat model with only `credential`, `model` and `parameters`. The matching model card's `context_size` is never forwarded to the constructor, so every chat model silently falls back to its per-provider class default.
Model cards declare much larger windows than those defaults. For example, the DeepSeek card (`deepseek-v4-flash`) declares `context_size: 1000000`, while `DeepSeekChatModel.__init__` defaults to `65536` — about 6.5% of the real window.
This is not cosmetic. `Agent` derives every context-compression threshold from `self.model.context_size` (`agent/_agent.py`, e.g. `trigger_ratio * self.model.context_size`), so an under-reported value makes compression fire far too early. The same applies to the fallback chat model, which goes through the same factory.
Evidence that this is an oversight rather than intended: the sibling embedding path in the same package does forward it. `app/_service/_embedding.py` looks up the matching card and passes `card.context_size` into the constructor. The chat path looks up the very same card but only uses it to override `formatter.input_types`. In addition, `CONTRIBUTING.md` §Chat Model lists `context_size` as a required model card field, so the declared value is meant to be authoritative.
This affects every provider whose card value differs from the class default, not just DeepSeek — e.g. DashScope (131072 vs 10000000 for `qwen-long`) and Anthropic (200000 vs 1000000 for the Claude 5 / 4.6+ cards).
The card's `output_size` is likewise never read on the chat path.
### Error Messages
```shell
No exception is raised — the defect is silent and only manifests as premature context compression.
Observed by running the reproduction below against agentscope 2.0.8:
card declares: 1000000
constructed model has: 65536
```
### Steps to Reproduce
import inspect
from agentscope.model._deepseek import DeepSeekChatModel
# What the model card declares
for card in DeepSeekChatModel.list_models():
print(card.name, card.context_size)
# deepseek-v4-flash 1000000
# What the constructor falls back to
print(
inspect.signature(DeepSeekChatModel.__init__)
.parameters["context_size"].default
)
# 65536
# get_model() never passes it:
# model = model_cls(
# credential=credential,
# model=config.model,
# parameters=parameters,
# )
# -> `context_size` does not appear anywhere in get_model()'s source.
### Environment
- AgentScope Version: 2.0.8
- Python Version: 3.14.5
- OS: Windows 11 Pro
Contributor guide
Assessment
This issue has not been assessed yet.