Handle native structured-format incompatibility and preserve failure evidence
This commit is contained in:
@@ -32,6 +32,12 @@ type Connection struct {
|
||||
done chan error
|
||||
models map[string]map[string]string
|
||||
responses map[string][]byte
|
||||
formatChecked bool
|
||||
formatSupported bool
|
||||
FormatProbe *FormatProbe
|
||||
LastHTTPStatus int
|
||||
LastHTTPOperation string
|
||||
MessageReadbackDiagnostic string
|
||||
}
|
||||
|
||||
// Reference records only our ephemeral loopback service credentials, never provider auth.
|
||||
@@ -210,6 +216,8 @@ func (c *Connection) Close() {
|
||||
}
|
||||
|
||||
func (c *Connection) Native(ctx context.Context, method, path string, body any) ([]byte, error) {
|
||||
c.LastHTTPStatus = 0
|
||||
c.LastHTTPOperation = strings.ToUpper(method) + " " + path
|
||||
u, err := url.Parse(c.URL + path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -241,6 +249,7 @@ func (c *Connection) Native(ctx context.Context, method, path string, body any)
|
||||
return nil, fmt.Errorf("OpenCode native API request failed")
|
||||
}
|
||||
defer response.Body.Close()
|
||||
c.LastHTTPStatus = response.StatusCode
|
||||
if response.StatusCode < 200 || response.StatusCode >= 300 {
|
||||
// The stage adapter stores bounded, redacted failure evidence separately;
|
||||
// the public error string remains free of provider bodies and credentials.
|
||||
|
||||
Reference in New Issue
Block a user