Handle native structured-format incompatibility and preserve failure evidence
This commit is contained in:
@@ -52,11 +52,31 @@ func TestStableNativeSessionContractLive(t *testing.T) {
|
||||
if len(session.Permission) != 3 || session.Permission[2]["permission"] != "bash" {
|
||||
t.Fatal("scoped native permission contract not retained", string(data))
|
||||
}
|
||||
// Validate the real native JSON-schema request without provider inference.
|
||||
_, err = c.Native(ctx, "post", "/session/"+result.Data.ID+"/message", map[string]any{"noReply": true, "format": map[string]any{"type": "json_schema", "retryCount": 0, "schema": map[string]any{"type": "object", "required": []string{"outcome", "output"}, "additionalProperties": false, "properties": map[string]any{"outcome": map[string]any{"type": "string", "enum": []string{"success", "error"}}, "output": map[string]any{"type": "object"}}}}, "parts": []map[string]string{{"type": "text", "text": "No inference; validate structured format."}}})
|
||||
// Validate the complete POST -> retained GET contract, not merely POST
|
||||
// acceptance. The probe itself never runs a model or tools.
|
||||
format, _ := json.Marshal(map[string]any{"type": "json_schema", "retryCount": 0, "schema": map[string]any{"type": "object", "required": []string{"outcome", "output"}, "additionalProperties": false, "properties": map[string]any{"outcome": map[string]any{"type": "string", "enum": []string{"success", "error"}}, "output": map[string]any{"type": "object", "additionalProperties": true}}}})
|
||||
supported, err := c.supportsFormat(ctx, format)
|
||||
if err != nil {
|
||||
t.Fatal("native format capability probe failed", err)
|
||||
}
|
||||
payload := map[string]any{"noReply": true, "parts": []map[string]string{{"type": "text", "text": "No inference; validate retained message readback."}}}
|
||||
if supported {
|
||||
payload["format"] = json.RawMessage(format)
|
||||
}
|
||||
_, err = c.Native(ctx, "post", "/session/"+result.Data.ID+"/message", payload)
|
||||
if err != nil {
|
||||
t.Fatal("native schema request rejected", err)
|
||||
}
|
||||
if _, err = c.Native(ctx, "get", "/session/"+result.Data.ID+"/message", nil); err != nil {
|
||||
t.Fatal("effective format breaks retained-message readback", err)
|
||||
}
|
||||
t.Logf("schema mode supported: %v; retained compatibility probe: %s", supported, c.FormatProbe.SessionID)
|
||||
if !supported {
|
||||
recovered, exportErr := c.Messages(ctx, c.FormatProbe.SessionID)
|
||||
if exportErr != nil || !json.Valid(recovered) || c.MessageReadbackDiagnostic == "" {
|
||||
t.Fatal("cannot recover old format-bearing messages via read-only export", exportErr, string(recovered))
|
||||
}
|
||||
}
|
||||
ref, err := c.Reference()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user