feat(cloud-agent): 上下文计量 - 每步发出 context_pressure 读数并用上游实测定锚 (#601)

This commit is contained in:
AetherNo2332 authored and ddcat666 committed 2026-09-24 13:35:15 +08:00
1 parent 7ca625730e
commit abf593c6c9
12 files changed
+1366 -15

No files matched your search

@@ -15,9 +15,9 @@ func TestStuckCloudAgentIsTerminated(t *testing.T) {
}
run, state := agentMediaRun(t, s, a, "request_approval", "stuck-idle")
state.ActiveTaskID, state.MediaTaskID, state.StoryboardTaskID = "", "", ""
if len(state.Events) == 0 {
state.event(run.ID, "assistant_message", map[string]any{"text": "起个头"})
}
// 事件日志是 append-only(已落库的行不能再改写),所以这里用"追加一条时间戳在十分钟前的
// 新事件"表达"最后进展在十分钟前",而不是回头改上一条已落库的事件。
state.event(run.ID, "assistant_message", map[string]any{"text": "起个头"})
state.Events[len(state.Events)-1].CreatedAt = time.Now().Add(-10 * time.Minute)
if err := s.repo.MutateCloudAgent("user", run.ID, run.Revision, func(current *model.CloudAgentExecution, _ *repository.Repository) error {
return cloudAgentSave(current, &state)
@@ -77,9 +77,8 @@ func TestStuckDetectionSkipsRunsWithLiveWork(t *testing.T) {
}
state.ActiveTaskID = live.ID
state.TaskIDs = append(state.TaskIDs, live.ID)
if len(state.Events) == 0 {
state.event(run.ID, "assistant_message", map[string]any{"text": "起个头"})
}
// 同上:只能追加新事件,不能改写已有事件的时间戳。
state.event(run.ID, "assistant_message", map[string]any{"text": "起个头"})
state.Events[len(state.Events)-1].CreatedAt = time.Now().Add(-10 * time.Minute)
if err := s.repo.MutateCloudAgent("user", run.ID, run.Revision, func(current *model.CloudAgentExecution, _ *repository.Repository) error {
return cloudAgentSave(current, &state)
@@ -105,9 +104,8 @@ func TestStuckDetectionTreatsTerminalTaskAsIdle(t *testing.T) {
}
state.ActiveTaskID, state.MediaTaskID = "", ""
state.StoryboardTaskID = dead.ID
if len(state.Events) == 0 {
state.event(run.ID, "assistant_message", map[string]any{"text": "起个头"})
}
// 同上:只能追加新事件,不能改写已有事件的时间戳。
state.event(run.ID, "assistant_message", map[string]any{"text": "起个头"})
state.Events[len(state.Events)-1].CreatedAt = time.Now().Add(-10 * time.Minute)
if err := s.repo.MutateCloudAgent("user", run.ID, run.Revision, func(current *model.CloudAgentExecution, _ *repository.Repository) error {
return cloudAgentSave(current, &state)