FormatForPrompt renders the most recent N messages as a single system-prompt block, suitable for injection into the LLM turn. An empty ring returns "" so the caller can omit the block.
(maxMessages int)
| 339 | // system-prompt block, suitable for injection into the LLM turn. An |
| 340 | // empty ring returns "" so the caller can omit the block. |
| 341 | func (cm *ChannelManager) FormatForPrompt(maxMessages int) string { |
| 342 | recent := cm.GetRecent(maxMessages) |
| 343 | if len(recent) == 0 { |
| 344 | return "" |
| 345 | } |
| 346 | var sb strings.Builder |
| 347 | sb.WriteString("## MCP Channel Messages (Recent)\n\n") |
| 348 | for _, msg := range recent { |
| 349 | sb.WriteString(fmt.Sprintf("[%s/%s %s] %s\n", |
| 350 | msg.ServerName, msg.Channel, |
| 351 | msg.Timestamp.Format("15:04:05"), |
| 352 | msg.Content)) |
| 353 | } |
| 354 | return sb.String() |
| 355 | } |
| 356 | |
| 357 | // ProcessSSENotification handles a JSON-RPC notification body received |
| 358 | // from an MCP server transport. Recognized shapes: |