# Passing outputs of One Task multiple times to other Task as 'Template Variable'

**URL:** <https://community.crewai.com/t/passing-outputs-of-one-task-multiple-times-to-other-task-as-template-variable/6057>\
**Category:** General\
**Created:** [June 1, 2025, 8:39am UTC](https://community.crewai.com/t/passing-outputs-of-one-task-multiple-times-to-other-task-as-template-variable/6057 "2025-06-01T08:39:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiran\_J](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/kiran_j/32/1571_2.png) [@Kiran\_J](https://community.crewai.com/u/Kiran_J)\
**Post date:** [June 1, 2025, 8:39am UTC](https://community.crewai.com/t/passing-outputs-of-one-task-multiple-times-to-other-task-as-template-variable/6057/1 "2025-06-01T08:39:40Z")

</div>

Have 2 Agents (Agent\_1, Agent\_2) and 2 tasks (Task\_1, Task2)  
Task\_1 of Agent\_1 runs and gets a list of output (City Names, Say 10 cities).

for each of these output of the Task\_1 I need to call the Task\_2  
Task\_2’s description must take Task\_1 output as a ‘Template variable’ and execute it for all the Values  
(Say Task\_2 is executed for all the 10 cities one after another )

How do I accomplish this in CrewAI  
I dont want to pass it as just context to Task\_2 as it not guaranteed to take it as value in Template Valiable which makes my task’s description better

[How to pass output of certain agent as input to other agent](https://community.crewai.com/t/how-to-pass-output-of-certain-agent-as-input-to-other-agent/3766) did not help much

Any complete example / sample code Snippet for this is highly appreciated

---

<div class="post-metadata">

**Author:** ![zinyando](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/zinyando/32/4435_2.png) [@zinyando](https://community.crewai.com/u/zinyando)\
**Post date:** [June 2, 2025, 2:45pm UTC](https://community.crewai.com/t/passing-outputs-of-one-task-multiple-times-to-other-task-as-template-variable/6057/2 "2025-06-02T14:45:24Z")

</div>

I think passing the output as context is still the way to go.

What you might need to do it so have the output of task 1 as a structured output eg JSON object then in the task description of task 2 be explicit that you want to perform the task on the context object for each item.

This should probably work. Try it out!!
