fix(agent): address session and streaming concurrency bugs

This commit is contained in:
hamb1y authored and Xubin Ren committed 2026-05-28 22:54:46 +08:00
1 parent 1a4ae8994d
commit 0df60416ba
10 files changed
+250 -39

No files matched your search

+7 -1
View File
@@ -1273,7 +1273,13 @@ class AgentRunner:
return messages
system_tokens = sum(estimate_message_tokens(msg) for msg in system_messages)
remaining_budget = max(128, budget - system_tokens)
fixed_tokens, _ = estimate_prompt_tokens_chain(
self.provider,
spec.model,
system_messages,
spec.tools.get_definitions(),
)
remaining_budget = max(0, budget - max(system_tokens, fixed_tokens))
kept: list[dict[str, Any]] = []
kept_tokens = 0
for message in reversed(non_system):