Merge pull request #142 from CJackHwang/dev

Merge pull request #141 from CJackHwang/codex/investigate-json-leakage-in-vercel-deployment-rh84s1

Fix raw tool-call JSON leaks when feature_match mode is off
This commit is contained in:
CJACK.
2026-03-22 08:55:29 +08:00
committed by GitHub
4 changed files with 7 additions and 7 deletions

View File

@@ -128,8 +128,8 @@ func (h *Handler) handleStream(w http.ResponseWriter, r *http.Request, resp *htt
} }
created := time.Now().Unix() created := time.Now().Unix()
bufferToolContent := len(toolNames) > 0 && h.toolcallFeatureMatchEnabled() bufferToolContent := len(toolNames) > 0
emitEarlyToolDeltas := h.toolcallEarlyEmitHighConfidence() emitEarlyToolDeltas := h.toolcallFeatureMatchEnabled() && h.toolcallEarlyEmitHighConfidence()
initialType := "text" initialType := "text"
if thinkingEnabled { if thinkingEnabled {
initialType = "thinking" initialType = "thinking"

View File

@@ -146,8 +146,8 @@ func (h *Handler) handleResponsesStream(w http.ResponseWriter, r *http.Request,
if thinkingEnabled { if thinkingEnabled {
initialType = "thinking" initialType = "thinking"
} }
bufferToolContent := len(toolNames) > 0 && h.toolcallFeatureMatchEnabled() bufferToolContent := len(toolNames) > 0
emitEarlyToolDeltas := h.toolcallEarlyEmitHighConfidence() emitEarlyToolDeltas := h.toolcallFeatureMatchEnabled() && h.toolcallEarlyEmitHighConfidence()
streamRuntime := newResponsesStreamRuntime( streamRuntime := newResponsesStreamRuntime(
w, w,

View File

@@ -10,10 +10,10 @@ function resolveToolcallPolicy(prepBody, payloadTools) {
const preparedToolNames = normalizePreparedToolNames(prepBody && prepBody.tool_names); const preparedToolNames = normalizePreparedToolNames(prepBody && prepBody.tool_names);
const toolNames = preparedToolNames.length > 0 ? preparedToolNames : extractToolNames(payloadTools); const toolNames = preparedToolNames.length > 0 ? preparedToolNames : extractToolNames(payloadTools);
const featureMatchEnabled = boolDefaultTrue(prepBody && prepBody.toolcall_feature_match); const featureMatchEnabled = boolDefaultTrue(prepBody && prepBody.toolcall_feature_match);
const emitEarlyToolDeltas = boolDefaultTrue(prepBody && prepBody.toolcall_early_emit_high); const emitEarlyToolDeltas = featureMatchEnabled && boolDefaultTrue(prepBody && prepBody.toolcall_early_emit_high);
return { return {
toolNames, toolNames,
toolSieveEnabled: toolNames.length > 0 && featureMatchEnabled, toolSieveEnabled: toolNames.length > 0,
emitEarlyToolDeltas, emitEarlyToolDeltas,
}; };
} }

View File

@@ -44,7 +44,7 @@ test('resolveToolcallPolicy respects prepare flags and prepared tool names', ()
[{ type: 'function', function: { name: 'fallback_tool', parameters: { type: 'object' } } }], [{ type: 'function', function: { name: 'fallback_tool', parameters: { type: 'object' } } }],
); );
assert.deepEqual(policy.toolNames, ['prepped_tool']); assert.deepEqual(policy.toolNames, ['prepped_tool']);
assert.equal(policy.toolSieveEnabled, false); assert.equal(policy.toolSieveEnabled, true);
assert.equal(policy.emitEarlyToolDeltas, false); assert.equal(policy.emitEarlyToolDeltas, false);
}); });