diff --git a/config/prompt_templates/agent_system_prompt.yaml b/config/prompt_templates/agent_system_prompt.yaml index 7926267..6cb043a 100644 --- a/config/prompt_templates/agent_system_prompt.yaml +++ b/config/prompt_templates/agent_system_prompt.yaml @@ -98,7 +98,7 @@ templates: You are Academy SIP Translator, specialized in translating Chinese engineering Excel workbooks (SIP standard inspection procedures, SOP standard operating procedures, rack/enclosure manufacturing documents) into English. Workflow: - When the user uploads a .xlsx workbook, call xlsx_translate: pass file_path set to the uploaded file's absolute sandbox path from when that section is present, otherwise pass attachment_name set to the uploaded file's name. Never ask the user to re-upload or to run any manual steps. - - After the tool returns, summarize the verification report for the user in their language: how many text units were translated, glossary hits, residual Chinese count, and the number/part integrity result. The translated workbook _EN.xlsx is delivered automatically as a file card on this reply (and filed in the conversation artifact library) — tell the user to click that card to view details and download it. NEVER print raw API paths or URLs; always refer to the file by its name and the card on the reply. + - After the tool returns, summarize the verification report for the user in their language: how many text units were translated, glossary hits, residual Chinese count, and the number/part integrity result. The translated workbook _EN.xlsx is delivered automatically as a clickable file link in the tool result (and filed in the conversation artifact library). Include that exact markdown link in your answer unchanged, so the user can click the file name to view details and download it. NEVER print raw API paths or URLs. - If residual Chinese or integrity mismatches are reported, list the affected samples and recommend manual review of those entries; do not claim the deliverable is 100% complete when the report says otherwise. - If the tool reports an error (unsupported format, size limit, workspace unavailable), explain the exact cause and the fix (for example: re-save legacy .xls as .xlsx, or ask an administrator to enable the session workspace). - Answer short questions about the translation approach (terminology control, placeholder protection for part numbers and tolerances, structure preservation) without calling tools; the translation itself always goes through xlsx_translate. diff --git a/internal/agent/tools/xlsx_translate.go b/internal/agent/tools/xlsx_translate.go index 13e55a0..e904218 100644 --- a/internal/agent/tools/xlsx_translate.go +++ b/internal/agent/tools/xlsx_translate.go @@ -206,12 +206,18 @@ func (t *XlsxTranslateTool) Execute(ctx context.Context, args json.RawMessage) ( logger.Infof(ctx, "[Tool][XlsxTranslate] session=%s file=%s -> %s units=%d residual=%d llm_calls=%d", sessionID, source, deliverable, report.TranslatedUnits, report.ResidualCJKCount, report.LLMCalls) + // The file name is written as a Markdown link whose destination is the + // canonical sandbox: spelling. The stream handler rebinds that + // destination to the artifact's stable reference (resource:// handle, or + // sandbox: without a catalog), so the file name inside the answer + // itself renders clickable — clicking opens the translated workbook. + fileLink := "[" + outName + "](sandbox:" + outName + ")" var b strings.Builder switch { case len(outputLinks) > 0: - b.WriteString("Translation finished. The English workbook **" + outName + "** is saved in the output directory (available as a downloadable artifact).\n\n") + b.WriteString("Translation finished. The English workbook " + fileLink + " is saved in the output directory (available as a downloadable artifact).\n\n") case attached: - b.WriteString("Translation finished. The English workbook **" + outName + "** is attached to this reply as a file card — open it to see details and download.\n\n") + b.WriteString("Translation finished. The English workbook " + fileLink + " is attached to this reply — click the file name or the file card to view details and download.\n\n") default: b.WriteString("Translation finished. Download the English workbook **" + outName + "** here: " + deliverable + "\n\n") } diff --git a/internal/agent/tools/xlsx_translate_test.go b/internal/agent/tools/xlsx_translate_test.go index eb7c7fd..e687b16 100644 --- a/internal/agent/tools/xlsx_translate_test.go +++ b/internal/agent/tools/xlsx_translate_test.go @@ -280,8 +280,12 @@ func TestXlsxTranslateToolWithoutSandbox(t *testing.T) { if !result.Success { t.Fatalf("tool failed: %s", result.Error) } + wantLink := "[D4-A08AR12000002-A3-SIP_EN.xlsx](sandbox:D4-A08AR12000002-A3-SIP_EN.xlsx)" + if !strings.Contains(result.Output, wantLink) { + t.Fatalf("output missing clickable file link %s: %s", wantLink, result.Output) + } if !strings.Contains(result.Output, "file card") { - t.Fatalf("output should point at the artifact card: %s", result.Output) + t.Fatalf("output should mention the file card: %s", result.Output) } msg := sink.messages["assistant-1"]