Skip to content

Comments

feat: event-driven reactions architecture#91

Open
AgentWrapper wants to merge 11 commits intomainfrom
feat/EVENT-REACTIONS-ARCH
Open

feat: event-driven reactions architecture#91
AgentWrapper wants to merge 11 commits intomainfrom
feat/EVENT-REACTIONS-ARCH

Conversation

@AgentWrapper
Copy link
Collaborator

Summary

Implements the broader event-driven reactions architecture that all automatic response behaviors plug into. Coordinates with ao-48 (review-comments reaction) by providing shared infrastructure without duplicating that work.

New: Event Log (packages/core/src/event-log.ts)

  • Append-only JSONL audit trail at ~/.agent-orchestrator/{hash}-events.jsonl
  • All state transitions and reaction executions are now logged
  • createEventLog(logPath) / createNullEventLog() / getEventLogPath(configPath)
  • Exported from @composio/ao-core as first-class API

New: Automated Comment Detection (bugbot/linter feedback)

  • Polls scm.getAutomatedComments() every cycle when a PR exists
  • Emits automated_review.found event with comment details (bot name, severity, path, url)
  • Triggers configurable bugbot-comments reaction (default: send-to-agent)
  • Deduplication via fingerprinting — tracks sorted comment IDs per session; only retriggers when new/changed comments appear, not on every poll cycle

New: Persistent State Retrigger (retriggerAfter)

  • New retriggerAfter?: string field on ReactionConfig (e.g. "10m", "30s")
  • Fills the gap where an agent receives a CI failure message but doesn't fix it — the reaction re-fires after the configured interval rather than silently giving up
  • Only applies to send-to-agent actions, opt-in per reaction
  • Works with existing retries/escalateAfter for progressive escalation to human

Updated Default Reactions

Reaction retriggerAfter
ci-failed 15m
changes-requested 20m
bugbot-comments 20m (new default)
merge-conflicts 10m

Coordination with ao-48 (review-comments)

  • getPendingComments polling is explicitly not implemented here — ao-48 owns that
  • A clear comment in lifecycle-manager.ts marks where ao-48's check should go
  • The same checkAutomatedComments pattern and deduplication infrastructure is available for ao-48 to reuse for pending review comments

Test plan

  • All 203 core tests pass (pnpm test)
  • Zero type errors (pnpm typecheck)
  • Zero lint errors (pnpm lint)
  • Build succeeds across all packages (pnpm build)
  • New test suites cover: event log integration, bugbot detection + deduplication, persistent retrigger + no-retrigger guard

🤖 Generated with Claude Code

@AgentWrapper AgentWrapper force-pushed the feat/EVENT-REACTIONS-ARCH branch from f08eadf to 90355ac Compare February 18, 2026 10:44
@AgentWrapper AgentWrapper force-pushed the feat/EVENT-REACTIONS-ARCH branch from 5b28147 to 7a8a838 Compare February 18, 2026 12:40
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@AgentWrapper AgentWrapper force-pushed the feat/EVENT-REACTIONS-ARCH branch 3 times, most recently from 0f43cc5 to e2cd5f5 Compare February 18, 2026 22:54
AgentWrapper added a commit that referenced this pull request Feb 19, 2026
- Kanban column order: working→pending→review→respond→merge
  (left = in progress, right = ready to ship)
- Columns use flex-1 min-w-[200px] to fill available width
  instead of fixed 260px leaving half the page empty
- Alert badges: inline-flex wrapper prevents stretching to full
  row width when wrapping
