Agent tool hardening: annotation fields corrected, citations resolve real UUIDs, errors surface messages
Eight commits tighten the document-edit tool family: missing DB columns are populated, generate_docx download cards are fixed, citations are rewritten to carry real document UUIDs rather than chat-local labels like "doc-0", and tool errors now return the actual error message rather than a generic string.
The edit_document tool had been INSERTing into document_edits without change_id, del_w_id, or ins_w_id. Those come from the applyTrackedEdits return value - specifically appliedChanges[i].id, .delId, and .insId. efb0290 wires that return value and adds context_before and context_after to the INSERT. The annotation payload sent in the SSE stream now also carries status: 'pending', which EditCard in the frontend requires to render correctly.
The download URL from edit_document was a presigned S3 URL (15-min TTL). 3f61433 changes it to a backend-relative path /single-documents/{docId}/docx?version_id={versionId}, which is more stable and routes through the existing auth middleware.
generate_docx had a DB INSERT using source: 'assistant_generated' against a column that only accepts 'generated', silently failing. 0cbbf5e fixes the value and also adds a doc_created_start SSE event with a sanitized filename so the streaming tool spinner shows something useful.
The citation UUID rewrite (c85201f) is the structural change. The extractAnnotations parser is updated to expect document_id (a real UUID) rather than doc_id (a chat-local label). The agent's system prompt instructs it to output UUIDs sourced from list_documents output. A UUID regex validates each citation and drops malformed ones. A tail-buffer is added to the SSE stream to suppress the <CITATIONS> block from reaching the frontend as visible text.
A logger.ts helper adding logInfo/logError functions that emit structured JSON lands across all tools, giving CloudWatch a consistent shape to query.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?