[Feature Request] Workforce: put {content} last in PROCESS_TASK_PROMPT so sibling subtasks can share a cached prefix
Required prerequisites
- I have searched the Issue Tracker and Discussions that this hasn't already been reported. (+1 or comment there if it has.)
- Consider asking first in a Discussion.
Motivation
This comes from a cost problem I hit running a Workforce against a local model server: every subtask makes the server process the parent task's text again, although all the sibling subtasks send exactly the same parent text.
The cause is the order of PROCESS_TASK_PROMPT in camel/societies/workforce/prompts.py. It places the subtask's own {content} right after the instructions, ahead of {parent_task_content}, {dependency_tasks_info} and {additional_info}. Each sibling has a different {content}, so two sibling prompts stop matching right after the instructions, and a server-side prefix cache (llama.cpp's or vLLM's, for example) can reuse only the instructions.
I measured this on a local llama.cpp llama-server (2 slots, Qwen3-Coder-Next 80B), running a Workforce with 2 workers and 3 independent subtasks (8 requests per run) and reading the server's own per-request prompt eval counts:
stock template {content} last
prompt tokens evaluated per run 12,728 9,606
prompt evaluation time per run 38.7 s 29.7 s
one worker dispatch, tokens served from cache 5 of 2,128 1,849 of 2,121The first two rows are means of 2 interleaved pairs from 2026-10-01, after a discarded warm-up run. The last row comes from an earlier run of the same harness on 2026-08-19.
Related: #3586 and #3770, which asked for provider-side prompt caching. Those caches also match on the start of the prompt, so the same order should let them reuse the parent block too; I have not measured that.
Solution
Move the {content} block to the end of PROCESS_TASK_PROMPT. Every placeholder and every word stays the same; only the order changes, so the parent block becomes part of the prefix that sibling sub-tasks share. Add a test that pins {content} after the three shared fields, so a later edit to the template does not quietly undo it. I have this as a 10-line change plus a 3-test file and can open a PR if you agree with the direction.
Alternatives
Each deployment can swap the template itself at startup. That is what I run now: a small module replaces camel.societies.workforce.prompts.PROCESS_TASK_PROMPT before the workforce is built. It works, but every user who wants the saving has to find and maintain the same patch against an internal name, and that patch can stop working unnoticed when the template is renamed or reworded.
A configurable template on the worker would also work, but it adds an API surface for what is a one-time ordering fix.
Additional context
All of the measurements are from a single workload on one llama.cpp setup. When siblings also differ in {dependency_tasks_info} or {additional_info}, the shared prefix ends after the parent block and the saving is smaller. I did not evaluate output quality; I only checked that the runs completed.
Provider-side prompt caching (#3586, #3770) also matches on the start of the prompt, so the same order should help there; I have not measured that. ROLEPLAY_PROCESS_TASK_PROMPT has the same layout, and I have not measured it either.
Source: camel-ai/camel