feat(FN-3302): restore Claude usage tracking with Fusion Anthropic auth sto
Restores Claude usage tracking across the dashboard by integrating with Fusion Anthropic auth storage, and adds detection and testing for the `model_context_window_exceeded` stop reason to handle context limit errors gracefully. The work spans planning logic, usage tracking, mission management UI, a Fusion-Task-Id: FN-3302
This commit is contained in:
@@ -88,6 +88,28 @@ describe("isContextLimitError", () => {
|
||||
expect(isContextLimitError("Context Window Exceeds limit")).toBe(true);
|
||||
});
|
||||
|
||||
// ── Anthropic model_context_window_exceeded stop_reason ──────────────
|
||||
|
||||
it("matches full pi-ai error 'Unhandled stop reason: model_context_window_exceeded'", () => {
|
||||
expect(isContextLimitError("Unhandled stop reason: model_context_window_exceeded")).toBe(true);
|
||||
});
|
||||
|
||||
it("matches standalone 'model_context_window_exceeded'", () => {
|
||||
expect(isContextLimitError("model_context_window_exceeded")).toBe(true);
|
||||
});
|
||||
|
||||
it("matches 'model_context_window_exceeded' case-insensitively", () => {
|
||||
expect(isContextLimitError("Model_Context_Window_Exceeded")).toBe(true);
|
||||
});
|
||||
|
||||
it("does NOT match 'model_context_window' without 'exceeded'", () => {
|
||||
expect(isContextLimitError("model_context_window")).toBe(false);
|
||||
});
|
||||
|
||||
it("does NOT match 'context_window' alone", () => {
|
||||
expect(isContextLimitError("context_window")).toBe(false);
|
||||
});
|
||||
|
||||
// ── Negative matches: must NOT trigger ─────────────────────────────
|
||||
|
||||
it("returns false for empty string", () => {
|
||||
|
||||
@@ -42,6 +42,9 @@ const CONTEXT_OVERFLOW_PATTERNS: RegExp[] = [
|
||||
// Provider JSON error envelope variant: "context window exceeds limit (2013)"
|
||||
// Matches when "context window" and "exceeds" appear together (order-flexible)
|
||||
/context\s+window\s+exceeds/i,
|
||||
// Anthropic API stop_reason: model_context_window_exceeded
|
||||
// Surfaces as "Unhandled stop reason: model_context_window_exceeded" from pi-ai's mapStopReason()
|
||||
/model_context_window_exceeded/i,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user