Harden model results with lossless isolated repair and scoped permissions
This commit is contained in:
@@ -23,11 +23,12 @@ const maxModelResponse = 1 << 20
|
||||
// A fresh location-scoped session avoids unrelated user conversation history and
|
||||
// is deleted after generation. Generation is text-only: no agent tools are run.
|
||||
type OpenCodeClient struct {
|
||||
Directory string // empty uses the pipeline server's working directory
|
||||
Backend string
|
||||
Reference string
|
||||
connection *opencode.Connection
|
||||
command func(context.Context, string, ...string) ([]byte, error)
|
||||
Directory string // empty uses the pipeline server's working directory
|
||||
Backend string
|
||||
Reference string
|
||||
FormatAudit string
|
||||
connection *opencode.Connection
|
||||
command func(context.Context, string, ...string) ([]byte, error)
|
||||
}
|
||||
|
||||
type openCodeError struct {
|
||||
@@ -129,7 +130,7 @@ func (c OpenCodeClient) Generate(ctx context.Context, config ModelConfig, prompt
|
||||
}
|
||||
}
|
||||
// Fail before creating a session if the generation payload is too large.
|
||||
body := map[string]string{"prompt": prompt}
|
||||
body := generationBody("prompt", prompt, config, c.Backend)
|
||||
encoded, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -138,9 +139,10 @@ func (c OpenCodeClient) Generate(ctx context.Context, config ModelConfig, prompt
|
||||
return "", fmt.Errorf("OpenCode request exceeds 64 KiB limit")
|
||||
}
|
||||
created, err := c.call(ctx, "post", "/api/session", map[string]any{
|
||||
"title": "Pipeline stage generation",
|
||||
"location": map[string]string{"directory": directory},
|
||||
"model": map[string]string{"providerID": config.Provider, "id": config.Model},
|
||||
"title": "Pipeline stage generation",
|
||||
"location": map[string]string{"directory": directory},
|
||||
"model": map[string]string{"providerID": config.Provider, "id": config.Model},
|
||||
"permissions": []map[string]string{{"action": "*", "resource": "*", "effect": "deny"}},
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user