agentleFS
AWSKnown publisherawslabs/social-messaging-agent-runtime-toolkit/recipes/generate-image/AGENTS.md

social-messaging-agent-runtime-toolkit / generate-image

AGENTS.md4 starsChanged 8 days agoApache-2.0View on GitHub

AI-optimized wiring guide. Goal: generate an image from text and send it via WhatsApp. 1. Import generate_image from the copied tool module into src/tools/__init__.py. 2. Define a Strands tool (e.g. generate_image_tool) with @tool(context=True). 3. await generate_image(prompt) (it is async). If the result has "error", raise ValueError(result["error"]). 4. Send the image with the payload wrapper (required — notify.send_message reads message["payload"]). Use image_id when present, else the presigned-URL fallback: image = {"id": result["image_id"]} if "image_id" in result else {"link": result["image_url"]} then await…

The file

We split this AGENTS.md into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Import generate_image from the copied tool module into src/tools/__init__.py.

    line 14
  2. Very specific:

    Run inside socialagent_notify_context() so the outbound image is queued and drained by the webhook after the turn.

    line 19

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — generate-image recipe

AI-optimized wiring guide. Goal: generate an image from text and send it via WhatsApp.

Files copied by socialagent recipe add generate-image

SourceDestinationPurpose
tool.pysrc/tools/generate_image.pygenerate_image(prompt, width, height) → Bedrock SD 3.5 (IMAGE_MODEL_REGION, default us-west-2) → S3 → WhatsApp media id
skill.mdsrc/skills/generate_image.mdAgent guidance on when/how to generate images

Wiring steps

  1. Import generate_image from the copied tool module into src/tools/__init__.py.
  2. Define a Strands tool (e.g. generate_image_tool) with @tool(context=True).
  3. await generate_image(prompt) (it is async). If the result has "error", raise ValueError(result["error"]).
  4. Send the image with the payload wrapper (required — notify.send_message reads message["payload"]). Use image_id when present, else the presigned-URL fallback: image = {"id": result["image_id"]} if "image_id" in result else {"link": result["image_url"]} then await notify.send_message(phone, {"type": "image", "payload": {"image": image}}) using tool_context.invocation_state.get("phone", "").
  5. Run inside socialagent_notify_context() so the outbound image is queued and drained by the webhook after the turn.

Required env vars

VariableRequiredPurpose
MEDIA_BUCKETyesS3 bucket for the JPEG (falls back to CONVERSATION_LOGS_BUCKET)
IMAGE_MODEL_REGIONnoRegion of the Bedrock call (default us-west-2; empty counts as unset). Set under agent.environment in socialagent.<env>.yaml; the model must be available there
AWS_REGIONnoRegion for the S3 client (default us-east-1); Bedrock uses IMAGE_MODEL_REGION
MEDIA_PREFIXnoOptional key prefix: <prefix>/images/<uuid>.jpg

Required IAM actions

Agent runtime needs:

  • bedrock:InvokeModel (Stability SD 3.5 in IMAGE_MODEL_REGION, default us-west-2). The stack's runtime role already allows foundation models in every Region, so another Region needs no IAM change
  • s3:PutObject (on MEDIA_BUCKET)
  • s3:GetObject (only for the presigned-URL fallback)

The S3 → WhatsApp upload runs in the notification Lambda via notify.upload_media, so the agent runtime needs no socialmessaging permission (only src/socialagent/providers/eum_social.py, inside the notification Lambda, calls socialmessaging).

Notes

  • Bedrock model stability.sd3-5-large-v1:0 is not offered in every Region, so the tool calls it in IMAGE_MODEL_REGION (read at call time; unset or empty means us-west-2), regardless of AWS_REGION. It calls the model ID directly, not an inference profile, so the request stays in that Region; a Region without the model makes the call fail.
  • socialagent recipe add never overwrites, so a project copy taken before IMAGE_MODEL_REGION existed ignores it and still calls us-west-2.
  • Generation takes ~5–15 seconds; the skill instructs the agent to tell the user it is generating.
  • In dev mode (socialagent dev), generate_image skips Bedrock/S3 and returns {"image_id": "dev-media-id"}.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.