fix: sanitize assembled diagnostic context · openclaw/openclaw@0bf4876
steipete
·
2026-04-26
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -97,6 +97,45 @@ describe("diagnostic stability recorder", () => {
|
97 | 97 | expect(snapshot.events[1]).not.toHaveProperty("reason"); |
98 | 98 | }); |
99 | 99 | |
| 100 | +it("summarizes assembled context diagnostics without prompt text", async () => { |
| 101 | +startDiagnosticStabilityRecorder(); |
| 102 | + |
| 103 | +emitDiagnosticEvent({ |
| 104 | +type: "context.assembled", |
| 105 | +runId: "run-secret", |
| 106 | +sessionId: "session-secret", |
| 107 | +provider: "openai", |
| 108 | +model: "gpt-5.4", |
| 109 | +channel: "telegram", |
| 110 | +trigger: "user-message", |
| 111 | +messageCount: 4, |
| 112 | +historyTextChars: 1200, |
| 113 | +historyImageBlocks: 1, |
| 114 | +maxMessageTextChars: 800, |
| 115 | +systemPromptChars: 300, |
| 116 | +promptChars: 100, |
| 117 | +promptImages: 1, |
| 118 | +contextTokenBudget: 200_000, |
| 119 | +reserveTokens: 20_000, |
| 120 | +}); |
| 121 | +await new Promise<void>((resolve) => setImmediate(resolve)); |
| 122 | + |
| 123 | +const snapshot = getDiagnosticStabilitySnapshot({ limit: 10 }); |
| 124 | + |
| 125 | +expect(snapshot.events[0]).toMatchObject({ |
| 126 | +type: "context.assembled", |
| 127 | +provider: "openai", |
| 128 | +model: "gpt-5.4", |
| 129 | +channel: "telegram", |
| 130 | +count: 4, |
| 131 | +context: { limit: 200_000 }, |
| 132 | +}); |
| 133 | +expect(snapshot.events[0]).not.toHaveProperty("runId"); |
| 134 | +expect(snapshot.events[0]).not.toHaveProperty("sessionId"); |
| 135 | +expect(snapshot.events[0]).not.toHaveProperty("promptChars"); |
| 136 | +expect(snapshot.events[0]).not.toHaveProperty("systemPromptChars"); |
| 137 | +}); |
| 138 | + |
100 | 139 | it("sanitizes tool and model diagnostic error categories", async () => { |
101 | 140 | startDiagnosticStabilityRecorder(); |
102 | 141 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。