mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 18:30:09 +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.
17 lines
683 B
Go
17 lines
683 B
Go
package runtime
|
|
|
|
import "regexp"
|
|
|
|
const missingGeneratedImageWarning = "The model returned text but no image for this image-generation request. Try rephrasing the request."
|
|
|
|
var imageGenerationIntentRE = regexp.MustCompile(
|
|
`(?i)\b(?:re)?(?:generate|create|make|draw|render|produce)\s+(?:an?\s+|the\s+)?` +
|
|
`(?:image|picture|photo|banner|logo|icon|graphic|drawing|illustration|thumbnail|sticker|avatar|gif)\b`,
|
|
)
|
|
|
|
// This phrase heuristic does not resolve negation or conversational context;
|
|
// the caller does not track capability or submission-wide continuations.
|
|
func hasExplicitImageGenerationIntent(prompt string) bool {
|
|
return imageGenerationIntentRE.MatchString(prompt)
|
|
}
|