Skip to content

feat(core): E10 loop guard + E11 secret redaction - #25

Merged
ajianaz merged 1 commit into
developfrom
feat/e10-e11-guards
Aug 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/e10-e11-guards

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What

Two small, independent guards adopted from oh-my-pi research (#22, #23):

  • E10 loop guard: fingerprints consecutive identical tool calls (tool name + canonical sorted-key JSON input). Three identical calls in a row → TurnOutcome::LoopDetected with a durable error entry explaining the trip. Guard resets on any different call. Budget ceiling (MAX_STEPS=32) unchanged — now covered by a test using distinct inputs per step.
  • E11 secret redaction: scrub() was already applied to provider error strings; it is now also applied to message text in request_body(). If a user message accidentally quotes the API key, it never reaches the provider in cleartext. The durable log keeps the original text (redaction is wire-only).
  • CLI prints a clear loop detected message with a resume hint (exit code 7).

Why

Both land in the "cheap, high-value" bucket from the oh-my-pi deep-dive: loop guard prevents burning the step budget on a stuck model repeating the same call; secret redaction closes a real leak path before more tools can see environment content.

Testing

  • cargo test --workspace: 81/81 pass (69 core + 12 CLI), incl. 3 new loop-guard tests (trip, durable record + sandwich count, reset-on-different-input) and 2 new redaction tests (key absent from wire body, durable log untouched).
  • cargo clippy --workspace --all-targets: 0 warnings.
  • cora review: no findings.

Closes #22, closes #23

- E10: fingerprint consecutive identical tool calls (name + canonical
  JSON input); trip at LOOP_TRIP_AFTER=3 with durable error entry and
  TurnOutcome::LoopDetected. Budget test updated to use distinct inputs
  so it exercises the ceiling, not the guard.
- E11: scrub() now also applied to message text in request_body — the
  API key never leaves the machine in cleartext; durable log untouched.
- CLI: report LoopDetected with resume hint (exit code 7).

Closes #22, closes #23
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit d64dd8f into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/e10-e11-guards branch August 27, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant