Skip to content

feat: cheerleading detection for agent sessions#1205

Merged
corvid-agent merged 3 commits intomainfrom
agent/architect/implement-cheerleading-detection-for-age-mmvc6fsx-bcc3f1
Mar 18, 2026
Merged

feat: cheerleading detection for agent sessions#1205
corvid-agent merged 3 commits intomainfrom
agent/architect/implement-cheerleading-detection-for-age-mmvc6fsx-bcc3f1

Conversation

@corvid-agent
Copy link
Collaborator

Closes #1021

Summary

  • server/lib/session-analysis.ts (new): isCheerleadingResponse(events: ClaudeStreamEvent[]): boolean — heuristic that detects pure-acknowledgment responses with no tool calls. Flags forward-commitment language ("I'll look into that", "Let me investigate", "On it!") combined with absence of tool_use, code blocks, lists, or substantive length (>200 chars).
  • server/process/manager.ts: integrates the detector into handleEvent(). Per-turn events are accumulated in SessionMeta.currentTurnEvents and analysed at each result event. consecutiveCheerleadingCount is tracked; reaching the threshold (2) emits a __quality:cheerleading:<count> system event visible to owners and orchestrators. Public getter getConsecutiveCheerleadingCount(sessionId) exposed for introspection.
  • server/__tests__/session-analysis.test.ts (new): 22 unit tests — true positives (pure ack patterns), false positives (tool-use present, code blocks, numbered lists, long explanations, empty events), and mixed-turn scenarios.

Test plan

  • bun test server/__tests__/session-analysis.test.ts — 22/22 pass
  • bun test — 7822 pass, 0 fail (no regressions)
  • bun x tsc --noEmit --skipLibCheck — no type errors

🤖 Generated with Claude Code

corvid-agent and others added 2 commits March 17, 2026 17:06
Add comprehensive JSDoc documentation with @param and @returns tags to
exported functions in errors.ts, response.ts, secure-wipe.ts, and
resilience.ts. No functional changes — documentation only.

Closes #1087

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Detects when an agent session produces acknowledgment-only responses
("I'll look into that!") with zero tool calls, indicating no real
progress. Consecutive cheerleading turns (threshold: 2) emit a
session quality warning so the orchestrator can intervene.

- server/lib/session-analysis.ts: isCheerleadingResponse(events) heuristic
  — checks for forward-commitment language, enthusiasm patterns, and
  absence of tool_use with no substantive content markers (code blocks,
  lists, long explanations)
- server/process/manager.ts: accumulate per-turn events in SessionMeta,
  analyse on each result event, track consecutiveCheerleadingCount, emit
  __quality:cheerleading:<count> system event at threshold
- server/__tests__/session-analysis.test.ts: 22 unit tests covering true
  positives, false positives (tool use present, substantive content),
  and mixed-turn scenarios

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
github-actions[bot]
github-actions bot previously approved these changes Mar 18, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All CI checks passed (tsc, tests) on ubuntu. Cross-platform tests (macOS, Windows) run on release tags only.

The previous implementation embedded detection state and logic directly in
ProcessManager (server/process/manager.ts), which is a Constitutional (Layer 0)
path that automated workflows cannot modify.

This commit:
- Reverts server/process/manager.ts to its main-branch state
- Introduces SessionCheerleadingDetector (server/process/session-cheerleading-detector.ts)
  as a standalone observer that attaches via the existing public subscribeAll() API
- Wires the detector into bootstrap.ts (Layer 2) after ProcessManager is created
- Cleans up per-session state on session_exited / session_stopped events

The detection logic and library (server/lib/session-analysis.ts) are unchanged.
The warning is now logged rather than injected as a system event, since no
consumers of __quality:cheerleading:N events exist yet; the event API can be
added in a future human-approved change to manager.ts if needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All CI checks passed (tsc, tests) on ubuntu. Cross-platform tests (macOS, Windows) run on release tags only.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@corvid-agent corvid-agent merged commit 6d635eb into main Mar 18, 2026
13 checks passed
@corvid-agent corvid-agent deleted the agent/architect/implement-cheerleading-detection-for-age-mmvc6fsx-bcc3f1 branch March 18, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: detect cheerleading responses vs substantive progress

1 participant