Skip to content

fix(briefing): render briefing body into content so the model sees it#378

Merged
mgoldsborough merged 1 commit into
mainfrom
fix/briefing-model-body
Jun 3, 2026
Merged

fix(briefing): render briefing body into content so the model sees it#378
mgoldsborough merged 1 commit into
mainfrom
fix/briefing-model-body

Conversation

@mgoldsborough
Copy link
Copy Markdown
Contributor

Symptom

Calling nb__briefing from chat returns one of "Briefing retrieved from cache.", "Briefing (refreshing in background).", or "Briefing generated." — with no briefing body, including with force_refresh: true. The dashboard renders the briefing fine.

Root cause

nb__briefing's ok() helper put the entire BriefingOutput in structuredContent and only the status note in content (src/tools/core-source.ts). The engine feeds tool results back to the model via extractTextForModel(finalResult.content) (src/engine/engine.ts:843), which reads only content text blocks and never structuredContent (src/engine/content-helpers.ts:100). So a chat caller (the model) saw only the note. The dashboard reads structuredContent directly, so it was unaffected.

nb__briefing is genuinely model-facing — no ai.nimblebrain/internal annotation, and its description tells the model it "Returns a summary of recent activity, upcoming items, and anything needing attention." It must therefore carry the human-readable summary in content, per the platform-tool contract (src/tools/platform/CLAUDE.md §2.1: content = human summary, structuredContent = typed/UI payload).

Longstanding behavior (dates to the briefing tool's origin), not a recent regression.

Fix

Add a pure renderBriefingText(briefing) helper (src/services/briefing-render.ts) that renders greeting + lede + sections grouped by category, and have ok() set content to ${note}\n\n${rendered}. structuredContent is unchanged, so the dashboard is unaffected. Fixes all three branches (cache / stale / generated).

Category and field names anchor on the generator's actual output schema (categoryrecent/upcoming/attention, field type) from src/tools/platform/schemas/home.ts and src/services/briefing-generator.tsnot the stale names in the inline dashboard script (see note below).

Tests

test/unit/services/briefing-render.test.ts (5 cases): body text reaches the output, greeting/lede included, sections grouped under the correct schema-category labels in order, empty categories omit headings, quiet briefing renders without headings. The category-name test specifically guards the silent-drop failure mode (a renderer keyed on stale names would emit zero sections).

bun run verify:static passes; all briefing unit tests pass.

Follow-up (not in this PR)

The inline dashboard resource script src/tools/core-resources/scripts/home-briefing-inline.ts uses stale category names (needs_attention/coming_up) and a non-existent field (item.sentiment) — it would render zero sections against real output. The primary React dashboard (src/bundles/home/ui/src/App.tsx) uses the correct names and is unaffected. Worth a separate issue/PR to align the inline script (and ideally share this PR's category-order source of truth).

nb__briefing put the full BriefingOutput only in structuredContent and a
short status note in content. The engine feeds extractTextForModel(content)
back to the model and never reads structuredContent, so a chat caller saw
only "Briefing generated." with no body. The dashboard reads
structuredContent directly and was unaffected.

Render the briefing (greeting, lede, sections grouped by category) into
content alongside the note, per the platform-tool contract (content =
human-readable summary, structuredContent = typed payload). Fixes all three
branches (cache / stale / generated). Category and field names anchor on the
generator's output schema (recent/upcoming/attention, type).
@mgoldsborough mgoldsborough added the qa-reviewed QA review completed with no critical issues label Jun 3, 2026
@mgoldsborough mgoldsborough merged commit 48f0e74 into main Jun 3, 2026
5 checks passed
@mgoldsborough mgoldsborough deleted the fix/briefing-model-body branch June 3, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa-reviewed QA review completed with no critical issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant