Skip to content

server: tests: fetch random media marker via /apply-template (#21962)#21980

Merged
ggerganov merged 5 commits intoggml-org:masterfrom
ServeurpersoCom:tests/apply-template
Apr 16, 2026
Merged

server: tests: fetch random media marker via /apply-template (#21962)#21980
ggerganov merged 5 commits intoggml-org:masterfrom
ServeurpersoCom:tests/apply-template

Conversation

@ServeurpersoCom
Copy link
Copy Markdown
Contributor

Overview

Fix CI

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, python write, install and run the test on disposable pod

@ServeurpersoCom ServeurpersoCom requested a review from a team as a code owner April 16, 2026 04:27
@github-actions github-actions bot added examples python python script changes server labels Apr 16, 2026
@ServeurpersoCom
Copy link
Copy Markdown
Contributor Author

cc @ngxson if you prefer a separate helper let me know

@ngxson
Copy link
Copy Markdown
Contributor

ngxson commented Apr 16, 2026

Actually I think allowing user to set the marker would be a more flexible approach.

Maybe we can add a logic in get_media_marker() to return the env var LLAMA_MEDIA_MARKER if it's set?

get_media_marker() checks LLAMA_MEDIA_MARKER at first call and uses it
as-is if set, falling back to the random marker otherwise.

Tests no longer need to fetch the marker dynamically via /apply-template:
the fixture sets LLAMA_MEDIA_MARKER=<__media__> so the hardcoded prompts
work as before.

Address review feedback from ngxson
}
}
return media_marker.c_str();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make get_media_marker() thread-safe like this:

const char * get_media_marker() {
    static const std::string media_marker = []() {
        // allow user to pin a reproducible marker via env var (useful for tests and external pipelines)
        const char * env = getenv("LLAMA_MEDIA_MARKER");
        if (env && env[0] != '\0') {
            return std::string(env);
        } else {
            return std::string("<__media_") + random_string() + "__>";
        }
    }();
    
    return media_marker.c_str();
}

Use a C++11 static local with a lambda initializer instead of a global
static with an empty-check. The runtime guarantees initialization exactly
once without explicit locking.

Address review feedback from ggerganov
@ggerganov ggerganov merged commit 4adac43 into ggml-org:master Apr 16, 2026
49 of 53 checks passed
cnsiva pushed a commit to saas-home/llama.cpp that referenced this pull request Apr 17, 2026
…g#21962) (ggml-org#21980)

* server: tests: fetch random media marker via /apply-template (ggml-org#21962 fix)

* server: allow pinning media marker via LLAMA_MEDIA_MARKER env var

get_media_marker() checks LLAMA_MEDIA_MARKER at first call and uses it
as-is if set, falling back to the random marker otherwise.

Tests no longer need to fetch the marker dynamically via /apply-template:
the fixture sets LLAMA_MEDIA_MARKER=<__media__> so the hardcoded prompts
work as before.

Address review feedback from ngxson

* server: make get_media_marker() thread-safe via magic statics

Use a C++11 static local with a lambda initializer instead of a global
static with an empty-check. The runtime guarantees initialization exactly
once without explicit locking.

Address review feedback from ggerganov

* nits

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

Labels

examples python python script changes server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants