Files
docker-agent/pkg/runtime/image_generation_intent.go
T
Arnaud Héritier 104caf4a54 feat(#3996): materialize generated media with no-resend history
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.
2026-09-10 10:17:07 +02:00

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)
}