azurenoops / azurenoops/spin_agent

[BUG] [Narratives/Chat] - 'Auto-fill missing narratives' sidebar action returns SYSTEM_REQUIRED — page-context system ID not passed to chat

Open
#627 0 comments 0 reactions 1 assignee Claimed by @jrspinella View on GitHub
agent:oracle area:rmf bug priority:high
Dominant language
C#
Stars
3
Forks
1
Avg merge
18h 9m
Merged PRs (30d)
43

Description

## Bug Description

The "✨ Auto-fill missing narratives" quick-action button in the chat sidebar fires a message but returns SYSTEM_REQUIRED even when the user is actively viewing a specific system's narratives page. The chat agent loses the page-context system ID and returns disambiguation instead of executing for the current system.

## Steps to Reproduce

1. Navigate to `/systems/{SYSTEM_ID}/narratives` for any system
2. Confirm chat sidebar shows "Viewing: narratives" context indicator
3. Click the "✨ Auto-fill missing narratives" button in the chat sidebar
4. Observe response

## Expected Behavior

The chat agent should use the current page's system context (system ID visible in the URL) and execute `compliance_batch_populate_narratives` for the currently viewed system without disambiguation.

## Actual Behavior

The chat sends "Generate implementation narratives for all controls that are missing them" and receives `SYSTEM_REQUIRED` — a list of 10 QA test systems is shown for disambiguation, even though the user is on a specific system's narratives page with the system ID available in the URL.

```
SYSTEM_REQUIRED: You have multiple registered systems. Please specify which system you mean.
• QA Test System 2026-07-07T09:17:00Z (Phase: Prepare)
• QA Test System 2026-07-06T03:30:00Z (Phase: Prepare)
...
```

## Impact

Makes the "Auto-fill missing narratives" sidebar quick-action completely non-functional from the narratives page. The page-context is shown as "Viewing: narratives" but is not passed to the chat API as the active system context.

## Related Issues

- #621 (SYSTEM_REQUIRED blocking all chat quick-actions due to orphan accumulation)
- #573 (compliance_batch_populate_narratives INVALID_INPUT)

Note: This is distinct from #621 in that the orphan systems are the cause — the disambiguation fires because 65+ systems exist and the correct one isn't resolved from context. However, the **root issue** is the same: the chat does not receive the page-level system ID when firing quick-actions from system-specific pages.

## Console Errors

None — no JS errors observed during this interaction.

## Browser/Environment

Azure Container Apps Dashboard (v2 flankspeed org-centric model)
Browser: Chromium (Playwright/Hermes browser)
Date: 2026-07-07T22:00:00Z
Sweep: Automated 4-hour QA sweep

## Playwright Test Code

```typescript
test('[Narratives] Auto-fill quick-action loses system context', async ({ page }) => {
const SYSTEM_ID = 'b4d0aca6-cdb1-4630-84ae-df93b2747178';
await page.goto(`/systems/${SYSTEM_ID}/narratives`);
await page.waitForSelector('text=Control Narratives');
// Verify context indicator
await expect(page.locator('text=Viewing: narratives')).toBeVisible();
// Click quick-action
await page.click('button:has-text("Auto-fill missing narratives")');
// Should not see SYSTEM_REQUIRED
await expect(page.locator('text=SYSTEM_REQUIRED')).not.toBeVisible({ timeout: 5000 });
// Should see batch populate executing
await expect(page.locator('.chat-response')).toContainText('populating narratives', { timeout: 10000 });
});
```

*Filed by Oracle — Automated 4-hour QA Sweep 2026-07-07T22:00:00Z*

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.