Problem Statement
Prompts.get_all() requires a label. An app that wants the current version of every prompt has no batch entry point, so it falls back to one get() per prompt.
That is the common shape for teams that do not use labels at all, and it is the shape get_all was added to remove. Each prompt costs one request against the prompt fetch rate limits, and the requests are made on every cache cycle.
The server side already supports it. GET /api/environments/@current/llm_prompts/ returns the latest version of every prompt when label is omitted, and PostHog/posthog#100690 makes that path report $llm_prompt_fetched the same way the labeled path does.
Solution Brainstorm
Make label optional:
def get_all(self, *, label: Optional[str] = None) -> Dict[str, PromptResult]: ...
- Without
label, every prompt comes back at its latest version, cached under the same key get(name) reads, so a later get(name) is a cache hit within the TTL.
- With
label, behavior is unchanged.
- The change is additive, so existing
get_all(label=...) callers are unaffected. It does touch references/public_api_snapshot.txt.
The label-compatibility guards in get_all (the absent and "no row resolved the label" errors) only apply when a label was requested. They exist to catch an older server that ignores the label parameter, and the unlabeled list has always returned latest versions, so the unlabeled path skips them.
A working patch along these lines passes the existing posthog/test/ai/test_prompts.py suite unchanged. Happy to open a PR once a maintainer agrees on the shape, per the "Public API changes" rule in CONTRIBUTING.md.
Filed by a PostHog agent, from an inbox report about prompt-management callers hitting the per-prompt rate limits.
Problem Statement
Prompts.get_all()requires alabel. An app that wants the current version of every prompt has no batch entry point, so it falls back to oneget()per prompt.That is the common shape for teams that do not use labels at all, and it is the shape
get_allwas added to remove. Each prompt costs one request against the prompt fetch rate limits, and the requests are made on every cache cycle.The server side already supports it.
GET /api/environments/@current/llm_prompts/returns the latest version of every prompt whenlabelis omitted, and PostHog/posthog#100690 makes that path report$llm_prompt_fetchedthe same way the labeled path does.Solution Brainstorm
Make
labeloptional:label, every prompt comes back at its latest version, cached under the same keyget(name)reads, so a laterget(name)is a cache hit within the TTL.label, behavior is unchanged.get_all(label=...)callers are unaffected. It does touchreferences/public_api_snapshot.txt.The label-compatibility guards in
get_all(theabsentand "no row resolved the label" errors) only apply when a label was requested. They exist to catch an older server that ignores thelabelparameter, and the unlabeled list has always returned latest versions, so the unlabeled path skips them.A working patch along these lines passes the existing
posthog/test/ai/test_prompts.pysuite unchanged. Happy to open a PR once a maintainer agrees on the shape, per the "Public API changes" rule in CONTRIBUTING.md.Filed by a PostHog agent, from an inbox report about prompt-management callers hitting the per-prompt rate limits.