AutoGen's hidden token tax: why a 3-agent chat costs 15× what you expect
Cost-audit series, episode 2. This series began with
UnboundedChatCompletionContext.get_messages() returns self._messages — the full list, no cap, no truncation:
# autogen-core/.../model_context/_unbounded_chat_completion_context.py (a ~20-line file)
async def get_messages(self) -> List[LLMMessage]:
"""Get at most `buffer_size` recent messages."""
return self._messages
The group manager (BaseGroupChatManager) maintains a single _message_thread and appends every response to it:
# _base_group_chat_manager.py
self._message_thread: List[BaseAgentEvent | BaseChatMessage] = []
...
await self.update_message_thread(delta) # called after every agent response
does: it instruments LLM calls, tracks per-run cumulative cost, and can block a CI build when a PR's token delta exceeds a threshold.
The ·
SOCIAL SHARE CARD GENERATOR