mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 10:02:15 +00:00
Save accumulated media into the owning session's workspace, resolving parent-session WorkingDir provenance. Persist owner-qualified workspace references and MIME/name/size rather than generated base64 in session JSON. Use generic naming fallback for refused provider names and per-item warnings when no workspace/save is available; there is no alternate storage target in this patch. Exempt media-bearing results from the empty-response error. Replace saved generated parts in ordinary later provider turns with bounded metadata placeholders and avoid counting mirrored text twice in compaction. If all saves in a media-only reply fail, an empty assistant record may remain alongside warnings; successful siblings and reply text are retained. At a text-only stop, match phrases in the last user prompt for a nonfatal missing-image notice. A terminal error skips this branch; current-agent structured-output config suppresses it, but arbitrary per-call overrides and reply content are not classified. Negated/question/context phrases can match, capability is unchecked, and continuations are not tracked as one submission. Characterization tests pin those limits. Use mockRuntime.events for the independent CLI text-before-warning test, not a later helper.
34 lines
973 B
Go
34 lines
973 B
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
"github.com/docker/docker-agent/pkg/runtime"
|
|
"github.com/docker/docker-agent/pkg/session"
|
|
)
|
|
|
|
func TestImageGenerationWarningPreservesTextAndPrintsAfterIt(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
const warning = "The model returned text but no image for this image-generation request. Try rephrasing the request."
|
|
rt := &mockRuntime{
|
|
events: []runtime.Event{
|
|
runtime.AgentChoice("test", "sess", "Here's an image of Docker and its friends."),
|
|
runtime.Warning(warning, "test"),
|
|
},
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
err := Run(t.Context(), NewPrinter(&buf), Config{}, rt, session.New(), []string{"draw an image"})
|
|
assert.NilError(t, err)
|
|
|
|
output := buf.String()
|
|
assert.Check(t, strings.Contains(output, "Here's an image of Docker and its friends."))
|
|
assert.Check(t, strings.Contains(output, warning))
|
|
assert.Check(t, strings.Index(output, "Here's an image") < strings.Index(output, warning))
|
|
}
|