Skip to content

Commit 9c72fef

Browse files
docs: document ASCII-safe JSON contract for rewritten turn metadata
1 parent 6806c5b commit 9c72fef

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/codex/forward-transport-headers.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ export function deriveCodexAccountInstallationId(chatgptAccountId: string, _call
2626
return codexInstallationIdForAccount(chatgptAccountId);
2727
}
2828

29+
/**
30+
* Rewrites the `installation_id` inside Codex turn metadata while preserving all other fields.
31+
*
32+
* Structure contract: the returned JSON is ASCII-safe — every non-ASCII code unit is
33+
* escaped as `\\uXXXX`. Both consumers of rewritten turn metadata (the
34+
* `x-codex-turn-metadata` HTTP header and the embedded `client_metadata` value)
35+
* receive this ASCII-safe form, so header setters never see literal Unicode.
36+
*/
2937
export function rewriteTurnMetadataInstallationId(rawMetadata: string, chatgptAccountId: string): string {
3038
if (!chatgptAccountId.trim()) throw new CodexInstallationIdUnavailableError();
3139
// A size bound must refuse the Pool send, never bypass identity projection.

0 commit comments

Comments
 (0)