feat: 贯通 context_window 配置并按 token 预算裁剪对话历史

This commit is contained in:
2026-09-20 14:22:53 +08:00
parent 8251a57010
commit 4114b0b4fb
21 changed files with 307 additions and 42 deletions
+2
View File
@@ -104,6 +104,8 @@ class LlmRuntimeConfig:
api_key: str
model: str
extra_headers: dict[str, str] = field(default_factory=dict)
# 租户配置的上下文窗口;None 表示由 Agent 按模型名估计
context_window: int | None = None
@dataclass(frozen=True)
+2 -2
View File
@@ -89,7 +89,7 @@ class ChatStreamer(ABC):
llm: LlmRuntimeConfig,
history: list[ChatMessage],
user_text: str,
system_prompt: str,
tools: list[Any] | None = None,
memory_count: int = 0,
memory_just_saved: str | None = None,
max_tool_result_chars: int = 8000,
) -> AsyncIterator[StreamEvent]: ...