MCPcopy Index your code
hub / github.com/coder/coder / sanitizeWorkspaceAgentContextFileContent

Function sanitizeWorkspaceAgentContextFileContent

coderd/workspaceagents.go:2438–2448  ·  view source on GitHub ↗

sanitizeWorkspaceAgentContextFileContent applies prompt sanitization, then enforces the 64KiB per-file budget. The truncated flag is preserved when the caller already capped the file before sending it.

(
	content string,
	truncated bool,
)

Source from the content-addressed store, hash-verified

2436// truncated flag is preserved when the caller already capped the
2437// file before sending it.
2438func sanitizeWorkspaceAgentContextFileContent(
2439 content string,
2440 truncated bool,
2441) (string, bool) {
2442 content = chatd.SanitizePromptText(content)
2443 if len(content) > maxChatContextFileBytes {
2444 content = content[:maxChatContextFileBytes]
2445 truncated = true
2446 }
2447 return content, truncated
2448}
2449
2450// readChatContextBody reads and validates the request body for chat
2451// context endpoints. It handles MaxBytesReader wrapping, error

Callers 1

Calls 1

SanitizePromptTextFunction · 0.92

Tested by

no test coverage detected