-
Notifications
You must be signed in to change notification settings - Fork 82
fix(ai): let Prompts.get_all() batch without a label #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
posthog
wants to merge
1
commit into
main
Choose a base branch
from
posthog-self-driving/fixaiprompts-let-promptsget_all-batch-0b7352
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+122
β40
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| pypi/posthog: minor | ||
| --- | ||
|
|
||
| `Prompts.get_all()` now works without a label: it fetches the latest version of every prompt in one request and caches each one under the key `get(name)` reads. Apps that do not use labels no longer need one request per prompt per cache cycle. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlabeled batch fetches lose prompt-fetch usage events
Issue description
The new unlabeled path calls the list endpoint without
label. The deployed server emits$llm_prompt_fetchedfor labeled list calls only. Repeatedget(name)calls emit one event per prompt. An app that switches toget_all()therefore stops reporting these fetches. Prompt-only teams can also disappear from AI observability usage reports. The required server fix remains an open draft.Why we think it's a valid issue
list()handler on PostHog/posthog master, the ingestion billable-event list, and the AI observability usage report task.list()callsself._track_labeled_list_fetches(prompts, label)inside anif label:guard (posthog/api/llm_prompt.py:685-689), while the single-prompt action callsself._track_prompt_fetch(prompt)unconditionally (posthog/api/llm_prompt.py:358). The premise holds: the path this PR adds produces no$llm_prompt_fetchedevent, and the path it replaces produces one per prompt per cache cycle.7d776ae0 feat(aio): report prompt fetches on labeled list calls (#98183). feat(aio): report prompt fetches on unlabeled list callsΒ posthog#100690 reportsstate: OPEN,isDraft: true,mergedAt: null, so the unlabeled tracking is not deployed.llm_prompt_fetchedacross posthog-python returns no match, and_maybe_capture_errorreports exceptions only.AI_OBSERVABILITY_REPORT_TRIGGER_EVENTSincludes$llm_prompt_fetched(posthog/tasks/ai_observability_usage_report.py:47) and feedsget_teams_with_ai_events(...)at line 911. A team that uses prompt management but emits no$ai_*events drops out of the report after it moves to the unlabeled batch call.get_alldocstring names "PostHog releases from before September 2026" for the labeled path (posthog/ai/prompts.py:395-397).should_fix.$llm_prompt_fetchedsits inNON_BILLABLE_EVENTSin nodejs/src/ingestion/common/usage-records/billable-events.ts:20, so no billing and no customer-facing result changes. No code in this repository is wrong, the correction is server-side and takes effect for every client as soon as it deploys, and the requested server contract test belongs in PostHog/posthog. The action for this PR is release coordination plus a note in the changeset, not a merge blocker.Suggested fix
Deploy PostHog/posthog#100690 before this SDK release. Record this rollout dependency in the changeset. Add a server contract test that proves an API-key unlabeled list request emits one event for each returned prompt.
Prompt to fix with AI (copy-paste)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escalating: the gap is real, but it closes in the server repository and depends on a release-sequencing call a human must make.
How this was verified
No code changed, so no lint or tests were run. Checks made instead: read the unlabeled request build and the error-capture helper in the prompts module, searched the whole repository for any client-side prompt-fetch event (no match), and queried the state of the referenced server pull request (still open and draft). Working tree left clean.