mattermost/server/channels/jobs/recap
Nick Misasi cbdf5536fd
Add structured JSON output for recap summarization (#35496)
* Add structured outputs, response sanitization, and session context for recaps

- Wrap BridgeClient to strip markdown code fencing from LLM JSON responses,
  using explicit delegation to prevent unsanitized methods from leaking
- Add JSONOutputFormat schema to SummarizePosts for structured LLM output
- Pass user session in recap worker context for session-dependent code paths
- Pre-parse min plugin version semver at package level to avoid repeated parsing
- Hoist static JSON schema to package-level var to avoid per-call allocation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix stripMarkdownCodeFencing to handle single-line fenced payloads

Address CodeRabbit feedback: the function previously returned the original
string when fenced JSON had no newline (e.g. ```json {"a":1}```), which
would break downstream JSON parsing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Handle case/spacing variants for single-line fenced language tags

Address CodeRabbit feedback: use case-insensitive comparison for the
"json" language tag and check for whitespace separator, so inputs like
```JSON {"a":1}``` are handled correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Revert BridgeClient wrapper and keep only structured output changes

Remove the BridgeClient wrapper, stripMarkdownCodeFencing, and semver
pre-parse from agents.go. The scope of this PR is limited to adding
JSONOutputFormat structured outputs for recaps and the worker session
context fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix lint: use any instead of interface{} and fix gofmt formatting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-05 19:06:05 +00:00
..
worker.go Add structured JSON output for recap summarization (#35496) 2026-03-05 19:06:05 +00:00
worker_test.go [MM-66359] Recaps MVP (#34337) 2026-01-13 11:59:22 -05:00