mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-26 22:04:46 -06:00
c578051cb8
* feat: tool result advisory system with user message queuing General-purpose advisory injection for tool results — when advisories are present, tool output is wrapped in <tool_output> tags with <system-reminder> blocks appended. Two initial producers: - Output guard advisories: model sees why content was flagged/redacted - User message interjections: users can queue messages mid-execution via the web UI, injected at the next tool-call seam Queued messages use !!! prefix for important priority. Advisory injection is gated by ModelCapabilities.supports_tool_advisories (default true for commercial models, false for local/vLLM). On cancel/error, queued messages are flushed as regular user messages so nothing is silently lost. Raw tool output (pre-wrap) is persisted to the DB to keep history clean of ephemeral advisory XML. * fix: frontend UX for queued messages — rollback, discoverability, a11y - Send button changes to "Queue" (outline style) during busy state, visually distinct from filled red Stop button - Placeholder updates to hint at !!! priority convention - addQueuedMessage returns element ref for optimistic UI rollback - Remove queued element on queue_full, busy, or connection error - Add role="status" and aria-label to queued message elements - Promote queued messages to normal appearance when generation ends * feat: queued message removal via dismiss button Switch backing store from queue.Queue to OrderedDict + Lock for O(1) removal by ID. Each queued message gets a UUID, returned to the frontend and stored as data-msg-id on the DOM element. Dismiss button (x) on queued messages calls DELETE /v1/api/send with the msg_id. If the message was already injected (race), server returns not_found and the UI removes the element anyway. No new endpoint — DELETE method added to the existing /v1/api/send route. dequeue_message() on ChatSession is O(1) under the lock. * fix: address PR review — escaping, types, list output, message cap - Escape </tool_output> and <system-reminder> in tool output to prevent wrapper tag injection from untrusted tool results - Change _collect_advisories return type from list[Any] to list[ToolAdvisory] - Drain queued messages on list/structured output (append as text part) so they aren't silently stuck until a str result appears - Cap queued message length at 2000 chars to prevent context bloat - Remove unused var in _dequeueMessage