Handle native structured-format incompatibility and preserve failure evidence
This commit is contained in:
@@ -18,11 +18,18 @@ func TestNativeSessionModelPermissionsGenerationAndAbort(t *testing.T) {
|
||||
}
|
||||
switch r.Method + " " + r.URL.Path {
|
||||
case "POST /session":
|
||||
var raw map[string]json.RawMessage
|
||||
json.NewDecoder(r.Body).Decode(&raw)
|
||||
if strings.Contains(string(raw["title"]), "compatibility probe") {
|
||||
w.Write([]byte(`{"id":"ses_probe"}`))
|
||||
return
|
||||
}
|
||||
var body struct {
|
||||
Model map[string]string
|
||||
Permission []map[string]string
|
||||
}
|
||||
json.NewDecoder(r.Body).Decode(&body)
|
||||
data, _ := json.Marshal(raw)
|
||||
json.Unmarshal(data, &body)
|
||||
if body.Model["id"] != "model" || body.Model["providerID"] != "provider" || body.Permission[0]["action"] != "deny" || body.Permission[1]["permission"] != "bash" {
|
||||
t.Error("model or scoped permissions lost", body)
|
||||
}
|
||||
@@ -43,6 +50,18 @@ func TestNativeSessionModelPermissionsGenerationAndAbort(t *testing.T) {
|
||||
}
|
||||
prompted = true
|
||||
w.Write([]byte(`{"info":{"role":"assistant","finish":"stop","time":{"completed":1}},"parts":[{"type":"text","text":"result"}]}`))
|
||||
case "POST /session/ses_probe/message":
|
||||
var body struct {
|
||||
NoReply bool `json:"noReply"`
|
||||
Format map[string]any
|
||||
}
|
||||
json.NewDecoder(r.Body).Decode(&body)
|
||||
if !body.NoReply || body.Format["retryCount"] != float64(0) {
|
||||
t.Error("probe requested inference or retries", body)
|
||||
}
|
||||
w.Write([]byte(`{}`))
|
||||
case "GET /session/ses_probe/message":
|
||||
w.Write([]byte(`[{"info":{"role":"user"}}]`))
|
||||
case "GET /session/ses_native/message":
|
||||
w.Write([]byte(`[{"info":{"role":"assistant","finish":"stop","time":{"completed":1}},"parts":[{"type":"text","text":"result"}]}]`))
|
||||
case "POST /session/ses_native/abort":
|
||||
|
||||
Reference in New Issue
Block a user