fix(ai): soft LLM transport errors and strip ext/ai json glue
Host/plugin HTTP failures return structured finish|status=error instead of aborting the VM; agent/llm/openai/智能体 result maps use GFM tables and table.put. SKILL gains positive copy-paste examples so agents stop mirroring legacy json.set chains. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c44ea38ae2
commit
1908bf1a53
12 files changed
+813
-327
No files matched your search
+17
-3
@@ -152,8 +152,13 @@ pub fn http_post(
|
||||
Some(v) => as_text(v, "content_type")?,
|
||||
};
|
||||
let hdrs = headers_from_value(headers)?;
|
||||
let (status, resp) = http_exchange("POST", url, Some(body), Some(ct), &hdrs)?;
|
||||
Ok(response_map(status, resp))
|
||||
// Transport failures → status 0 + body message (soft). Callers that need
|
||||
// hard errors can still treat status!=200 as failure; Agent/LLM surfaces
|
||||
// map this into structured `{finish:error}` instead of aborting the VM.
|
||||
match http_exchange("POST", url, Some(body), Some(ct), &hdrs) {
|
||||
Ok((status, resp)) => Ok(response_map(status, resp)),
|
||||
Err(e) => Ok(response_map(0, e)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Generic request: method + url + optional body / content_type / headers.
|
||||
@@ -847,7 +852,16 @@ pub fn http_post_sse(
|
||||
),
|
||||
]))
|
||||
}
|
||||
Err(e) => Err(format!("http POST sse {url}: {e}")),
|
||||
Err(e) => Ok(Value::Map(vec![
|
||||
("status".into(), Value::Int(0)),
|
||||
(
|
||||
"events".into(),
|
||||
Value::List(vec![event_map(vec![
|
||||
("type", Value::Text("error".into())),
|
||||
("message", Value::Text(format!("http POST sse {url}: {e}"))),
|
||||
])]),
|
||||
),
|
||||
])),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user