dropthejase tightens the document-editing toolchain

A round of fixes makes Mike's document-edit agent more honest about what it did, what broke, and where the citations actually point.

draftingworkflow

When an AI agent edits a contract or generates a Word doc, the lawyer needs to trust two things: that the citation in the chat actually maps to the right document, and that when something goes wrong, the error message says something useful. dropthejase has been shoring up both. Citations now resolve all the way back to specific document IDs instead of brittle position references, and when a tool fails, the actual error reaches the user rather than a generic shrug.

There's also a quieter piece: every tool now emits structured error logs, the kind a legal-ops team can actually pipe into monitoring. The download cards for generated documents render properly again, and the edit tools are now aware of the broader workflow context they're operating inside.

So what Worth a look for anyone running agent-based document workflows where a wrong citation or a swallowed error is the difference between trust and a rewrite.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

8 commits from dropthejase/louis, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
efb0290f fix(agent): populate change_id, del_id, ins_id in document_edits INSERT Jason Lee 2026-05-12 ↗ GitHub
a1cef7a5 feat(agents): add structured JSON error logging to all tools Jason Lee 2026-05-12 ↗ GitHub
Add logger.ts helper to both main and tabular agents. Wraps console.log/error
with JSON output (level, tool, message, error, stack). All tool callbacks now
catch exceptions and log full stack traces to CloudWatch via stderr.
3f614333 fix: annotation status field and download URL in edit_document tool Jason Lee 2026-05-12 ↗ GitHub
commit body
- Add status: 'pending' to annotation payload so EditCard does not
  immediately resolve and disable Accept/Reject/View buttons
- Replace presigned S3 URL with backend-relative path for download_url
  so DocDownloadBlock isSafeHref check passes
- Remove unused getPresignedUrl import
- Add TEMP_TASKS.md to .gitignore
- Note tool spinner parity item in FEATURE-PARITY.md
0cbbf5ed fix(agents,frontend): fix generate_docx download card not showing Jason Lee 2026-05-13 ↗ GitHub
commit body
- Fix source constraint: 'assistant_generated' -> 'generated' to match
  document_versions_source_check constraint
- Fix doc_created_start filename mismatch: sanitize title to match the
  filename the tool returns so frontend updateMatchingEvent finds a match
- Fix DocDownloadBlock: open presigned S3 URLs directly instead of
  rejecting them via isSafeHref check
c85201fd fix(citations): resolve document UUIDs in agent citations end-to-end Jason Lee 2026-05-13 ↗ GitHub
commit body
- Agent outputs real document_id/version_id UUIDs in <CITATIONS> block sourced from <document_metadata> appended to read_document output
- DocStore extended with document_id + version_id so read_document can append metadata
- extractAnnotations parses document_id directly, validates UUID format, cross-checks against known doc set, drops and warns invalid entries
- <CITATIONS> block suppressed from SSE stream - never shown in chat UI
- History reload extractCitationsFromText validates UUID format on parse
- System prompt updated: citations use document_id/version_id/filename fields; doc-N labels banned from <CITATIONS>
833bb5d3 fix(agents): surface err.message in tool error returns Jason Lee 2026-05-13 ↗ GitHub
c05081b4 fix(agent): use source doc filename for doc_replicated SSE to match doc_replicate_start Jason Lee 2026-05-13 ↗ GitHub
b06b54ef fix(agent): wire workflow marker and attached documents to AgentCore Jason Lee 2026-05-15 ↗ GitHub
commit body
Three bugs prevented workflows and doc selection from working:
1. useAssistantChat never prepended [Workflow: title (id)] marker to prompt
2. DisplayWorkflowModal never set workflow field on the outgoing message
3. agents/index.ts never read attached_documents from request body

Agent system prompt + read_workflow/list_workflows tools were already
correct - only the triggers were missing.

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-347.md from inside the repo you want the changes in.

⬇ Download capture-thread-347.md