Repository navigation
docs(prompt-management): add a guide for prompts in Temporal workflows - #21180
Conversation
Deploy preview
Changed pages
|
|
Vale prose linter → found 0 errors, 2 warnings, 0 suggestions in your markdown Full report → Copy the linter results into an LLM to batch-fix issues. Linter being weird? Update the rules!
|
| Line | Severity | Message | Rule |
|---|---|---|---|
| 2:34 | warning | Capitalize 'Workflows' for PostHog's product. Use 'workflows' for the general industry concept. | PostHogBase.ProductNames |
| 11:32 | warning | Capitalize 'Workflows' for PostHog's product. Use 'workflows' for the general industry concept. | PostHogBase.ProductNames |
| host: 'https://us.posthog.com', | ||
| personalApiKey: '<your_personal_api_key>', | ||
| }) | ||
| const prompts = new Prompts({ posthog }) |
There was a problem hiding this comment.
P2 · Export the prompt client used by the TypeScript worker
When readers combine the TypeScript examples, worker.ts accesses activities.prompts, but activities.ts declares prompts without exporting it. TypeScript rejects that access; running without type checking instead throws before Worker.create(), so the documented worker never starts. Export the shared prompts instance used by the warm-up call.
| from activities import draft_reply, prompts | ||
|
|
||
| async def main(): | ||
| prompts.get_all(label='production') |
There was a problem hiding this comment.
P2 · Handle cache warm-up failures before starting the worker
When the prompt API is unavailable during startup, get_all() and getAll() throw instead of returning a fallback. Both worker examples let that exception escape before the worker starts polling, so the activity's documented fallback never runs and support tasks stop processing. Catch and log warm-up failures, then start the worker with its activity fallbacks.
| try { | ||
| await worker.run() | ||
| } finally { | ||
| await posthog.shutdown() |
There was a problem hiding this comment.
P2 · Reference the shared client in the shutdown examples
When readers add this cleanup to the worker examples, worker.ts only imports activities, and worker.py only imports draft_reply and prompts. Neither defines posthog, so TypeScript fails to compile and Python raises NameError on shutdown instead of flushing queued generation events. Use activities.posthog in TypeScript and import the shared client in Python.
|
|
||
| ## Set timeouts above the fetch timeout | ||
|
|
||
| Each SDK fetch gives up after 10 seconds. Give the activity a `start_to_close_timeout` (Python) or `startToCloseTimeout` (TypeScript) longer than that, so a slow prompt fetch surfaces as a fallback instead of an activity timeout. |
There was a problem hiding this comment.
P2 · Account for Python HTTP retries in the activity timeout
During a Python prompt API outage, prompts.get() uses a Requests session with two retries, so timeout=10 applies per attempt and fetching can take 30 seconds. An activity configured just above 10 seconds times out before fallback, while asyncio.to_thread keeps fetching and Temporal retries the activity. Document the full retry budget and reserve time for the LLM call.
…ll Python fetch budget
Bundle reportTotal JS (gzip)10.10 MiB (-0.9 KiB / -0.0%) Eager graph (modules shipped in each entrypoint's initial chunks)
Largest modules in the
|
| Module | Size |
|---|---|
./src/data/mcp-tools.json |
1348.5 KiB |
css ./node_modules/.pnpm/[email protected][email protected]/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[1]!./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[2]!./src/styles/global.css |
811.7 KiB |
./src/components/Stickers/Stickers.tsx |
696.4 KiB |
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js |
481.4 KiB |
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@posthog/brand/dist/generated/hoggies/svg/x-ray.mjs |
481.2 KiB |
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@posthog/brand/dist/generated/hoggies/svg/trenchcoat.mjs |
450.8 KiB |
./node_modules/.pnpm/[email protected]/node_modules/rehype-raw/lib/index.js + 29 modules |
395.1 KiB |
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@posthog/brand/dist/generated/hoggies/svg/im-the-driver.mjs |
385.8 KiB |
./src/hooks/useCustomers.tsx + 59 modules |
380.8 KiB |
./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@posthog/icons/dist/posthog-icons.es.js |
354.8 KiB |
./node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/react-markdown/lib/react-markdown.js + 88 modules |
351.4 KiB |
./src/components/ProductComparisonTable/index.tsx + 127 modules |
310.3 KiB |
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@posthog/brand/dist/generated/hoggies/svg/doll-house.mjs |
284.1 KiB |
./node_modules/.pnpm/[email protected][email protected]/node_modules/cloudinary-core/cloudinary-core.js |
281.9 KiB |
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@posthog/brand/dist/generated/hoggies/svg/director.mjs |
275.7 KiB |
Eager-graph budgets are report-only until a baseline is established. Sizes are gzip of public/**/*.js; eager size is webpack module source bytes for the modules actually shipped in the entrypoint's initial chunks (post-tree-shake).
Changes
Adds a page under Prompt management on using prompts inside Temporal workflows. Teams fetching prompts from Temporal activities had no guidance and hit the same problems one by one. Closes PostHog/posthog#106807.
The page covers, with Python and TypeScript samples:
get_all/getAllwhen the worker starts.New page, so no before screenshot. The nav gets a third entry under Prompt management.
The page says concurrent fetches share one request. That is true for
@posthog/ai(PostHog/posthog-js#5266) and for Python once PostHog/posthog-python#1059 is released, so this should land after that release.Checklist
vercel.json