observability Plugin
Agent Insights
Agent insight jobs are infrastructure-flavored analysis runs that inspect a repository's recent workflow history and surface improvement suggestions to the operator. They are read-only: no code changes are committed and no pull request is opened.
Agent Insights
Agent insight jobs are infrastructure-flavored analysis runs that inspect a repository's recent workflow history and surface improvement suggestions to the operator. They are read-only: no code changes are committed and no pull request is opened.
Enabling
Agent insights ship as the agent_insights plugin, disabled by default. The plugin is its own feature flag: enable or disable it from Admin → Plugins (or PluginRecord.find_by(name: "agent_insights").update!(enabled: true)). While it is disabled:
- The
agent_insightJob kind,agent_insighttrigger kind,agent_insight_run
step kind, and the agent_insight WorkDefinition are all absent from their registries, so an insight Job cannot be created or dispatched at all.
- The plugin's MCP tools (
submit_insight,update_insight,retire_insight,
list_insights, read_insight, list_recent_workflows) are not advertised to workflow or chat sidecars.
- The repository Insights tab, the
/admin/insightspage, and the plugin's API
endpoints are not mounted.
Existing suggestion rows are left untouched by disabling; bin/rails plugin:purge[agent_insights] is the separate, explicit step that removes them.
Job kind
agent_insight is a Job kind the plugin contributes through :workflow_kinds, alongside core's issue, cron, direct, main_grader, external_pr, and deploy. It shares the same state machine and operator-facing affordances, but is declared issueless and infrastructure, which means:
issue_numbermust be blank.- Insight Jobs are filtered out of the operator's user-facing Job lists.
- The job auto-closes on both workflow success and failure.
Workflow chain
prepare → agent_insight_run → auto_close
prepare — installs repository dependencies as usual (respects .syrus.yml and all standard skip conditions).
agent_insight_run — agentic step. Invokes the insight prompt against the workspace (read-only). The agent discovers recent completed Workflows with list_recent_workflows, reads paginated Run JobLog transcripts with read_run_transcript, inspects host pressure with read_run_worker_health when relevant, searches operational logs with read_syrus_logs when that tool is available, checks memory/insight context, then calls submit_insight for each finding.
auto_close — non-agentic core step. Closes the anchor Job with the Job's own kind as the closure reason (agent_insight), so it does not accumulate in the operator dashboard.
Queue
Insight workflows run on the runs queue because their agentic steps are still RunJob executions. Create insight jobs with priority: "low" so implementation work stays ahead of periodic analysis.
Suggestion records
Each submit_insight call creates one AgentInsights::Suggestion row (table agent_insight_suggestions):
| Field | Type | Description |
|---|---|---|
job | FK | The anchor insight Job. |
repository | FK | The analysed repository. |
title | string | Concise finding title (≤ 200 chars). |
category | string | e.g. repeated_failure, inefficiency, configuration, etc. |
severity | string | low, medium, or high. |
confidence | float | Agent's confidence (0.0–1.0). |
evidence | json | Array of {job_id, run_id, kind} objects. |
proposal_type | string | create_job, save_memory, remove_memory, or informational. Legacy revise_existing_insight rows may still exist but new insight runs should not create them. |
suggested_prompt | text | Optional prompt for a follow-up Job or ScheduledTask. |
memory_suggestion | text | Optional text to store as a memory. |
target_memory | FK | Memory proposed for audited removal on remove_memory suggestions. |
stale_memory_text | text | Snapshot of stale/wrong memory text. |
stale_memory_evidence | text | Explanation of why the memory no longer matches current reality. |
target_insight | FK | Legacy revision reference retained for old rows. |
state | string | pending → accepted or dismissed; dismissed suggestions can return to pending. Any of pending/dismissed (and, with an explicit override, accepted) can transition to retired, a terminal audited state. |
retired_at | datetime | Set when the insight is retired. |
retired_reason | text | Required explanation recorded on retirement. |
superseded_by_insight | FK | Optional insight that supersedes this retired one. |
superseded_by_job | FK | Optional Job that resolved or replaced this retired finding. |
created_job | FK | Populated when the operator promotes the suggestion into a Job. |
Retirement
retire_insight is an audited state transition, not a physical delete: retired rows keep their full history and stay inspectable via list_insights(state: "retired")/state: "all" and read_insight. Pending and dismissed insights retire directly. Accepted insights are refused by default — accepted insights are operator history, so the normal path is filing a new standalone insight that supersedes the accepted one — unless the caller explicitly passes retire_accepted: true, a distinct override reserved for accepted insights that are themselves confirmed obsolete. Every retirement records a retired AgentInsights::AuditEvent with the previous/new state and retirement fields, the actor (run/user/system), and the reason.
Repository insight suggestions are identified in the UI as stable INSIGHT-<id> slugs. Each repository insight card renders the slug as a one-click copy control, while accepted cards continue to link to the Job they created when applicable.
The repository insight view uses the shared smart-folder and filter controls instead of bespoke state tabs. Built-in folders cover Pending, Accepted, Dismissed, Retired, and All, and the folder/filter URL preserves refresh, back/forward navigation, and copied links. Operators can add filters for created date/range, state, severity, proposal type, category, confidence, and created-job presence. Repository and admin insight list views default to the pending review surface, so retired insights are excluded from the default active-review surface without any extra filtering. Both views accept an explicit retired state/folder (or All, which includes retired rows) to inspect retired insights.
List responses keep long prompt, memory, stale-memory, retirement, and evidence content out of each row. Expanding a suggestion loads those fields from GET /api/v1/app/insight_suggestions/:id; compact rows expose presence flags and an evidence count so collapsed UI remains informative. Listing suggestions is read-only. The periodic insight sweep resolves remove-memory suggestions whose target memory has already disappeared.
Repository owners, direct repository members, and members of teams granted access can view insights, discuss them, and view the repository's insight schedule. Accepting, dismissing, restoring, or saving a suggested memory requires repository write access. Updating the repository-wide insight schedule requires repository admin access.
A one-off cleanup path retires the pre-existing stale backlog — pending or dismissed legacy revise_existing_insight rows and pending or dismissed informational rows titled Superseded by #... — without manual DB work:
bin/rails syrus:retire_stale_insight_backlog # retire
DRY_RUN=true bin/rails syrus:retire_stale_insight_backlog # preview only
This runs AgentInsights::StaleBacklogRetirement, which retires each matching row through the normal AgentInsights::Suggestion#retire! audit path with a system actor.
MCP tools
Agent insight runs
The insight agent receives:
read_live_state— inspect the current run/workflow/job/queue state.list_recent_workflows— list completed Workflows for the current repository after the previous insight cutoff (or an explicit ISO8601since).read_run_transcript— read paginated JobLog transcript chunks plus agent summary/diff for a Run in the current repository, with secret-shaped values redacted.read_run_worker_health— inspect worker host health correlated with a Run in the current repository.read_syrus_logs— search recent indexed Rails application logs for repeated exceptions, recurring warnings, slow behavior, retry storms, queue/worker anomalies, failed background jobs, and noisy code paths. This tool is provided by thesyrus_devplugin and returns data only whenoperational_log_indexingis enabled and the current repository istkadauke/syrusor a registered fork/upstream. Operational log ingestion uses the shared observability sink: request/job hot paths append to per-process memory plus a local JSONL spool, and each process has a lazy background flusher that persists rows tooperational_log_eventsand the FTS index in batches. The searchable retention window is 6 hours.read_memory,search_memories,list_memories— read repository-scoped memories.write_memory— store durable facts discovered during analysis. Before
creating a row, the tool checks recent active memories for the same user, scope, scope id, and kind. If normalized text has a matching first ~80 characters or high trigram/Jaccard overlap, the write is rejected with an error that names the existing AgentMemory::Entry id so the agent can read, update, or delete the existing memory instead of creating a duplicate. During rebase retry storms, workflow agents may not write prescriptive memories that tell future agents to skip diagnosis or abort a conflict based on an unverified run-level conclusion; keep abort rationale in the run summary and store only verified file-level facts.
submit_insight— record a new finding, including structured memory-removal proposals.update_insight— revise a pending or dismissed existing insight in place with an audit event. Accepted insights are rejected and should be handled by filing a new standalone insight that cites the accepted prior insight as context.accept_insight— accept one pending insight immediately or passinsight_idsto stage a bounded, deduplicated batch for one operator confirmation. The full batch is authorized and validated before mutation; create-job and save-memory proposals retain their side effects and run transactionally.dismiss_insight— dismiss one pending insight immediately or passinsight_idsfor one grouped confirmation. A shared auditreasonis required; dismissal never creates Jobs or memories.retire_insight— retire one pending or dismissed insight that is stale, duplicated, or superseded, or passinsight_idsfor one grouped confirmation. The singulartarget_insight_idinterface remains supported. A sharedreasonis required, and per-item superseding references can be supplied as maps keyed by insight id. Accepted insights are rejected unlessretire_accepted: trueis passed explicitly. Records aretiredaudit event; rows stay inspectable, never deleted.
The SQL-backed list_insights, list_recent_workflows, and read_run_transcript tools accept one-based pages capped at 10,000. Ordinary out-of-range pages return empty results, while larger values are reduced to the cap before an SQL offset is calculated. Their per-page limits remain unchanged.
Scope enforcement: workflow evidence tools are constrained to the current insight run's repository. submit_insight also validates that evidence.job_id values belong to repositories accessible to the running user. Non-admin users cannot reference jobs from repositories they do not own. Admin users may reference any job.
Operational log matches should be treated as investigative evidence, not as standalone proof. Insight findings should include log evidence plus workflow or run context when possible: affected Job/Run ids, transcript excerpts, correlated worker health, code paths, or repeated occurrences across the log window. Avoid filing insights from one-off benign log lines or isolated noise.
Insight runs must review pending, accepted, and dismissed insights for freshness before filing new ones. When an unaccepted insight's details need correcting but the finding is still active, call update_insight to revise it in place. When an unaccepted insight is stale, duplicated, folded into another insight, or no longer worth any operator review, call retire_insight instead of filing a new informational "Superseded by #N" card. When an accepted insight is changed by a novel realization, create a new insight rather than updating or retiring the accepted row (unless the accepted insight itself is confirmed obsolete, in which case retire_insight(..., retire_accepted: true) applies). They should call list_memories / read_memory for repository-relevant memories and compare them with current code, docs, recent jobs, and accepted implementation state. If a memory is stale or wrong, the agent files a remove_memory insight with target_memory_id, stale_memory_text, and stale_memory_evidence; it must not call delete_memory directly during analysis. Operators accept removal proposals through the application, which soft-deletes the memory via AgentMemory::Entry#soft_delete_by! and records the normal audit event.
Regular chat agents
While the plugin is enabled, regular chat agents can discover and call list_insights, read_insight, and retire_insight from the deferred chat sidecar. Non-admin chat agents are limited to the current chat's attached repositories. Admin chat agents can list/read suggestions across repositories, and should use the repository_id, state, limit, and page filters to keep broad reads deliberate. Chat retirements are audited user actions scoped to an accessible insight's repository, can cite a superseding Job, and keep the same accepted-insight safety guard: accepted rows are refused unless retire_accepted: true is passed deliberately.
submit_insight and update_insight stay limited to agent_insight_run workflows. They create or revise suggestions on the current anchor insight Job and update workflow artifacts, so chat-originated insight creation or revision is not a supported product behavior.
Agent Insight Jobs
Overview
Agent insight jobs (kind: "agent_insight") are analysis runs that inspect a repository's recent workflow history and surface improvement suggestions as AgentInsights::Suggestion records. They are designed for periodic health checks — an agent reviews recent jobs, identifies patterns (repeated failures, inefficiencies, gaps in agent memory, recurring tasks that could be automated), and records structured suggestions for the operator to review, accept, or dismiss.
Insight jobs are read-only: they never commit to the repository, never open a pull request, and auto-close once the analysis completes (success or failure).
Enabling Agent Insights
Agent insights ship as the agent_insights plugin, disabled by default. The plugin is its own feature flag — there is no separate agent_insights Feature row. Enable it from the Plugins admin page:
Admin → Plugins → Agent Insights → Enable
Or via Rails console:
PluginRecord.find_by!(name: "agent_insights").update!(enabled: true)
Once enabled, the following become active:
- "Run insight analysis" button on repository pages
/repositories/:id/plugin/insights— per-repository suggestions list/admin/insights— cross-repository admin viewPOST /api/v1/app/repositories/:id/run_insight_analysisAPI endpointGET /api/v1/app/repositories/:id/insight_suggestionsAPI endpointPATCH /api/v1/app/insight_suggestions/:idAPI endpointGET /api/v1/app/admin/insightsAPI endpoint (admin only)POST /api/v1/app/admin/insights/:id/promote_memoryAPI endpoint (admin only)- The
submit_insightMCP tool is available to agents running in insight workflows - The
list_insightsandread_insightMCP tools are available to regular chat agents through the deferred chat sidecar - The
read_run_worker_healthMCP tool is available so insight agents can use
retained worker host pressure and grader command-span pressure as evidence for Run, Step, and phase-level patterns
The plugin's routes are not mounted while the plugin is disabled, so all of these return 404. The agent_insight Job kind, trigger kind, step kind, and WorkDefinition are likewise absent from their registries, so an insight Job cannot even be created.
Triggering an Insight Run
Via the UI: Navigate to a repository page → click "Run insight analysis". The button is hidden when the feature is off. If an insight job is already running for that repository, clicking the button shows the active job instead of creating a duplicate.
Via the API:
POST /api/v1/app/repositories/:id/run_insight_analysis
Returns the standard repository detail payload with a notice that the job was started (or that one is already running).
What the Agent Analyzes
The agent receives a read-only view of the repository's workspace and recent job history (last 14 days, up to 50 issue-kind jobs). It uses the submit_insight MCP tool to record new findings — one call per distinct pattern. It uses update_insight to revise pending or dismissed existing insights in place; accepted insights are preserved as operator history, so new realizations about them become new standalone insights. It can also call read_run_worker_health(run_id:) to inspect retained CPU, memory, disk, CPU pressure, and IO pressure samples for a specific Run window, including whether the Run's history was clipped by the worker-health retention window. Grader and preflight grader Runs may include command_spans, which let the agent attribute pressure or latency to phases like dependency checks, installs, database preparation, backend tests, or frontend builds instead of only the full Run window. Durable run_resource_summaries retain this Run-level view for 30 days and keep host-correlated pressure fields separate from process-attributed command metrics, with explicit low-confidence fallback markers when command attribution is unavailable.
Each AgentInsights::Suggestion captures:
- title — concise description of the finding (≤ 200 chars)
- category — e.g.,
repeated_failure,inefficiency,configuration,memory_gap,recurring_task - severity —
low,medium, orhigh - confidence — 0.0–1.0 score
- evidence — array of
{job_id, run_id, kind}supporting evidence - proposal_type — explicit action:
create_job,save_memory,remove_memory, orinformational; legacyrevise_existing_insightrows may still exist but new insight runs should not create them - suggested_prompt — optional prompt text for a Job or ScheduledTask that would address the finding
- memory_suggestion — optional text to store as an agent memory for future runs
- target_memory_id, stale_memory_text, stale_memory_evidence — structured stale-memory removal proposal fields
- target_insight_id — legacy revision reference retained for old rows
Reviewing Suggestions
Navigate to /repositories/:id/plugin/insights to see suggestions for a repository, ordered by severity (high → low) then confidence (high → low). Each suggestion has a stable copyable display slug such as INSIGHT-123; accepted suggestions still retain links to any created Job. INSIGHT-<id> references are registered with Syrus's shared slug infrastructure, so generated text that mentions one becomes copyable/linkable with a hover preview, and /s/INSIGHT-<id> or /INSIGHT-<id> redirects to the repository insight view focused on that suggestion. Slug previews include only lightweight metadata and return a neutral inaccessible state for suggestions in repositories the current user cannot see. The repository view uses Syrus smart folders for Pending, Accepted, Dismissed, Retired, and All, and the shared filter bar supports created-date/range, state, severity, proposal type, category, confidence, and created-job presence filters. Folder, filter, and pagination state live in the URL, so refreshes and shared links preserve the selected view.
Regular chat agents can inspect the same suggestions with list_insights and read_insight. Non-admin chat agents can only list/read suggestions for the chat's attached repositories; inaccessible insight ids return a generic not-found/not-accessible error. Admin chat agents can inspect all suggestions and can narrow broad reads with repository_id, state, limit, and page. Chat agents do not receive submit_insight; suggestion creation remains tied to agent insight workflows because that tool records against the anchor insight Job and its workflow artifacts.
Each suggestion shows:
- Title, category tag, severity pill, confidence percentage, and age
- Clickable evidence links to jobs and run transcripts
- Expandable detail showing the suggested prompt and memory suggestion text
- Remove-memory proposals render as destructive stale-memory cards with the target memory id, stale text, and evidence
Accept
Click Accept to open a confirmation form. The form pre-fills with the suggested prompt (if any). You can:
- Edit the prompt text
- Confirm to mark the suggestion accepted and create a direct Job from the prompt
The accepted_at timestamp is recorded, and created_job_id links back to the created Job.
For remove_memory suggestions, Remove memory accepts the suggestion and soft-deletes the target AgentMemory::Entry through AgentMemory::Entry#soft_delete_by!. Non-admin operators can only remove memories they are allowed to delete; admins can accept stale-memory removals from the admin insight view. The insight agent never deletes memories directly.
Dismiss
Click Dismiss to confirm and mark the suggestion dismissed. The dismissed_at timestamp is recorded. Dismissed suggestions can be restored from the Dismissed tab with Undismiss, which returns them to Pending; accepted suggestions cannot be reopened.
Save as Memory
When memory_suggestion is present, a Save as memory button appears on pending and accepted suggestions. Clicking it creates a AgentMemory::Entry record with:
kind: "project_fact"scope: "repository"(scoped to this repository)source_type: "insight",source_id: <suggestion_id>author: "agent"confidence: <suggestion.confidence>
The memory becomes available to future agents working on the same repository.
Admin View
/admin/insights shows a paginated, state-filterable cross-repository table of all suggestions (requires admin role and the plugin enabled). Each row includes the repository slug, the user who owns the source job, severity, confidence, and state.
Admins can expand rows to see the full suggested prompt, memory suggestion, and stale-memory removal evidence. They can Promote to repository memory for memory suggestions — this creates a published AgentMemory::Entry with scope: "repository" for the suggestion repository, making it visible to future agents working in that repository and to users who can read published repository memories. For remove_memory suggestions, admins can accept the removal from the table.
Concurrent Insight Jobs
Syrus enforces at-most-one active insight job per repository. If an insight job is already running when "Run insight analysis" is clicked, a notice is shown and no new job is created. Once the active job closes (success or failure), a new run can be triggered.
Adaptive Scheduling
In addition to on-demand runs, Syrus can automatically schedule insight jobs based on coding job activity. This eliminates the need for fixed time intervals: insight jobs fire when there is genuinely new work to analyze, not on a calendar.
Settings UI
While the plugin is enabled, an Insight Scheduling section appears at the bottom of each repository's edit page (/repositories/:id/edit). It has its own Save and Discard buttons separate from the main repository form:
- Enable automatic insights — toggle to enable or disable adaptive scheduling for this repository.
- Minimum jobs — integer ≥ 1 (default 5). The periodic sweep threshold:
InsightSweepJobruns every 6 hours and fires an insight job if the count of closed coding jobs since the last insight run is ≥ this value. - Maximum jobs — integer ≥ 2, must be greater than Minimum (default 10). The immediate trigger threshold: fires an insight job right away when a coding job closes and the count reaches this value.
Validation requires min < max; the form enforces this client-side before submitting and the server validates it as well.
API
GET /api/v1/app/repositories/:id/insight_schedule_config— returns the current config (enabled,min_jobs_since_last_run,max_jobs_since_last_run). Returns defaults if no record exists yet.PATCH /api/v1/app/repositories/:id/insight_schedule_config— updatesenabled,min_jobs_since_last_run, and/ormax_jobs_since_last_run. Returns 422 on validation failure.
Both endpoints are unmounted (404) while the plugin is disabled.
Status badge
On the repository overview page, a small status badge appears next to the "Run insight analysis" button:
- Auto: off — automatic scheduling is disabled.
- Auto: on (min 5 / max 10) — automatic scheduling is enabled, showing the configured thresholds.
Console / Rails
Adaptive scheduling is also configurable via Rails:
repo = Repository.find_by!(owner: "acme", name: "widgets")
config = repo.insight_schedule_config || repo.build_insight_schedule_config
config.update!(
enabled: true,
min_jobs_since_last_run: 5, # sweep threshold
max_jobs_since_last_run: 10 # immediate trigger threshold
)
Thresholds
Two thresholds control when insight jobs fire automatically:
min_jobs_since_last_run(default: 5) — the periodic sweep threshold.InsightSweepJobruns every 6 hours and fires an insight job for any enabled repository whose count of closed coding jobs since the last insight run is ≥min.max_jobs_since_last_run(default: 10) — the immediate trigger threshold.AgentInsights::Subscriberslistens for thejob.closeddomain event; when the count of closed coding jobs since the last insight run reaches ≥max, an insight job is enqueued immediately without waiting for the next sweep.
Both thresholds count closed jobs of any kind except agent_insight, measured from the finished_at of the most recently created agent_insight job (or from the beginning of time if none exists). Weekends and idle periods are skipped naturally: the count only crosses min if real work has occurred.
Deduplication
Manual runs, the sweep, and the immediate trigger call AgentInsights::Scheduler.enqueue_if_idle!, which locks the repository row and then checks whether a non-closed agent_insight job already exists for that repository. If one is queued or running, no new job is created.
Validation
- Both
min_jobs_since_last_runandmax_jobs_since_last_runmust be ≥ 1. min_jobs_since_last_runmust be strictly less thanmax_jobs_since_last_run.
Job Lifecycle
- Branch: Insight jobs do not create a branch — they operate on a shallow clone of the default branch read-only.
- Auto-close: The anchor Job is automatically closed once the insight workflow finishes (success or failure), so insight jobs do not accumulate in the dashboard.
- Retries: Insight jobs do not retry automatically. Trigger a new run manually if needed.
- Queue: Insight workflows use the
:runsqueue with low Job priority.