[PR #42] [MERGED] Web app pictures reached the engine without their embeddings (strata_resume job thread) #296

Closed
opened 2026-10-29 21:23:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/42
Author: @tanutanu56
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @mw00

Base: main ← Head: fix-image-lost-in-resume-job


📝 Commits (1)

  • 8a02290 strata_resume: carry the image embeddings file over to the job thread

📊 Changes

2 files changed (+28 additions, -2 deletions)

View changed files

📝 serve/server.py (+10 -1)
📝 serve/test_server.py (+18 -1)

📄 Description

Pictures sent from the web app are read as a blank / black image (or the model invents a task for them), while the same request sent straight to the API is read correctly.

Cause

Service.embeddings is a threading.local: the request thread prepares the prompt, encodes the images and sets embeddings.path; generate() reads it when the engine call starts. With strata_resume (which the web app always sends) the first chunk is pulled on the request thread, but the rest of the generator runs on the strata-job thread, where embeddings.path is None. The engine then gets the prompt with the image's pad tokens and no embeddings, so the model "sees" nothing. Without strata_resume, everything runs on one thread and works, which is why curl and --bench never showed it.

Fix

carry_embeddings(local, path, chunks): a small generator that sets the file on the job thread before it first pulls from the answer generator. One call site (the strata_resume branch); StreamJob is untouched.

Reproduction (v1.0.16 and v1.0.17, GLM Maya-S, vision on)

A 512x384 picture, red background with a yellow circle, asked "background and circle colour in a word", reasoning_effort: none:

request answer
plain red with yellow
stream: true red with yellow
stream: true, strata_resume: true (before) black background, red circle
stream: true, strata_resume: true (after) red with yellow

In the web app, a new chat with any picture answered about a black image, or made up a maths problem about it.

Tests

serve.test_server.TestCarryEmbeddings runs the generator on a second thread and checks that it sees the request thread's file. python -m unittest serve.test_server: 54 tests, OK. The table above was measured on the running server; I did not re-run the live check on this branch, only on the same change applied to a v1.0.16 checkout.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/42 **Author:** [@tanutanu56](https://github.com/tanutanu56) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `fix-image-lost-in-resume-job` --- ### 📝 Commits (1) - [`8a02290`](https://github.com/mw00/project-maya/commit/8a02290f30fa55828872cc517489315be0c4d085) strata_resume: carry the image embeddings file over to the job thread ### 📊 Changes **2 files changed** (+28 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+10 -1) 📝 `serve/test_server.py` (+18 -1) </details> ### 📄 Description Pictures sent from the web app are read as a blank / black image (or the model invents a task for them), while the same request sent straight to the API is read correctly. ## Cause `Service.embeddings` is a `threading.local`: the request thread prepares the prompt, encodes the images and sets `embeddings.path`; `generate()` reads it when the engine call starts. With `strata_resume` (which the web app always sends) the first chunk is pulled on the request thread, but the rest of the generator runs on the `strata-job` thread, where `embeddings.path` is `None`. The engine then gets the prompt with the image's pad tokens and no embeddings, so the model "sees" nothing. Without `strata_resume`, everything runs on one thread and works, which is why `curl` and `--bench` never showed it. ## Fix `carry_embeddings(local, path, chunks)`: a small generator that sets the file on the job thread before it first pulls from the answer generator. One call site (the `strata_resume` branch); `StreamJob` is untouched. ## Reproduction (v1.0.16 and v1.0.17, GLM Maya-S, vision on) A 512x384 picture, red background with a yellow circle, asked "background and circle colour in a word", `reasoning_effort: none`: | request | answer | |---|---| | plain | red with yellow | | `stream: true` | red with yellow | | `stream: true, strata_resume: true` (before) | black background, red circle | | `stream: true, strata_resume: true` (after) | red with yellow | In the web app, a new chat with any picture answered about a black image, or made up a maths problem about it. ## Tests `serve.test_server.TestCarryEmbeddings` runs the generator on a second thread and checks that it sees the request thread's file. `python -m unittest serve.test_server`: 54 tests, OK. The table above was measured on the running server; I did not re-run the live check on this branch, only on the same change applied to a v1.0.16 checkout. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:54 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#296
No description provided.