Skip to content

feat: enforce max constraints on image generation limits#86

Open
iconben wants to merge 3 commits intomainfrom
feature/generation-limits-7463793138972359175
Open

feat: enforce max constraints on image generation limits#86
iconben wants to merge 3 commits intomainfrom
feature/generation-limits-7463793138972359175

Conversation

@iconben
Copy link
Copy Markdown
Owner

@iconben iconben commented Apr 5, 2026

Fixes an issue where unbounded height, width, and step parameters could lead to runaway resource utilization.

  • max_steps, max_width, and max_height are stored in config file
  • Exposed via CLI zimg info and web UI /info endpoints
  • Enforced at CLI layer, Web API layer, and MCP Server schema validation layer

PR created automatically by Jules for task 7463793138972359175 started by @iconben

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@AgentSeal AgentSeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, solid defense-in-depth across all three layers (CLI, Web API, MCP). Two small things we noticed:

  1. CLI height check missing sys.exit(1) -- in cli.py, the steps and width checks both call sys.exit(1) after log_error, but the height check just falls through:
if args.height > max_height:
    log_error(f"Requested height ({args.height}) exceeds the maximum allowed ({max_height}).")
    # missing sys.exit(1) here
  1. MCP schema-level enforcement -- the Field() annotations add descriptions but no le= constraint. Adding le=4096 (or le=max_steps/max_width/max_height) would let MCP hosts reject invalid values at the schema validation layer before the tool handler runs:
steps: int = Field(default=9, le=50, description="Number of inference steps")
width: int = Field(default=1280, le=4096, description="Image width in pixels")
height: int = Field(default=720, le=4096, description="Image height in pixels")

Not a blocker since the server-side ValueError catches it, but schema-level enforcement is the strongest signal to agents and hosts.

Everything else looks good. Will rescan once this lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security scan results for z-image-studio - 92.1/100

2 participants