- Terminal button: add bg-subtle fill so it reads as a button
- PR number (#91): remove opaque pill background, now plain
  amber text link — clearly a hyperlink
- Merge PR button: pt-0.5 spacer above the action area

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AgentWrapper added a commit that referenced this pull request Feb 19, 2026
- Kanban column order: working→pending→review→respond→merge
  (left = in progress, right = ready to ship)
- Columns use flex-1 min-w-[200px] to fill available width
  instead of fixed 260px leaving half the page empty
- Alert badges: inline-flex wrapper prevents stretching to full
  row width when wrapping
- Terminal button: add bg-subtle fill so it reads as a button
- PR number (#91): remove opaque pill background, now plain
  amber text link — clearly a hyperlink
- Merge PR button: pt-0.5 spacer above the action area

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AgentWrapper added a commit that referenced this pull request Feb 19, 2026
- Kanban column order: working→pending→review→respond→merge
  (left = in progress, right = ready to ship)
- Columns use flex-1 min-w-[200px] to fill available width
  instead of fixed 260px leaving half the page empty
- Alert badges: inline-flex wrapper prevents stretching to full
  row width when wrapping
- Terminal button: add bg-subtle fill so it reads as a button
- PR number (#91): remove opaque pill background, now plain
  amber text link — clearly a hyperlink
- Merge PR button: pt-0.5 spacer above the action area

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AgentWrapper added a commit that referenced this pull request Feb 20, 2026
…nal (#125)

* docs: add design research artifacts — briefs, token reference, screenshots

Comprehensive design research package for the ao dashboard, session
detail page, and orchestrator terminal. Produced via competitive analysis
of 14 products (Linear, Vercel, Railway, Fly.io, Inngest, WandB, LangSmith,
Supabase, and more) + Playwright CSS extraction from live sites + full
codebase audit.

Artifacts:
- docs/design/design-brief.md            Main design brief (v2, Playwright-updated)
- docs/design/session-detail-design-brief.md   /sessions/[id] design spec
- docs/design/orchestrator-terminal-design-brief.md  Orchestrator page spec
- docs/design/token-reference.css        Drop-in CSS replacement for globals.css
- docs/design/competitive-analysis-raw.md  Raw research notes, all 14 sites
- docs/design/design-brief-v1.md         Original text-only brief (pre-Playwright)
- docs/design/README.md                  Index + research methods summary
- docs/design/screenshots/linear-homepage.png   Playwright-captured screenshot
- docs/design/screenshots/railway-homepage.png  Playwright-captured screenshot

Key findings:
- Linear CSS token values verified via Playwright (body bg #08090A, accent
  #7070FF, Berkeley Mono monospace, type scale, radius, transitions)
- Recommended palette: #0C0C11 base (blue-cast dark vs current GitHub #0d1117)
- Highest-impact change: load Inter Variable via next/font/google
- Orchestrator terminal needs visual differentiation (violet accent, status strip)
- token-reference.css is ready to drop into packages/web/src/app/globals.css

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

* feat(web): redesign dashboard, session detail, and orchestrator terminal

Implements a cohesive dense dark-mode design system across all three main views.

- New color token palette: #0c0c11 base, #141419 surface, #1c1c25 elevated
- Accent blue #5b7ef8, status semantics (ready/error/attention/working/idle/done)
- Violet accent #a371f7 reserved for orchestrator
- Inter Variable + JetBrains Mono loaded via next/font with CSS variables
- activity-pulse keyframe for live agent dots

- AttentionZone header: dot + label + flex divider + count pill + chevron
- Sessions laid out in responsive 1→2→3 column grid
- Solid green merge button (translateY hover), no confirm() dialog

- Breadcrumb nav: ← Agent Orchestrator / {session-id} [orchestrator badge]
- CSS 8×8px activity dot with pulse animation replaces emoji labels
- Merge-ready state: green-bordered banner with checkmark icon
- Orchestrator sessions show zone counts strip (merge/respond/review counts)

- xterm.js dark theme (#0a0a0f bg, #d4d4d8 fg, full 16-color ANSI palette)
- variant prop: "agent" (blue cursor) vs "orchestrator" (violet cursor)
- Dynamic height prop instead of fixed 600px; fullscreen toggle with SVG icons

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

* refactor(web): strip rainbow stats, clean header, IBM Plex Sans typography

- Replace Inter with IBM Plex Sans (technical tool aesthetic, distinctive numerics)
- Replace 4-color big-number stats bar with a single compact inline status line
  in the header: "35 sessions · 1 working · 9 PRs" — no decorative colors
- Remove the two-tone "Agent (blue) Orchestrator (white)" title — just "Orchestrator"
- Remove ClientTimestamp (useless) — replaced by orchestrator nav link
- Zone headers: colored dot only (semantic), neutral uppercase label, plain count
  — removes the rainbow-colored label text that read as a widget template
- Add subtle radial gradient glow at top of page for depth

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

* feat(web): kanban layout, amber accent, full-width, bigger stats

- Switch accent from blue (#5b7ef8) to amber/gold (#d18616) throughout
- Replace grid layout with horizontal Kanban columns for active zones
  (merge, respond, review, pending, working), Done stays full-width below
- Remove max-w-[1100px] constraint — full viewport width
- Header stats numbers 20px bold (was 12px), orchestrator link is now a
  visible bordered button
- AttentionZone gains variant="column" for Kanban mode (compact header
  with count pill, vertical card stack)
- Update all hardcoded rgba(91,126,248,...) in SessionCard to amber

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

* fix(web): layout, alert sizing, column order, button feel

- Kanban column order: working→pending→review→respond→merge
  (left = in progress, right = ready to ship)
- Columns use flex-1 min-w-[200px] to fill available width
  instead of fixed 260px leaving half the page empty
- Alert badges: inline-flex wrapper prevents stretching to full
  row width when wrapping
- Terminal button: add bg-subtle fill so it reads as a button
- PR number (#91): remove opaque pill background, now plain
  amber text link — clearly a hyperlink
- Merge PR button: pt-0.5 spacer above the action area

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

* fix(web): don't cache rate-limited partial PR data

When GitHub rate limits fire, enrichSessionPR was caching the
bad partial data (0 additions, CI failing) for 60 seconds, causing
the dashboard to show incorrect data for the full TTL window.

- Skip cache write when majority of API calls failed
- Downgrade console.error → console.warn (this is handled/expected)

The next page refresh will retry live API calls, so data recovers
as soon as the rate limit window resets.

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

* feat(web): graceful GitHub API rate limit handling in UI

When the GitHub plugin hits rate limits, the dashboard now:

- Shows a single amber banner: "GitHub API rate limited — PR data
  (CI status, review state, sizes) may be stale. Will retry on
  next refresh."
- Hides CI badge, review decision, and size pill on PR cards
  (they'd show wrong values: +0 -0 XS, CI failing)
- Shows a subtle "⚠ PR data rate limited" note on affected cards
  instead of misleading alert badges
- Skips CI/review/conflict-based attention zone classification
  for rate-limited PRs (prevents sessions moving to Review due
  to phantom "CI failing" from the fallback value)
- Doesn't cache partial rate-limited data so next refresh retries
  live API calls as soon as the rate limit window resets

What still works when rate limited:
- Session ID, title, branch, PR number/link
- Session activity status (working/spawning/etc.)
- Merge button if mergeability was already cached
- Restore/terminate/send actions

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

* feat(web): dashboard redesign — glassmorphism, Kanban, rate-limit handling, perf fix

Design:
- Kanban layout: active zones as flex columns (working→pending→review→respond→merge),
  Done as full-width grid below
- GitHub dark color palette (main's tokens) with glassmorphic card surfaces
  (rgba bg + backdrop-blur) and subtle blue/violet body gradient
- Activity state shown as labeled pill (● active / ● idle etc.) instead of bare dot
- Session card: title on its own row, larger font, inline-flex alert badges (no stretch)
- PR number rendered as plain accent link, not a blue pill badge
- Terminal button has background fill to feel like a button
- Info circle icon replaces alarming warning triangle for rate-limit indicators
- "1 working" → "1 active" in header stats
- PR table constrained to max-w-[900px] and centered
- Orchestrator session no longer uses purple accent

Rate limiting:
- isPRRateLimited() helper; getAttentionLevel() skips PR classification when limited
- Rate-limited banner in Dashboard; suppressed CI/size/review badges in PRStatus
- SessionCard shows subtle "PR data rate limited" indicator; getAlerts() returns []
- serialize.ts: rate-limited enrichment results cached for 5 min (not 60s) to stop
  retrying 168 failing API calls every minute

Performance:
- page.tsx: 4s hard timeout on PR enrichment — serves stale data fast instead of
  blocking SSR for 75s under rate limiting
- cache.ts: TTLCache.set() accepts optional ttl override for per-entry control

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

* fix: suppress stale size/CI/review in PR table when rate limited

PRTableRow now shows "—" for size, CI, and review columns when GitHub
API is rate limited, matching the card view which already hides these.
Prevents misleading "+0 -0 XS" size and "needs review" labels from the
default fallback values.

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

* feat: 3D card effect with depth shadow and top-edge shine

Cards now clearly pop against the dark background:
- Solid gradient bg (rgba(28,36,47) → rgba(18,23,31)) instead of
  near-invisible rgba(22,27,34,0.8) surface
- Layered box-shadow: contact shadow + diffuse depth + inset top highlight
  that simulates light hitting the card's top edge (the "shine")
- Hover: card lifts 2px with deeper shadow
- Merge-ready: green-tinted bg with green ambient glow + stronger lift on hover

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

* fix: restore text legibility inside session cards

The darker solid card gradient made muted/secondary text nearly
invisible — #484f58 (text-muted) had only ~2:1 contrast on the
new card bg. Override the color tokens locally within .session-card
to GitHub's established dark-mode legibility values:

  --color-text-muted:     #484f58 → #656d76  (3.8:1 on card bg)
  --color-text-secondary: #7d8590 → #8b949e  (6.2:1 on card bg)
  --color-text-tertiary:  #484f58 → #656d76

Scoped to .session-card so the rest of the UI is unchanged.

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

* fix: address bugbot comments — fonts, review zone, ActivityDot, orchestrator btn

- layout.tsx: add IBM Plex Sans weight 700 (was missing, font-bold falling
  back to 600)
- DirectTerminal.tsx: use "IBM Plex Mono" instead of unloaded "JetBrains Mono"
- SessionDetail.tsx: add review zone to OrchestratorStatusStrip (was omitted,
  sessions with CI failures were invisible in the strip)
- ActivityDot.tsx: extract shared component, remove duplicate implementations
  in SessionCard.tsx and SessionDetail.tsx
- Dashboard.tsx: redesign orchestrator button with 3D glass style matching
  card aesthetic (blue-tinted bg, depth shadow, hover lift)

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

* fix(web): lint — eqeqeq, duplicate import, unused var

- ActivityDot.tsx: != → !== (eqeqeq rule)
- PRStatus.tsx: merge duplicate @/lib/types imports into one
- SessionCard.tsx: remove unused activityIcon import

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

* feat(web): elevate session detail + orchestrator page design

- Nav: glass backdrop-blur effect with chevron back link
- Header: detail-card 3D treatment with left-border accent keyed to activity color
- Meta chips: bordered pill style with subtle bg instead of flat text
- Status tag: pill badge for status instead of plain text
- PR card: detail-card 3D treatment, border-color reflects PR state
- PR merged badge: purple pill instead of gray text
- Unresolved count: red pill badge in section header
- Blockers section: renamed "Issues" → "Blockers"
- Terminal section: colored bar indicator instead of plain label
- Orchestrator status strip: total agent count + per-zone colored pills
- globals.css: add .nav-glass and .detail-card classes

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

* fix(web): fetchZoneCounts parses body.sessions, delayed 2s to avoid contention

The /api/sessions endpoint returns `{ sessions: [...] }` not a bare array.
fetchZoneCounts was treating the whole response object as an array, so
zone counts were always zero on the orchestrator detail page.

Also delays the initial fetchZoneCounts call by 2s so it doesn't contend
with the session fetch on page load (both hit /api/sessions which is slow
when GitHub enrichment is running).

Also includes: Playwright kill-Chrome-for-Testing tip in CLAUDE.md,
toned-down detail-card shadow in globals.css.

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

* perf+test(web): cache-first PR enrichment, skip exited sessions, fix component tests

Performance improvements:
- enrichSessionPR() now accepts cacheOnly option and returns boolean
- /api/sessions/[id]: serve from cache immediately, only block on first load
- /api/sessions: skip PR enrichment for EXITED sessions (no longer changing)
- cache: increase default TTL from 60s to 5 minutes

Test fixes (match redesigned SessionCard + AttentionZone):
- "restore session" (header) → "restore"; expanded panel still shows "restore session"
- "merge PR #N" → "Merge PR #N" (capital M)
- "CI status unknown" → "CI unknown"
- "ask to fix CI" / "ask to fix CI" → "ask to fix"
- "terminate session" → "terminate"
- Zone labels: RESPOND/WORKING/DONE → Respond/Working/Done (CSS uppercase is visual only)
- "working" zone no longer collapsed by default; collapse tests now use "done" zone

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

* feat(core): ActivityDetection with timestamp propagation

- Add ActivityDetection interface { state, timestamp? } to types.ts
- Agent getActivityState() returns ActivityDetection | null instead of
  ActivityState | null, allowing timestamp from JSONL mtime to propagate
- session-manager updates session.lastActivityAt when detected.timestamp
  is more recent — fixes "active 22h ago" showing stale timestamps
- Update all agent plugins (claude-code, aider, codex, opencode) to
  return ActivityDetection objects

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

* fix(web): dismissible rate limit banner + 60min rate-limit cache TTL

- Add X dismiss button to GitHub API rate limit banner in Dashboard.tsx
  so it can be closed during demos
- Extend rate-limited PR cache TTL from 5min to 60min — GitHub GraphQL
  rate limits reset hourly, no point retrying every 5 minutes

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

* fix(web): address Cursor Bugbot review comments on PR #125

- Dashboard StatusLine: active sessions count now uses var(--color-status-working)
  (blue) instead of neutral text color, matching the design system semantics
- SessionCard: isReadyToMerge now guards against rate-limited state — a card
  with stale cached mergeability data won't show green merge-ready styling
- DirectTerminal: add `variant` to useEffect dependency array (was missing,
  causing stale cursor/selection colors if variant changed after mount)
- agent-aider: include `timestamp: chatMtime` in all ActivityDetection returns,
  matching the pattern used by agent-claude-code (enables accurate lastActivityAt)

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

* fix(ci): resolve lint, typecheck, and test failures

Lint:
- Remove unused parseJsonlFile function (superseded by parseJsonlFileTail)
- Remove dead lastLogModified stat() call in getSessionInfo (field was
  removed from AgentSessionInfo but the filesystem read was left behind)

Typecheck + Tests (ActivityDetection):
- session-manager.test.ts: update mocks to return { state: "active" } /
  { state: "idle" } instead of bare strings — getActivityState() returns
  ActivityDetection | null, not ActivityState | null
- integration tests (aider, claude-code, codex, opencode): update imports
  from ActivityState → ActivityDetection, variable types, comparisons
  (activityState?.state !== "exited"), and assertions (?.state).toBe()

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

* fix: parseJsonlFileTail uses readFile for small files; enrich exited sessions with PRs

- parseJsonlFileTail now calls stat() then readFile() for files smaller than
  maxBytes, falling back to open()/handle.read() only for large files. This
  fixes the test infrastructure (which mocks readFile but not open) and also
  fixes a scope bug where `offset` was declared inside an inner try block but
  referenced outside both try blocks.
- Math.max(0, NaN) returns NaN not 0, so size must default to 0 when stat
  returns a mock without a size field: `const { size = 0 } = await stat(...)`.
- Update activity-detection.test.ts: getActivityState() now returns
  ActivityDetection objects, so tests use (await ...)?.state comparisons.
- Remove stale lastLogModified test (field was removed from AgentSessionInfo).
- Remove EXITED skip guard from api/sessions/route.ts: exited sessions can
  still have open, merge-ready PRs that need enrichment on the dashboard.

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

* fix: comprehensive code review fixes — tests, timestamps, UI correctness

Address gaps identified in code review of the ActivityDetection PR:

Core / Session Manager:
- Add `timestamp` to all `{ state: "exited" }` returns in all 4 agent plugins
  (claude-code, aider, codex, opencode) using consistent `exitedAt = new Date()` pattern
- Add 2 new session-manager tests: timestamp propagation when detection timestamp
  is newer, and no-downgrade when detection timestamp is older
- Fix `parseJsonlFileTail` lint error: remove useless `= 0` initializer (value was
  always overwritten before use; catch block returns early)

Web package — tests:
- Fix 3 `api-routes.test.ts` failures: `sessionsGET()` needs a Request object since
  the route reads `request.url` for `?active=true` query param
- Fix `serialize.test.ts` rate-limit test: spy on `console.warn` (what the code uses)
  not `console.error`
- Add 5 `ActivityDot` component tests covering all activity states, unknown states,
  null activity, and dotOnly mode

Web package — UI correctness:
- Fix `relativeTime()` in SessionDetail to guard against invalid/empty ISO strings
- Fix timer Map leak: add `timersRef.current.clear()` in cleanup effect after forEach
- Add `encodeURIComponent` to sessionId in message fetch URL

Server — race condition fix:
- Guard `activeSessions.delete` in pty.onExit, ws.on("close"), and ws.on("error")
  against stale handlers deleting a newly-registered session with the same ID.
  Fixes flaky integration test where afterEach's pty.kill() fired asynchronously
  after the next test had already set up a new session with the same session ID.

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

* fix(web): narrow PREnrichmentData types to eliminate unsafe casts in serialize

PREnrichmentData.ciStatus and .reviewDecision were typed as string,
requiring unsafe `as` casts when reading from cache into DashboardPR.
Narrow them to the same literal union types used by DashboardPR, making
the casts unnecessary. Also narrow ciChecks[].status to match CoreCICheck.

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
AgentWrapper and others added 11 commits February 20, 2026 18:57
…on, persistent retrigger

Core infrastructure for the autonomous reactions system:

**Event Log (`packages/core/src/event-log.ts`)**
- New JSONL append-only event log for all orchestrator events
- `createEventLog(logPath)` — writes to `~/.agent-orchestrator/{hash}-events.jsonl`
- `createNullEventLog()` — no-op for tests/opt-out
- `getEventLogPath(configPath)` added to paths.ts
- All state transitions and reaction executions are now logged
- Exported from `@composio/ao-core`

**Automated Comment Detection (bugbot)**
- Polls `scm.getAutomatedComments()` every cycle when a PR exists
- Emits `automated_review.found` event with comment details
- Triggers `bugbot-comments` reaction (send-to-agent by default)
- Deduplication via comment-ID fingerprinting — only retriggers when
  new/changed comments appear, not every poll cycle

**Persistent State Retrigger (`retriggerAfter`)**
- New `retriggerAfter?: string` field on `ReactionConfig` (e.g. "10m")
- When a session stays in a bad state (ci_failed, changes_requested, etc.)
  without transitioning, reactions re-fire after the configured interval
- Handles the case where an agent received CI failure message but didn't fix it
- Combined with `retries`/`escalateAfter` to eventually escalate to human
- Opt-in per reaction — preserves existing behaviour when not configured

**Default reactions updated:**
- `ci-failed`: retriggerAfter 15m
- `changes-requested`: retriggerAfter 20m
- `bugbot-comments`: retriggerAfter 20m (new default)
- `merge-conflicts`: retriggerAfter 10m

**Architecture coordination with ao-48:**
- Review comment polling (`getPendingComments`) is explicitly NOT implemented here
- ao-48 can add it using the same checkAutomatedComments pattern
- `eventToReactionKey("review.changes_requested")` → "changes-requested" left intact

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gerAfter for bugbot

Fixes two bugs flagged in PR review:

1. **Fingerprint not cleared on state transition**
   The comment on line 621 promised to clear `automatedCommentFingerprints`
   on state transition (so bot comments retrigger after agent pushes a fix),
   but the actual delete call was missing. Added
   `automatedCommentFingerprints.delete(session.id)` unconditionally on any
   state transition.

2. **bugbot retriggerAfter had no code path**
   `checkPersistentConditions` routes via `statusToEventType` → no SessionStatus
   maps to `automated_review.found`, so `retriggerAfter` for `bugbot-comments`
   was configured but could never fire. Fixed by adding time-based retrigger
   logic directly in `checkAutomatedComments`: when the fingerprint is unchanged
   but `retriggerAfter` has elapsed since the last attempt, re-trigger the
   reaction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Legacy sessions (and sessions created before metadata had a `project` field)
cause the merge button to fail with "No SCM plugin configured" because
session.projectId is empty.

Add inferProjectId() that matches session ID prefix against configured
sessionPrefix values (e.g. "ao-18" matches prefix "ao"), with fallback
to the only configured project when there's just one. Use it in
metadataToSession() and the merge API route.

Also improve dashboard error display — show user-facing alerts with
parsed JSON error responses and formatted merge blockers instead of
console-only logging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…guard, JSON validation

Three bugs identified in re-review of feat/EVENT-REACTIONS-ARCH:

1. State transition event logged after its reaction events
   Log the transition event (ci.failing, etc.) to the JSONL audit trail
   BEFORE calling executeReaction, so the cause appears before the effect
   in the append-only log.

2. Retrigger repeatedly escalates after threshold is reached
   Add `escalated: boolean` to ReactionTracker. Set it when a reaction
   escalates to human notification. checkPersistentConditions now returns
   early if tracker.escalated is true, preventing notification spam on
   every retrigger cycle after the escalation threshold.

3. Unvalidated cast of parsed JSON to OrchestratorEvent
   Add isValidEventEntry() runtime type guard in event-log.ts that checks
   all required fields before accepting a parsed JSONL entry. Entries from
   file corruption or schema changes are silently dropped rather than
   returning incorrectly-typed objects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…igger + response body fix

Two bugs identified in re-review:

1. Missing escalated guard in checkAutomatedComments retrigger path
   The same-fingerprint + timer-elapsed retrigger path in checkAutomated-
   Comments was missing the tracker.escalated check that was already added
   to checkPersistentConditions. Without it, every retrigger cycle after
   escalateAfter elapses would re-escalate to human notification spam.

2. Response body consumed twice in merge error handler (Dashboard.tsx)
   res.json() and res.text() both consume the response body stream. If
   res.json() throws (e.g., proxy 502 returns HTML), the catch block's
   res.text() also fails, so users always saw "Unknown error". Fixed by
   reading res.text() first, then parsing with JSON.parse.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The merge-conflicts reaction's retriggerAfter: "10m" can never fire.
checkPersistentConditions requires the session to be in RETRIGGER_STATES,
which is driven by SessionStatus values. There is no merge_conflicts
SessionStatus — determineStatus never returns one and VALID_STATUSES
doesn't include it. Adding retriggerAfter without the backing status is
dead configuration that misleads readers into thinking it works.

Remove retriggerAfter and add an explanatory comment for future
implementors who wire up the merge_conflicts status.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…omatedComments

State transitions clear the automated comment fingerprint, so re-detected
identical bot comments look "new" to the fingerprint-change path and bypass
the tracker.escalated guard that the same-fingerprint retrigger path enforces.
Add the same guard before executeReaction in the new/changed fingerprint path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…action

When auto: false and action: "send-to-agent", neither the automated branch
nor the else-if (which only caught !reactionConfig or action === "notify")
fired, silently dropping the event. Change else-if to else so any case
where the automated reaction is skipped (auto: false, no config, or
notify-only) falls through to notifyHuman — mirroring the transition-based
path which always falls back to notifyHuman when the reaction doesn't run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
getEventLogPath was exported from @composio/ao-core but had zero callers —
the lifecycle manager always defaulted to createNullEventLog(), making it
dead code. Wire up createEventLog(getEventLogPath(config.configPath)) as
the default so events are durably logged to ~/.agent-orchestrator/{hash}-events.jsonl
out of the box. Callers can still inject a custom EventLog via deps.eventLog.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When comments.length === 0, only automatedCommentFingerprints was cleared.
The reactionTrackers entry (including tracker.escalated = true) persisted
permanently, silently blocking all future reactions for new bot comments.
Delete the tracker when comments resolve so future bot activity starts fresh.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The 3750f76 commit added a required `projects` parameter to
metadataToSession for inferProjectId support, but the restore()
call site missed it, causing a TypeScript build error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AgentWrapper AgentWrapper force-pushed the feat/EVENT-REACTIONS-ARCH branch from e2cd5f5 to 2345c9d Compare February 20, 2026 13:28
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.

1 participant