Skip to content

feat(image_edit): add mask parameter for selective image editing - #1008

Merged
edenreich merged 7 commits into
mainfrom
fix/issue-988
Aug 4, 2026
Merged

edenreich merged 7 commits into
mainfrom
fix/issue-988

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #988

Summary

Adds a mask parameter to the ImageEdit tool, allowing users to specify a PNG mask file whose transparent (alpha=0) areas mark the editable region. All non-transparent pixels are preserved exactly during the edit operation.

Changes

  • feat(image_edit): Add mask parameter to ImageEdit tool definition, validation, and execution
  • feat(domain): Update ImageService.EditImage interface to accept a maskPath parameter
  • feat(services): Implement mask handling in ImageService.EditImage - reads, decodes, and attaches the mask to the API request
  • test: Update fake/mock and test files to match the new EditImage signature

How it works

  1. The ImageEdit tool now accepts an optional mask string parameter (a local PNG file path)
  2. Validation ensures the mask is a valid PNG file when provided
  3. The service reads the mask file, base64-decodes it, and attaches it to the SDK's CreateImageEdit request as the Mask field
  4. The mask's transparent areas define where edits are applied; all other pixels are preserved

@edenreich

Copy link
Copy Markdown
Contributor

@infer CI is failing, can you fix this? also the CI was stopped early please finalise it and prepare it for a review (update the title and body of the PR). use /go /ponytail:ponytail

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Model: ollama_cloud/deepseek-v4-flash · View Job

Todos

  • Check current branch and understand the diff
  • Check CI status and identify failures
  • Fix image_edit_test.go - update EditImageArgsForCall to expect 7 values
  • Fix image_service_test.go - add maskPath arg to EditImage calls
  • Run pre-commit checks and push fixes
  • Update PR title and body for review
  • Wait for CI to verify fixes pass

Pull Request

#1008

✅ Infer Result: Success

All CI checks pass! Let me finalize.

All done. Here's a summary of what was accomplished:

Summary

PR #1008 is now ready for review. Here's what was done:

CI Fixes

The previous commit (0ae7c8d) added a maskPath parameter to EditImage but didn't update the test files, causing lint and vet failures. Fixed both test files:

  1. internal/agent/tools/image_edit_test.go - Updated EditImageArgsForCall(0) calls to capture the new 7th return value (mask) and assert it's empty
  2. internal/services/image_service_test.go - Added "" as the 7th argument (maskPath) to all 6 EditImage calls

PR Housekeeping

  • Title: Updated from fix: resolve #988 (salvaged) to feat(image_edit): add mask parameter for selective image editing
  • Body: Replaced the salvage template with a proper description explaining the feature, changes, and how it works
  • CI: All checks pass (lint, vet, build, test, e2e, postgres, CodeQL, analyze)

What the PR does

Adds an optional mask parameter to the ImageEdit tool, allowing users to specify a PNG mask file whose transparent (alpha=0) areas define the editable region. Non-transparent pixels are preserved exactly during the edit operation.

Model: ollama_cloud/deepseek-v4-flash · Exit Code: 0 · Duration: 13m 42s

Tokens: 1,836,833 in · 5,498 out · 1,842,331 total (24 requests)

Tool calls: 30 total · 87% success rate

Traces
Session: 1785861112-4a32fa5e

