feat(forwarder): system prompt for session chat (#418) - #430
Closed
jonathaneoliver wants to merge 1 commit into
Closed
feat(forwarder): system prompt for session chat (#418)#430jonathaneoliver wants to merge 1 commit into
jonathaneoliver wants to merge 1 commit into
Conversation
Adds the system prompt that drives all three AI session-analysis
modes (overview, forensic, compare) and a small loader that mtime-
caches it so operators can iterate live.
prompts/session_chat.md
YAML frontmatter (prompt_version, default_max_tokens,
default_temperature) + body covering:
- role / objective
- how a session is recorded (session_id ⨯ play_id, snapshot
cadence, network_requests row shape)
- schema of session_snapshots + network_requests + llm_calls
- response style — anchor to mm:ss.ms timestamps, structure
forensic answers as Observation / Mechanism / Evidence,
comparison answers as Similarities / Differences /
Hypotheses, no padding, no SQL in answers unless asked
- mode hints driven by the focus-context preamble
(Focus session_id / Focus range / Compare sessions)
- tool-use guidance — start narrow, aggregate before
materializing rows, errors-first, never SELECT *
- failure-mode language for sparse-data and stuck loops
llm_prompt.go
PromptCache.Load(path) — re-read only on mtime change so
edit-and-reload works without restart. Frontmatter parser
accepts the standard '---' delimiter style. Built-in
fallback prompt keeps /api/session_chat working when the
file is missing.
llm_session_chat.go
handleSessionChat now loads the system prompt, prepends it
as the first message (largest, prefix-cacheable), then the
focus-context preamble (small, varies per call), then the
user-supplied messages.
llm_calls.prompt_version
Now populated from the loaded prompt's frontmatter so
A/B prompt iteration correlates with response quality
over time.
Dockerfile
Copies prompts/ into /config/prompts/. Override path via
SESSION_CHAT_PROMPT_PATH env or ConfigMap mount over /config.
10 new tests (67 total): frontmatter parsing, mtime cache, builtin
fallback, on-disk load, system-prompt-actually-injected end-to-end.
Verified: go test ./... 67/67 pass; docker build clean; image
contains /config/prompts/session_chat.md.
Part of epic #412.
Closes #418.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
Owner
Author
|
Closing — superseded by the v2.0.0 release.
This stale stacked-PR chain (epic #412) has no salvageable diff against current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prompts/session_chat.md— the system prompt that drives every AI session-analysis interaction (overview, forensic, compare). Covers role, schema, tool docs, response style, mode hints, and failure-mode language.Closes #418.What's in the prompt
session_snapshots+network_requests+llm_callswith the columns analyses actually reach for.mm:ss.mstimestamps (the dashboard auto-links these to seek), structure forensic answers as Observation / Mechanism / Evidence, comparison answers as Similarities / Differences / Hypotheses, no padding, no SQL in answers unless asked.Focus session_id/Focus range/Compare sessions).Loader behaviour
SessionChatPrompt()reads/config/prompts/session_chat.md(overridable viaSESSION_CHAT_PROMPT_PATH).PromptCache.Loadre-reads only on mtime change — edit the file in production, next chat picks it up automatically./api/session_chatworking when the file is missing or malformed.---delimiters; missing or unversioned frontmatter logsunversionedinto the ledger.Ledger correlation
llm_calls.prompt_versionnow carries the version from the loaded prompt's frontmatter, so A/B iterations on the prompt correlate with response quality (e.g. cost per turn, average iterations, error rate) over time.Test plan
go test ./...67/67 pass.docker buildclean; image contains/config/prompts/session_chat.md(8.5 KB).TestSessionChat_InjectsSystemPrompt— uses a unique marker string to verify the on-disk prompt body actually reaches the LLM as the first message.PromptCachecovers: re-read on mtime change, hit cache when unchanged, missing-file fallback to builtin.🤖 Generated with Claude Code