Skip to content

feat(agents): alerting agent system prompt (spec 018 plan 1)#1261

Merged
zbigniewsobiecki merged 3 commits intodevfrom
plan/018-1-alerting-prompt
May 6, 2026
Merged

feat(agents): alerting agent system prompt (spec 018 plan 1)#1261
zbigniewsobiecki merged 3 commits intodevfrom
plan/018-1-alerting-prompt

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Author the system prompt template (src/agents/prompts/templates/alerting.eta) that the alerting agent's worker tries to load at boot. Every other piece of the alerting agent was already wired (YAML definition, capabilities, trigger handlers, context pipeline, Sentry integration); the missing .eta produced an ENOENT at agent boot when the first prod-traffic Sentry alert arrived (cascade project, 2026-05-06).

After this PR, an alerting agent dispatched via the existing Sentry trigger handlers reaches its execution phase end-to-end. Plan 2 of this spec (next PR) closes the silent-failure path that masked the gap.

Spec / plan

  • Spec: 018 (alerting agent + worker boot-failure visibility, bundled)
  • Plan: 018/1 alerting-prompt
  • Spec ACs satisfied: 1-6 (alerting block) — full coverage

What ships

  • src/agents/prompts/templates/alerting.eta — system prompt with persona, INVESTIGATE-AND-FILE-ONLY guardrail, three-phase process (parse pre-loaded event → confirm via source reads → file or comment), predictable output structure
  • tests/unit/agents/prompts.test.ts — 10 new tests for render-success, phase markers, guardrail, environment partial, comment-vs-create routing, engine-agnostic prose, read-only reinforcement
  • tests/unit/agents/definitions/alerting.yaml.test.ts — 4 new tests pinning the static capability invariants (no fs:write, no scm:*, resolved gadget allowlist excludes WriteFile/CreatePR/CreatePRReview)
  • README.md — alerting agent inventory entry; agent count 11 → 12
  • CHANGELOG.md — Added entry under Unreleased

Plan divergence

Plan task #2 was downgraded from a heavy E2E integration test (driving the dispatch pipeline against a fixture Sentry payload) to a static capability-allowlist test. The behavioral property "agent does not edit source" is enforced statically by the YAML's capability declaration — the agent literally cannot invoke source-edit gadgets regardless of what the prompt says. A static check is more reliable than a behavioral negative-assertion that depends on LLM cooperation. Recorded in the plan body itself.

Test plan

  • Full unit suite: 479 files, 8808 tests pass
  • npm run typecheck clean
  • npm run lint clean (no new warnings)
  • Post-merge: fire another Sentry test alert from the cascade project and confirm cascade runs list --project cascade --agent-type alerting shows a non-crashed run

What's NOT in this PR

  • Worker boot-failure visibility (run-record reorder, exit code 2, Sentry tag, conformance test, synthesized identifier for sentry runs) — plan 2 of 2.

🤖 Generated with Claude Code

zbigniewsobiecki and others added 3 commits May 6, 2026 14:05
Spec captures two related gaps surfaced by the first sentry-bound agent run
(2026-05-06): alerting agent's missing prompt template and the silent worker
boot-failure path that masked it.

Two plans downstream: alerting-prompt (feature) and boot-failure-visibility
(hardening, follow-on to spec 017). Linear DAG, plan 1 → plan 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author the system prompt template that the alerting agent's worker tries to
load at boot. Every other piece of the alerting agent — YAML definition,
capabilities, trigger handlers, context pipeline, Sentry integration — was
already wired. Missing the .eta produced an ENOENT at agent boot when the
first prod-traffic Sentry alert arrived (cascade project, 2026-05-06). After
this plan, an alerting agent dispatched via existing trigger handlers reaches
its execution phase end-to-end.

The prompt structures the agent's behavior as a three-phase investigator
(parse pre-loaded event → confirm root cause via source reads → file or
comment) with an explicit INVESTIGATE-AND-FILE-ONLY guardrail. Predictable
output structure: 'Investigate: <ErrorType> in <Function> (<file>:<line>)'
title and a 4-6 sentence + bullets description.

The agent's read-only guarantee is enforced statically by the YAML's
capability declaration (no fs:write, no scm:*) — the resolved gadget allowlist
excludes WriteFile, CreatePR, CreatePRReview. Plan task #2 was downgraded from
a heavy E2E integration test to a static capability-allowlist test (more
reliable than behavioral negative-assertions that depend on LLM cooperation);
divergence noted in the plan itself.

Tests: 10 new in tests/unit/agents/prompts.test.ts; 4 new in
tests/unit/agents/definitions/alerting.yaml.test.ts. All green; full unit
suite (8808 tests) green; lint + typecheck clean.

Spec ACs 1-6 satisfied (full). Marks plan 018/1 as .done.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit e0ce9ab into dev May 6, 2026
8 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the plan/018-1-alerting-prompt branch May 6, 2026 14:20
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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