refactor(open-sse): dedup fallback tool_call id helper (B3)

Add fallbackToolCallId() and apply to kiro/ollama/openai-responses response
translators (identical id shape). Leave commandcode (different order) and
request-side gemini/antigravity (random suffix) untouched. Golden + gate clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
decoluaandCursor committed 2026-06-13 18:12:40 +07:00
1 parent f4c39042a0
commit 997860aa1f
5 files changed
+12 -4

No files matched your search

@@ -3,6 +3,11 @@
// Anthropic tool_use.id must match: ^[a-zA-Z0-9_-]+$
const TOOL_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
// Fallback streaming tool_call id when provider omits one (index optional)
export function fallbackToolCallId(index) {
return index === undefined ? `call_${Date.now()}` : `call_${index}_${Date.now()}`;
}
// Generate deterministic tool call ID from position + tool name (cache-friendly)
export function generateToolCallId(msgIndex = 0, tcIndex = 0, toolName = "") {
const name = toolName ? `_${toolName.replace(/[^a-zA-Z0-9_-]/g, "")}` : "";