append_feedback_context
Append user's additional context to a thumbs-up or thumbs-down feedback session for improving agent behavior.
Instructions
Append a follow-up message to an open feedback session. Call this when the user types additional context after giving thumbs up/down.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ||
| message | Yes | The follow-up message from the user | |
| role | No | user |
Implementation Reference
- scripts/feedback-session.js:83-108 (handler)The actual implementation of appendFeedbackContext. It appends a follow-up message to an open feedback session, capping the message at 1000 characters and enforcing a max of 20 messages per session.
function appendToSession(sessionId, message, role = 'user') { const session = activeSessions.get(sessionId); if (!session) { return { status: 'not_found', message: `No active session: ${sessionId}` }; } if (session.status !== 'open') { return { status: 'closed', message: `Session already finalized at ${session.finalizedAt}` }; } if (session.followUpMessages.length >= MAX_FOLLOWUP_MESSAGES) { return { status: 'full', message: `Session has reached max ${MAX_FOLLOWUP_MESSAGES} messages` }; } session.followUpMessages.push({ role, content: (message || '').slice(0, 1000), // Cap per-message timestamp: new Date().toISOString(), }); resetSessionTimer(sessionId, session); return { status: 'appended', messageCount: session.followUpMessages.length, sessionId, }; } - adapters/mcp/server-stdio.js:213-217 (registration)Import/alias registration: appendFeedbackContext is the alias for appendToSession from scripts/feedback-session.js.
const { openSession: openFeedbackSession, appendToSession: appendFeedbackContext, finalizeSession: finalizeFeedbackSession, } = require('../../scripts/feedback-session'); - adapters/mcp/server-stdio.js:1071-1075 (handler)MCP handler dispatch: when tool name is 'append_feedback_context', calls appendFeedbackContext(args.sessionId, args.message, args.role).
case 'open_feedback_session': return toTextResult(openFeedbackSession(args.feedbackEventId, args.signal, args.initialContext)); case 'append_feedback_context': return toTextResult(appendFeedbackContext(args.sessionId, args.message, args.role)); case 'finalize_feedback_session': - scripts/feedback-session.js:322-335 (schema)Module exports showing appendToSession is the exported name of the function bound to appendFeedbackContext.
module.exports = { openSession, appendToSession, finalizeSession, getSession, getActiveSession, extractComplaints, autoInferLesson, SESSION_TIMEOUT_MS, MAX_FOLLOWUP_MESSAGES, scheduleTimer, // For testing _activeSessions: activeSessions, };