feat: de-risk agent loop — semantic tool schema + agent loop + real-WP spike harness
Mirror to GitHub / mirror (push) Canceled after 0s
Mirror to GitHub / mirror (push) Canceled after 0s
- api/agents: tool-schemas (semantic allowlist), agent-loop (multi-step + budget), circuit-breaker, llm-client/tool-executor interfaces - api/agents: WpRestExecutor (real WP REST), OpenRouterLlmClient - e2e/agent: multi-step prompts + run-agent-spike runner (scores rendered changes) - ADR 0017; 101 unit tests green
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { CircuitBreaker } from '../../src/agents/circuit-breaker.ts';
|
||||
|
||||
describe('CircuitBreaker', () => {
|
||||
it('halts after two consecutive failures', () => {
|
||||
const breaker = new CircuitBreaker({ maxConsecutiveFailures: 2 });
|
||||
breaker.recordFailure();
|
||||
breaker.recordFailure();
|
||||
expect(breaker.shouldHalt()).toBe(true);
|
||||
});
|
||||
|
||||
it('does not halt after a single failure', () => {
|
||||
const breaker = new CircuitBreaker({ maxConsecutiveFailures: 2 });
|
||||
breaker.recordFailure();
|
||||
expect(breaker.shouldHalt()).toBe(false);
|
||||
});
|
||||
|
||||
it('resets the failure count after a success', () => {
|
||||
const breaker = new CircuitBreaker({ maxConsecutiveFailures: 2 });
|
||||
breaker.recordFailure();
|
||||
breaker.recordSuccess();
|
||||
breaker.recordFailure();
|
||||
expect(breaker.shouldHalt()).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user