42 lines
1.5 KiB
Markdown
42 lines
1.5 KiB
Markdown
---
|
||
title: "Context Reset"
|
||
type: concept
|
||
tags:
|
||
- "agentic-ai"
|
||
- "context-window"
|
||
- "recovery"
|
||
sources:
|
||
- "Your-AI-Isn-t-Stupid---It-Just-Needs-a-Better-Harness--Lychee-Technology-Engineering-Blog"
|
||
last_updated: 2026-04-20
|
||
---
|
||
|
||
## Overview
|
||
Context Reset——当 [[Context-Anxiety]] 触发时,Harness 将当前 Agent 状态保存至磁盘、终止实例、启动全新 Agent 的程序化操作,用于解决长周期任务超出单次 context window 的问题。
|
||
|
||
## Trigger Condition
|
||
```python
|
||
if (tokens_used / max_context) > 0.7: # 阈值需按模型调优
|
||
trigger_context_reset()
|
||
```
|
||
|
||
## Procedure
|
||
1. **Save state**: 完整项目状态写入持久存储(磁盘文件)
|
||
2. **Terminate**: 终止当前 LLM 实例
|
||
3. **Launch fresh**: 启动全新 Agent,加载保存状态
|
||
4. **Orient**: 新 Agent 读取状态、定位自身、继续工作
|
||
|
||
## Why Not In-Place Summarization?
|
||
原地摘要(summarize → keep in same context)仍让模型在嘈杂、退化的上下文中操作。Context Reset 提供完全干净的上下文窗口——代价更高,但可靠性显著提升,适用于超长周期任务。
|
||
|
||
## Trade-off
|
||
- **In-place summarization**: 便宜,但 context 仍嘈杂
|
||
- **Context Reset**: 昂贵(需重新加载状态),但可靠性高
|
||
|
||
## Source
|
||
- [[Your-AI-Isn-t-Stupid---It-Just-Needs-a-Better-Harness--Lychee-Technology-Engineering-Blog]]
|
||
|
||
## See Also
|
||
- [[Context-Anxiety]] — 触发条件
|
||
- [[State-Externalization]] — 持久化状态文件格式
|
||
- [[7-Layer-Harness-Stack]] — 第 7 层 Constraints & Recovery 的核心机制
|