ZipAgent passes theContextobjects to provide a complete dialog state management solution:
Basic usage::
1. Creating contextual instances and running through multiple rounds of dialogues
2. The framework automatically maintains a complete history of interactions
3. Real-time access to dialog statistics
ctx = Context() # 初始化上下文 Runner.run(agent, "我叫张小明", context=ctx) # 首轮对话 result = Runner.run(agent, "我是谁?", context=ctx) # 次轮对话 print(result.content) # 输出"你叫张小明"
Advanced Management Features::
turn_countattribute records the current dialog roundusageAttribute statistics cumulative token consumption- Support for manual modification of specific dialog records in contexts
caveat::
To balance effectiveness and cost, it is recommended to combinemax_turnsparameter controls the maximum conversation depth and is captured by exception handlingMaxTurnsError. In scenarios where long-term memory is required, the Context class can be extended to implement persistent storage.
This answer comes from the articleZipAgent: a lightweight Python framework for building exclusive AI assistants in 5 minutesThe