session (standard, success)                                       13m35s
├── chat ollama_cloud/deepseek-v4-flash                             2.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.4s
│       ╰── HTTP POST [inference-gateway]                           2.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.4s
│               ╰── HTTP POST [inference-gateway]                   2.4s
├── execute_tool TodoWrite call_ubfjmryr                            85µs
├── chat ollama_cloud/deepseek-v4-flash                             2.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.4s
│       ╰── HTTP POST [inference-gateway]                           2.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.4s
│               ╰── HTTP POST [inference-gateway]                   2.4s
├── execute_tool Bash call_py0lmj79                                 31ms
├── execute_tool Bash call_lpj44bcm                                 25ms [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             3.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.4s
│       ╰── HTTP POST [inference-gateway]                           3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.4s
│               ╰── HTTP POST [inference-gateway]                   3.4s
├── execute_tool TodoWrite call_jpuvt4km                            65µs
├── chat ollama_cloud/deepseek-v4-flash                             2.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.5s
│       ╰── HTTP POST [inference-gateway]                           2.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.5s
│               ╰── HTTP POST [inference-gateway]                   2.5s
├── execute_tool Bash call_dsgf56r7                                  7ms
├── execute_tool Bash call_0fngkf4y                                  6ms
├── chat ollama_cloud/deepseek-v4-flash                             3.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.2s
│       ╰── HTTP POST [inference-gateway]                           3.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.2s
│               ╰── HTTP POST [inference-gateway]                   3.2s
├── execute_tool Bash call_5oxqxxol                                320ms
├── execute_tool Bash call_5swuzqix                                 1.2s [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             3.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.5s
│       ╰── HTTP POST [inference-gateway]                           3.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.5s
│               ╰── HTTP POST [inference-gateway]                   3.5s
├── execute_tool TodoWrite call_ntpwkih3                            58µs
├── chat ollama_cloud/deepseek-v4-flash                             2.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.7s
│       ╰── HTTP POST [inference-gateway]                           2.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.7s
│               ╰── HTTP POST [inference-gateway]                   2.7s
├── execute_tool Bash call_79gvcxtj                                 1.2s
├── chat ollama_cloud/deepseek-v4-flash                             3.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.4s
│       ╰── HTTP POST [inference-gateway]                           3.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.4s
│               ╰── HTTP POST [inference-gateway]                   3.4s
├── execute_tool TodoWrite call_adz3jqz1                            58µs
├── chat ollama_cloud/deepseek-v4-flash                             5.8s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.8s
│       ╰── HTTP POST [inference-gateway]                           5.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.8s
│               ╰── HTTP POST [inference-gateway]                   5.8s
├── execute_tool Read call_5krmdifq                                199µs
├── execute_tool Read call_tfc1g7tg                                318µs
├── chat ollama_cloud/deepseek-v4-flash                             5.4s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.4s
│       ╰── HTTP POST [inference-gateway]                           5.4s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.4s
│               ╰── HTTP POST [inference-gateway]                   5.4s
├── execute_tool MultiEdit call_uoct42c3                           402µs
├── execute_tool MultiEdit call_hr6r5iku                           221µs
├── chat ollama_cloud/deepseek-v4-flash                             6.2s
│   ╰── POST /v1/chat/completions [inference-gateway]               6.2s
│       ╰── HTTP POST [inference-gateway]                           6.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     6.2s
│               ╰── HTTP POST [inference-gateway]                   6.2s
├── execute_tool TodoWrite call_sq6f9bxm                            67µs
├── chat ollama_cloud/deepseek-v4-flash                             1.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.9s
│       ╰── HTTP POST [inference-gateway]                           1.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.9s
│               ╰── HTTP POST [inference-gateway]                   1.9s
├── execute_tool Bash call_i1b4b5hy                                52.0s
├── chat ollama_cloud/deepseek-v4-flash                             1.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.9s
│       ╰── HTTP POST [inference-gateway]                           1.8s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.8s
│               ╰── HTTP POST [inference-gateway]                   1.8s
├── execute_tool Bash call_qhkr6pkg                                 10ms
├── chat ollama_cloud/deepseek-v4-flash                            52.2s
│   ╰── POST /v1/chat/completions [inference-gateway]              52.2s
│       ╰── HTTP POST [inference-gateway]                          52.2s
│           ╰── POST /proxy/:provider/*path [inference-gateway]    52.2s
│               ╰── HTTP POST [inference-gateway]                  52.2s
├── execute_tool Bash call_ihcld5tz                                 3.3s
├── chat ollama_cloud/deepseek-v4-flash                             1.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               1.9s
│       ╰── HTTP POST [inference-gateway]                           1.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     1.9s
│               ╰── HTTP POST [inference-gateway]                   1.9s
├── execute_tool Bash call_op6zen67                                 1.7s
├── chat ollama_cloud/deepseek-v4-flash                             3.6s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.6s
│       ╰── HTTP POST [inference-gateway]                           3.6s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.6s
│               ╰── HTTP POST [inference-gateway]                   3.6s
├── execute_tool TodoWrite call_n1i0sn8x                            64µs
├── chat ollama_cloud/deepseek-v4-flash                             3.1s
│   ╰── POST /v1/chat/completions [inference-gateway]               3.1s
│       ╰── HTTP POST [inference-gateway]                           3.1s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     3.1s
│               ╰── HTTP POST [inference-gateway]                   3.1s
├── execute_tool Write call_22ue40v7                                 1ms
├── chat ollama_cloud/deepseek-v4-flash                             5.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               5.9s
│       ╰── HTTP POST [inference-gateway]                           5.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     5.9s
│               ╰── HTTP POST [inference-gateway]                   5.9s
├── execute_tool Bash call_uvcvnphv                                 1.2s
├── chat ollama_cloud/deepseek-v4-flash                             3.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.9s
│       ╰── HTTP POST [inference-gateway]                           2.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.9s
│               ╰── HTTP POST [inference-gateway]                   2.9s
├── execute_tool TodoWrite call_2q4y28r9                            73µs
├── chat ollama_cloud/deepseek-v4-flash                             2.7s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.7s
│       ╰── HTTP POST [inference-gateway]                           2.7s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.7s
│               ╰── HTTP POST [inference-gateway]                   2.7s
├── execute_tool Wait call_akgw5lxh                                2m33s [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             2.0s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.0s
│       ╰── HTTP POST [inference-gateway]                           2.0s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.0s
│               ╰── HTTP POST [inference-gateway]                   2.0s
├── execute_tool Bash call_pvzo14bo                                514ms [error: tool_error]
├── chat ollama_cloud/deepseek-v4-flash                             2.9s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.9s
│       ╰── HTTP POST [inference-gateway]                           2.9s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.9s
│               ╰── HTTP POST [inference-gateway]                   2.9s
├── execute_tool Wait call_o40fm1mc                                7m53s
├── chat ollama_cloud/deepseek-v4-flash                             2.5s
│   ╰── POST /v1/chat/completions [inference-gateway]               2.5s
│       ╰── HTTP POST [inference-gateway]                           2.5s
│           ╰── POST /proxy/:provider/*path [inference-gateway]     2.5s
│               ╰── HTTP POST [inference-gateway]                   2.5s
├── execute_tool TodoWrite call_w89sjeas                            69µs
╰── chat ollama_cloud/deepseek-v4-flash                             3.5s
    ╰── POST /v1/chat/completions [inference-gateway]               3.5s
        ╰── HTTP POST [inference-gateway]                           3.5s
            ╰── POST /proxy/:provider/*path [inference-gateway]     3.5s
                ╰── HTTP POST [inference-gateway]                   3.5s
Stats
Tool Calls

╭───────────┬───────┬───────┬──────────╮
│ Tool      │ Calls │ Fail% │ Avg      │
├───────────┼───────┼───────┼──────────┤
│ Bash      │ 13    │ 23%   │ 4725ms   │
│ TodoWrite │ 8     │ 0%    │ 0ms      │
│ Read      │ 2     │ 0%    │ 0ms      │
│ MultiEdit │ 2     │ 0%    │ 0ms      │
│ Wait      │ 2     │ 50%   │ 312531ms │
│ Write     │ 1     │ 0%    │ 1ms      │
╰───────────┴───────┴───────┴──────────╯

Token Usage

╭────────────────────────────────┬─────────┬────────┬────────────┬─────────┬──────╮
│ Model                          │ Prompt  │ Cached │ Completion │ Total   │ Cost │
├────────────────────────────────┼─────────┼────────┼────────────┼─────────┼──────┤
│ ollama_cloud/deepseek-v4-flash │ 1836833 │ 0      │ 5498       │ 1842331 │ -    │
╰────────────────────────────────┴─────────┴────────┴────────────┴─────────┴──────╯

Sessions

╭───────────┬──────────┬──────────╮
│ Execution │ Mode     │ Sessions │
├───────────┼──────────┼──────────┤
│ headless  │ standard │ 1        │
╰───────────┴──────────┴──────────╯
⚠️ 4 log(s)
  • Bash call_lpj44bcm:
    exit status 128: fatal: origin/main...HEAD: no merge base
    
  • Bash call_5swuzqix:
    exit status 1: lint	fail	1m13s	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042346185	
    vet	fail	1m7s	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042346067	
    build	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042709739	
    e2e	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042710003	
    postgres	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042709939	
    test	skipping	0	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042710190	
    Analyze (actions)	pass	45s	https://github.com/inference-gateway/cli/actions/runs/30924196986/job/92042206761	
    Analyze (go)	pass	1m42s	https://github.com/inference-gateway/cli/actions/runs/30924196986/job/92042206823	
    Analyze (javascript-typescript)	pass	1m0s	https://github.com/inference-gateway/cli/actions/runs/30924196986/job/92042206671	
    CodeQL	pass	2s	https://github.com/inference-gateway/cli/runs/92042413550	
    prepare	pass	25s	https://github.com/inference-gateway/cli/actions/runs/30924200487/job/92042215239
    
  • Wait call_akgw5lxh:
    check command failed with exit code 1 (not in pending_exit_codes)
    
  • Bash call_pvzo14bo:
    exit status 8: Analyze (actions)	pending	0	https://github.com/inference-gateway/cli/actions/runs/30930022410/job/92062027104	
    Analyze (go)	pending	0	https://github.com/inference-gateway/cli/actions/runs/30930022410/job/92062027233	
    Analyze (javascript-typescript)	pending	0	https://github.com/inference-gateway/cli/actions/runs/30930022410/job/92062027218
    

Triggered by edenreich · Infer Action · OSS

The EditImage signature was changed to add a maskPath parameter. This updates the test files to match the new signature.
@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title fix: resolve #988 (salvaged) feat(image_edit): add mask parameter for selective image editing Aug 4, 2026
@edenreich
edenreich marked this pull request as ready for review August 4, 2026 17:12
@edenreich
edenreich requested a review from a team as a code owner August 4, 2026 17:12
@edenreich
edenreich merged commit 11f9785 into main Aug 4, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-988 branch August 4, 2026 23:39
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.162.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add optional mask parameter to the ImageEdit tool

1 participant