Conceptio › Archive › arXiv CS
arXiv CS open access

Agent Memory Distillation: Empowering Small LLM Agents with Hierarchical Teacher Memory

2026 · arxiv_cs
arXiv CS · Papers · 2026
Open Source ↗Direct PDF ↓
deep-learningmachine-learningneural-networks
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

Agent Memory Distillation: Empowering Small LLM Agents with Hierarchical Teacher Memory

Taeil Kim1∗

Kangsan Kim1∗ 1

KAIST

2

Sung Ju Hwang1,2

DeepAuto.ai

https://agent-memory-distillation.github.io/ {kti5589, kangsan.kim, sungju.hwang}@kaist.ac.kr

(A) Using Student Memory

Abstract

Fail

arXiv:2608.07169v1 [cs.AI] 7 Aug 2026

Memory systems have shown promise for improving agent performance, but their potential remains largely unexplored for small language models, which struggle to generate sufficient successful trajectories on their own. We propose Agent Memory Distillation (AMD), a training-free framework that transfers structured knowledge from a large teacher agent to a small student agent through hierarchical memory. AMD constructs three complementary memory types from successful teacher trajectories: Workflow memory encodes task-level strategies, Subtask memory provides concrete behavioral examples at an intermediate granularity, and Function memory captures perfunction calling conventions and common pitfalls. Workflow and Subtask memories are injected proactively at the start of each task, while Function memory is retrieved reactively upon tool-calling errors. We evaluate AMD on three tool-use benchmarks using four student models (4B–8B parameters) with GPT-5mini as the teacher, achieving average accuracy gains of 27.2%p, 11.2%p, and 3.4%p on AppWorld, BFCL V3, and ToolSandbox, while consistently outperforming existing memorybased baselines. Further analysis shows that Subtask memory contributes the largest gains, teacher effectiveness depends on both teacher capability and student compatibility, and 4Bsized students benefit most from AMD.

1

Student

Fail

Limited Memory Benefit SelfPoor Evolve Memory

(B) Naive Teacher Memory Transfer Log in before playing music. Capability Gap Teacher

Teacher Memory

How can I log in..?

(C) Agent Memory Distillation (Ours)

Teacher

Comprehensible to Student

Task Solving Subtask Function Workflow Execution Call Guide Hierarchical Memory

(D) Performance Improvement (Qwen3-4B)

Figure 1: Motivation, Concept, and Results of AMD. (A) Student-generated memory is limited by low task success rates. (B) Naive teacher memory transfer yields marginal gains due to the capability gap. (C) AMD transfers hierarchical memories spanning task, subtask, and function levels, making teacher knowledge accessible to small students. (D) AMD achieves significant accuracy gains across three benchmarks.

as APIs and predefined functions to tackle complex tasks, the role of memory becomes even more essential (Liao et al., 2025; Xu et al., 2026). In such settings, memory helps agents recall effective tooluse strategies from past interactions, improving both efficiency and task success rates (Fang et al., 2025; Xia et al., 2025). Moreover, memory can encode tool conventions such as argument schemas and return structures, enabling agents to invoke tools more accurately and reliably (Du, 2026).

Introduction

Memory has emerged as a critical component for developing capable self-evolving agents, enabling the reuse of successful behavioral patterns and the avoidance of past failures (Zhao et al., 2024a; Ouyang et al., 2025; Zhang et al., 2026). As modern agents increasingly rely on external tools such *

Fail

However, the potential of memory remains largely unexplored for small agents, in contrast to its demonstrated effectiveness with large propri-

Equal contribution

1

etary models (Wu et al., 2025; Luo et al., 2026). A key challenge is that small agents typically exhibit lower task success rates, resulting in memory repositories that are dominated by unsuccessful trajectories and contain only a limited number of successful experiences, as shown in Figure 1 (A). Although agents can reflect on past failures to improve subsequent actions, the scarcity of successful trajectories fundamentally limits the impact of memory utilization (Hu et al., 2025; Allard et al., 2026; Ding, 2026). To overcome this limitation, we propose leveraging memories generated by stronger teacher agents, whose superior performance yields a rich source of successful trajectories and tool-use examples. A related line of work also transfers teacher experience to small students, for example by extracting hints from failed trajectories to generate successful teacher trajectories and then finetuning the student on them (Ibrahim et al., 2025). Inspired by knowledge distillation (Hinton et al., 2015; Kang et al., 2026), our method enhances student agents in a training-free manner by directly transferring the teacher’s experiences rather than optimizing model parameters. Despite access to high-quality teacher experience, we observe that naive memory transfer yields only marginal improvements, comparable to those achieved by student-generated memory alone. This suggests that the capability gap between teacher and student agents remains a major obstacle to effective memory distillation, analogous to the knowledge gap observed in conventional knowledge distillation (Mirzadeh et al., 2020; Guo et al., 2020). For example, a teacher memory may recommend a high-level strategy such as "Log in first to start the playlist," while the student lacks the prerequisite knowledge to execute the login procedure itself, as shown in Figure 1 (B). Furthermore, small models are known to exhibit limited in-context learning ability and weaker instruction-following capacity compared to larger models, leading to difficulties in effectively interpreting and applying teacher memories even when they are directly provided (Wei et al., 2022; Zhao et al., 2024b; Shen et al., 2024). These factors collectively highlight the need for a principled knowledge transfer strategy tailored to agent memory distillation. In this work, we introduce Agent Memory Distillation (AMD), a novel framework for transferring teacher agent experiences to small student agents. Rather than relying on a single memory representation, AMD constructs three types of mem-

ory from teacher experiences, organized in a hierarchical structure spanning task-level, subtasklevel, and function-level granularities to facilitate effective comprehension and application of teacher knowledge, as illustrated in Figure 1 (C). Specifically, Workflow memory captures overall task completion strategies, enabling the student to decompose tasks into subtasks and establish a coherent high-level plan. Subtask memory provides concrete action examples for each subtask, allowing the student to reference successful teacher behaviors at an intermediate level. Finally, Function memory encodes detailed tool schemas and usage examples, which are retrieved when the student encounters tool-calling errors during inference to guide correct tool execution. To validate the effectiveness of AMD, we conduct experiments across three benchmarks using four small language models (4B or 8B parameters) as student agents, with GPT-5-mini serving as the teacher. AMD consistently achieves substantial performance improvements over the zero-shot baseline across all student models, with average accuracy gains of 27.2%p on AppWorld (Trivedi et al., 2024), 11.2%p on BFCL V3 (Patil et al., 2025), and 3.4%p on ToolSandbox (Lu et al., 2024), while outperforming all memory-based baselines that are not designed for the memory distillation setting (Ouyang et al., 2025; Fang et al., 2025; Shen et al., 2026). Beyond accuracy, AMD also reduces the number of interaction turns required by the student, yielding trajectories that more closely resemble those of the teacher agent. We further reveal that each memory type contributes distinctly to knowledge transfer, that transfer quality depends on both teacher accuracy and teacher-student compatibility, and that 4B-scale students tend to benefit most from teacher memory distillation. In conclusion, this work presents the first systematic investigation into effective teacher-to-student memory transfer for small agents. By first identifying the limitations of naive memory transfer, we propose a hierarchically structured memory distillation framework that enables small student agents to better comprehend and apply teacher knowledge across multiple levels of task granularity. We hope this work provides a solid foundation for future research on agent memory distillation and the development of more capable small LLM agents by enhancing their ability to effectively leverage the accumulated experiences of stronger agents. 2

2

Related Work

2.1

LLM Agents with Memory

troduces a reinforced distillation framework based on student-centered short-horizon reinforcement learning. However, these approaches rely on parameter updates through costly training and do not explore memory-based knowledge transfer. AgentDistill (Qiu et al., 2025) takes a training-free approach by directly reusing teacher-generated MCPs, yet it does not enable students to leverage teacher memory directly. Memory Transfer Learning (Kim et al., 2026) investigates inter-model knowledge transfer but is not designed for the teacher-student distillation setting. It is also well established that the capability gap between teacher and student models can fundamentally limit distillation effectiveness (Mirzadeh et al., 2020; Guo et al., 2020; Xu et al., 2025). To the best of our knowledge, AMD is the first work to systematically address teacher-to-student memory distillation, explicitly accounting for the capacity gap through a principled hierarchical memory transfer design.

Memory enables agents to leverage previous experiences by following successful patterns while avoiding repeated failures (Zheng et al., 2024; Zhang et al., 2025; Tang et al., 2025; Zhang et al., 2026). Reflexion (Shinn et al., 2023) first demonstrates the potential of verbalized self-feedback and episodic memory buffers for agent self-improvement. ExpeL (Zhao et al., 2024a) enables agents to collect experience, extract cross-task insights, and retrieve them during future inferences. Similarly, AWM (Wang et al., 2024) extracts and reuses common multi-step workflows, while ReasoningBank (Ouyang et al., 2025) samples candidate trajectories through test-time scaling and generates reasoning insights for upcoming tasks. MemP (Fang et al., 2025) proposes procedural memory that distills agent trajectories into multilevel abstractions and investigates effective memory management mechanisms. ReflecTool (Liao et al., 2025) stores tool-wise experience in memory and retrieves relevant trajectories at inference time. SASM (Shen et al., 2026) further proposes subtasklevel memory alignment to address granularity mismatch in instance-level memory retrieval. However, existing methods are predominantly evaluated with large proprietary models such as GPT-4 (Achiam et al., 2023) or Gemini 2.5 (Comanici et al., 2025), overlooking the limitation of memory utilization in small agents stemming from their degraded reasoning and instruction-following capabilities. We address this gap by providing small agents with structured, multi-level knowledge distilled from teachers in a detailed and accessible form. 2.2

3

Agent Memory Distillation

We present AMD, a novel framework that transfers teacher memory to a small student agent. We first formalize the problem setting in Section 3.1, then describe multi-level memory generation by a teacher in Section 3.2 and memory retrieval and utilization by a student in Section 3.3. 3.1

Problem Formulation

We focus on multi-turn tool-use reasoning tasks, where an agent π operates in an interactive environment by issuing a sequence of tool calls from a predefined set F and receiving observations in return. Given a task s, the agent produces a trajec tory τ = (a1 , o1 ), . . . , (aT , oT ) , where at ∈ F is a tool call and ot is the resulting observation at step t. We distinguish between a teacher agent π T , backed by a large and capable language model, and a student agent π S , backed by a small model (4B or 8B parameters). Given a task set S, we first run π T on S to collect a set of teacher trajectories T }, where N = |S|. We then DT = {τ1T , ..., τN T use π to construct a memory store M from DT , which is subsequently transferred to π S . At inference time, π S retrieves relevant memories from M to guide its reasoning on S. The goal of AMD is to maximize the task performance of π S through effective utilization of teacher-generated memories:

Knowledge Distillation in LLM

Knowledge distillation (Hinton et al., 2015) has long been studied as a paradigm for transferring knowledge from a stronger teacher model to a smaller student model, with demonstrated effectiveness across a wide range of LLM settings (Sanh et al., 2019; Hsieh et al., 2023; Gu et al., 2024; Guo et al., 2025). Recent works have extended this paradigm to agentic settings. SAD (Liu et al., 2025) segments teacher trajectories into reasoning and action spans and applies segment-wise distillation losses. Agent Distillation (Kang et al., 2026) transfers full task-solving behaviors, including retrieval and code tool use, from teacher to student models, and SCoRe (Lyu et al., 2025) in-

  max Es∼S R π S (s; M) , M

3

(1)

Hierarchical Memory Generation by Teacher Memory Generation

Teacher Inference Agentic Tasks Teacher

Get correct trajectories

: How much money have I sent on Venmo this month?

Successful Teacher trajectory Workflow

Task: How much money have I sent on Venmo this month? Retrieve credentials, verify you received an access token. Aggregate sent amounts, iterating page index…

Subtask

[authenticate to Venmo]: [sum transactions and complete]: (Tool sequence) (Tool sequence)

Function venmo.show_transactions: (Tool description) (Call example)

Memory Usage by Student Proactive Injection System Prompt Workflow Subtask

Student

Teacher Memory

Retrieval

venmo.login(username=‘student’, password= ‘a1234’) Error!

Reactive Injection Function venmo.login: username should be an email address…

Figure 2: Hierarchical Memory Generation and Injection in AMD. (Left) The teacher agent generates three types of memory from successful trajectories. (Right) At inference time, Workflow and Subtask memories are proactively injected into the system prompt, while Function memory is reactively retrieved upon tool-calling errors.

where R(π S (s; M)) denotes the task success reward obtained by π S on task s given memory M. 3.2

pose the trajectory into a sequence of coherent subtask segments {ei,1 , . . . , ei,Ki }, where each segment corresponds to a semantically meaningful unit of the teacher’s behavior, such as authenticating with a service or executing a sequence of related API calls to fulfill one subtask. Segmentation is performed by a teacher LLM prompted to identify semantically coherent units in the trajectory, optionally guided by rule-based heuristics that provide candidate breakpoint hints. Each segment ei,k , which contains the concrete execution examples (tool calls or executable code paired with the corresponding observations from the teacher), is stored together with a label ℓi,k , a short natural language description di,k , forming a subtask memory entry mst i,k = (ℓi,k , di,k , ei,k ). Each description di,k is encoded into a dense vector for retrieval, and all entries across all trajectories constitute the subtask S|DT | Ki memory bank Mst = i=1+ {mst i,k }k=1 .

Hierarchical Memory Generation

AMD constructs three types of memory from the teacher’s past experiences, organized at different levels of task granularity. AMD employs π T to T ⊆ D T , the construct each memory type from D+ subset of successful teacher trajectories, producing a memory store M = Mwf ∪ Mst ∪ Mf n , where Mwf , Mst , and Mf n denote Workflow, Subtask, and Function memories. Workflow Memory Workflow memory captures the teacher’s high-level task-completion strategy. T , a verbalFor each successful trajectory τiT ∈ D+ ized insight is produced that describes the overall approach taken by the teacher in natural language, covering the apps and tools involved, key preconditions, and decision rules for task completion, as well as validation cues and common failure patterns to avoid. The insight abstracts over concrete runtime values: identifiers, credentials, file paths, and other dynamic inputs are replaced with typed placeholders (e.g., <ID>, <EMAIL>, <FILE_PATH>), so that the memory remains applicable to future tasks with different specific inputs. Together with a natural language query that characterizes the task, the insight forms a workflow memory entry mwf = (qi , insi ), which is encoded into a dense i vector for retrieval. The resulting memory bank

Function Memory Function memory captures fine-grained tool invocation knowledge at the level of individual function calls, built directly from the successful teacher trajectories and optionally augmented with the corresponding function documenT , we tation. For each successful trajectory τiT ∈ D+ extract its constituent function invocations, indexed by j ∈ {1, . . . , Ji }. Each record stores the function name fi,j and a concrete teacher example Ei,j , and is optionally augmented with the API documentation doc(fi,j ) that specifies the argument and response schema. The example Ei,j comprises the executable invocation together with its surrounding context, along with any returned observation when available. This context makes the rationale for the call apparent, namely why the function was invoked at that step and what constraints govern its arguments. Together these form a function memory entry mfi,jn = (fi,j , Ei,j , doc(fi,j )). Unlike the workflow and subtask banks queried through dense vector similarity, function entries are indexed by

|DT |

+ Mwf = {mwf i }i=1 provides the student agent with a high-level task plan before execution begins, enabling it to identify the relevant tools and establish a coherent action sequence.

Subtask Memory Subtask memory provides concrete behavioral examples at an intermediate level of granularity, bridging the gap between highlevel workflow plans and low-level tool calls. For T , we decomeach successful trajectory τiT ∈ D+ 4

function name fi,j , constituting the memory bank S|DT | i Mf n = i=1+ {mfi,jn }Jj=1 . 3.3

messaging, and payment services via Python API calls. The unit of action is a block of Python code executed in a stateful interpreter, and success is measured by database-state unit tests. We evaluate on the test_normal subset consisting of 168 tasks. BFCL V3 (Patil et al., 2025) is a function-calling benchmark that evaluates an agent’s ability to invoke the correct functions with accurate arguments. Each action of the agent is a structured function call, and user turns are pre-specified. An entry is correct only if every turn matches the expected API state and a minimal viable call path. We use the multi-turn base subset of 200 tasks. ToolSandbox (Lu et al., 2024) is a stateful, conversational tool-use benchmark where tools depend on a shared world state and on prior tool calls. Each action of the agent is a JSON tool call, with an LLMsimulated user driving the dialogue. Trajectories are scored against human-authored milestones and minefields. We evaluate on the base subset of 129 scenarios, using GPT-5-mini as the user simulator.

Memory Retrieval and Injection

At inference time, π S retrieves relevant memories from M via embedding-based cosine similarity, where all memory entries are pre-encoded using a pretrained text embedding model. Memories below a minimum similarity threshold are discarded. Proactive Injection Workflow and Subtask memories are injected once at the beginning of each task, before the agent begins execution. For Workflow memory, the task instruction serves as the retrieval query, and the top-k entries are retrieved from Mwf . The retrieved insight is prepended to the system prompt, providing π S with a high-level plan before it issues any tool calls. For Subtask memory, a student π S first decomposes the task instruction into an ordered sequence of subtask labels (up to six). Each subtask label is used as an independent retrieval query against Mst , and the best-matching memory mst is retrieved per subtask with deduplication across subtasks to avoid redundant examples. The retrieved segments, including their execution examples and observations, are injected alongside Workflow in the system prompt.

Baselines We compare AMD against the teacher agent and student Zero-shot performance, as well as three representative agent memory frameworks adapted to the teacher-to-student transfer setting. ReasoningBank (Ouyang et al., 2025) represents a flat, task-level memory approach that retrieves a single reasoning insight per task. MemP (Fang et al., 2025) organizes memory into hierarchical procedural abstractions, but is designed for samemodel self-evolution rather than cross-model transfer. SASM (Shen et al., 2026) introduces subtasklevel retrieval granularity, but applies a single uniform memory type without distinguishing between planning, execution, and error-recovery knowledge. Memory is generated from the same set of teacher trajectories and applied at student inference time following each method’s proposed protocol.

Reactive Injection Function memory is retrieved reactively in response to execution failures. When a tool call returns an error, the name of the failing function is used to look up candidate records in Mf n , which is indexed by function name. When multiple records exist for the same function, they are ranked by the cosine similarity between the current task instruction and the stored reasoning of each record, and the top examples are selected. The retrieved records are formatted as a hint block and appended to the error message in the current context, providing π S with targeted corrective guidance at the moment of failure without inflating the context during successful execution.

4

Experiment

4.1

Experimental Setup

Implementation Details We use GPT-5-mini as the teacher agent and evaluate four student models: Qwen3-4B, Qwen3-8B (Yang et al., 2025), Gemma4-E4B (Google DeepMind, 2026), and Llama3.1-8B (Grattafiori et al., 2024). Memory entries are encoded using OpenAI’s text-embedding-3-small model. At inference time, we retrieve the top-1 Workflow memory entry and the top-1 Subtask segment per decomposed subtask, and the top-1 Function memory record per failing function call (k = 1). To ensure robust evaluation, each experiment was repeated twice, and their average performance is reported.

Benchmarks We evaluate AMD on three benchmarks that cover diverse tool-use settings. AppWorld (Trivedi et al., 2024) is a multi-app agent benchmark in which an agent must complete complex, multi-step tasks by interacting with a set of simulated real-world applications such as email, 5

Method

AppWorld BFCL V3 ToolSandbox Average

Teacher Agent GPT-5-mini

50.00

36.50

28.68

38.39

Student Agents Qwen3-4B Zero-shot ReasoningBank MemP SASM AMD ∆

14.88 10.71 16.67 15.48 49.40 +34.52

15.50 24.25 28.25 15.25 38.50 +23.00

16.28 16.28 14.73 18.22 20.16 +3.88

15.55 17.08 19.88 16.32 36.02 +20.47

Gemma4-E4B Zero-shot ReasoningBank MemP SASM AMD ∆

24.40 30.36 20.83 22.02 54.17 +29.77

37.25 40.25 35.25 36.75 46.00 +8.75

18.22 15.12 15.89 12.40 21.71 +3.49

26.62 28.58 23.99 23.72 40.63 +14.00

Qwen3-8B Zero-shot AMD ∆

25.60 51.79 +26.19

38.00 45.50 +7.50

20.16 25.58 +5.42

27.92 40.96 +13.04

Llama3.1-8B Zero-shot AMD ∆

8.93 27.38 +18.45

9.00 14.50 +5.50

5.43 6.20 +0.77

7.79 16.03 +8.24

4.2

Num. Steps

Table 1: Main results across three benchmarks. ∆ shows absolute accuracy gains of AMD over zero-shot.

28 24 20 16 12 8

AppWorld

12

BFCL V3

8 4 Qwen3-4B Gemma4-E4B ReasoningBank SASM AMD MemP

Qwen3-4B Gemma4-E4B

Teacher Zero-shot

Figure 3: Interaction steps on two benchmarks. AMD brings the student’s turn count closer to the teacher’s, particularly where the zero-shot gap is large.

8B (51.79%) surpass GPT-5-mini performance (50.00%) with AMD while Qwen3-4B shows comparable performance (49.40%) with the teacher. Moreover, on BFCL V3, three students outperform the teacher, and this advantage persists in aggregate: Gemma4-E4B (40.63%) and Qwen3-8B (40.96%) exceed the teacher’s average accuracy (38.39%). Together, these results indicate that the student is not merely imitating the teacher’s trajectories, instead, AMD distills transferable decision-making patterns that each student re-instantiates under its own inductive biases, allowing the distilled behavior to exceed the source of supervision.

Experimental Results

We report the evaluation results across all benchmarks and student models in Table 1. AMD consistently outperforms all baselines in every model and benchmark, highlighting the effectiveness of hierarchical memory distillation from a teacher agent.

Interaction Efficiency Beyond accuracy, AMD also shapes the student’s interaction efficiency in a manner consistent with the teacher. As shown in Figure 3, on AppWorld, zero-shot students issue far more turns than the teacher (e.g., 23.8 vs. 10.1 for Qwen3-4B), reflecting inefficient exploration without prior knowledge. AMD substantially reduces this gap, bringing the student’s turn count much closer to the teacher’s (14.9 for Qwen3-4B, 7.2 for Gemma4-E4B). On BFCL V3, where the zero-shot turn counts already align closely with the teacher’s (around 8 to 11 turns), AMD preserves this efficiency without significant change. This pattern suggests that AMD transfers not only what to do but also how efficiently to do it, and the degree of alignment tracks the original gap between teacher and zero-shot student behavior.

AMD vs. Baselines AMD achieves average accuracy gains of 27.2%p, 11.2%p, and 3.4%p over zero-shot across the four student models on AppWorld, BFCL V3, and ToolSandbox, respectively. In contrast, the three baseline memory methods yield inconsistent improvements and, in several cases, degrade performance relative to zero-shot. For instance, ReasoningBank reduces Qwen3-4B accuracy on AppWorld from 14.88% to 10.71%, while MemP and SASM show similarly unstable behavior across models. These results suggest that directly transferring flat or inadequately structured teacher memory may introduce noise or exceed the comprehension and instruction-following capabilities of smaller students. AMD mitigates these limitations by organizing teacher knowledge hierarchically across multiple granularities and using representations appropriate for each memory level, making the transferred knowledge more accessible to the student agent.

5

Analysis

5.1

Ablation on Memory Components

We report the contribution of each memory component by incrementally adding Workflow, Subtask, and Function memories on top of each other in Table 2. Workflow memory alone yields consistent gains over zero-shot across both benchmarks, providing the student with a task-level plan before execution. Adding Subtask memory produces the

Matching and Surpassing the Teacher AMD enables small student models to achieve teacherlevel performance on several benchmarks. On AppWorld, Gemma4-E4B (54.17%) and Qwen36

Table 2: Ablation study across models and benchmarks. WF, ST, and FN denote workflow, subtask, and function memory. AppWorld

Method

BFCL V3

Qwen3-4B Qwen3-8B LLaMA3.1-8B Gemma4-E4B Qwen3-4B Qwen3-8B LLaMA3.1-8B Gemma4-E4B 25.60

8.93

24.40

15.50

38.00

9.00

37.25

WF WF + FN WF + ST WF + ST + FN

22.02 24.11 47.02 49.40

30.36 33.93 51.19 51.79

11.31 14.88 30.36 27.38

30.36 40.48 53.57 54.17

35.50 35.50 37.50 38.50

40.00 41.50 45.50 45.50

11.50 12.50 14.00 14.50

45.50 46.00 45.00 46.00

Student Memory

16.07

29.76

8.93

25.60

27.00

43.00

9.50

44.50

Zero-shot

Ours

Gain 40

Table 3: Effect of teacher agents on AppWorld. GPT5-mini shows the strongest transfer effectiveness for Qwen3-4B student. Teacher Zero-shot GPT-5.5 DeepSeek V4 Pro GPT-5-mini Qwen3-32B

Teacher Acc

Qwen3-4B

Qwen3-8B

-

14.88

25.60

91.08 81.55 50.00 34.42

47.02 38.10 49.40 29.76

58.93 57.14 51.79 39.29

1.7B

4B 8B 14B Student Model Size

30 20 10 0

Figure 4: Effect of student model size on AMD performance. Accuracy increases with model size, while accuracy gain peaks at 4B.

largest incremental improvement, particularly on AppWorld (e.g., +25.0%p for Qwen3-4B over WF alone), confirming that concrete behavioral examples at the subtask level are the most critical component for complex, long-horizon tasks. Function memory contributes additional gains when combined with Workflow and Subtask, though its effect is smaller in magnitude. We also compare against a variant that uses student-generated memories in place of teacher memories (Student Memory), which yields results close to zero-shot performance on AppWorld and substantially below AMD on both benchmarks. This confirms that the quality and completeness of the teacher’s trajectories are essential: the student’s own experience, being less reliable, does not provide the structured knowledge necessary for effective memory-guided execution. 5.2

60 50 40 30 20 10 0

Acc. Gain (%p)

14.88

Accuracy (%)

Zero-shot

dent performance (49.40%), outperforming even DeepSeek V4 Pro (38.10%) despite its substantially lower teacher accuracy. These results indicate that AMD substantially mitigates the capability gap, although a modest gap remains between the 4B student and the teacher models, suggesting room for further refinement of memory distillation. 5.3

Effect of Student Model Size

Figure 4 shows AppWorld accuracy as a function of student model size within the Qwen3 family (1.7B to 14B), using GPT-5-mini as the teacher. AMD accuracy increases consistently with model size (21.43%, 49.40%, 51.79%, and 52.68% for 1.7B, 4B, 8B, and 14B, respectively), while the accuracy gain peaks at 4B (+34.52%p) and diminishes for larger models. At 1.7B, the student’s limited capacity constrains its ability to effectively utilize the injected memories, resulting in modest absolute accuracy despite a non-trivial gain over the zero-shot baseline. At 8B and 14B, AMD accuracy matches and even slightly surpasses the teacher’s performance level (50.00% on AppWorld), with marginal room for further improvement at this scale. Together, these results indicate that AMD is effective across a range of student model sizes, with the largest relative benefit accruing to models around 4B that are capable enough to leverage the transferred knowledge while still having substantial room for improvement over their relatively low zero-shot baseline.

Effect of Teacher Agent

We report the effect of substituting different teacher agents on AppWorld in Table 3. For the stronger Qwen3-8B student, teacher accuracy is a reliable predictor of distillation quality: GPT-5.5 (91.08%) yields the highest student accuracy (58.93%), followed by DeepSeek V4 Pro (81.55%, 57.14%), GPT-5-mini (50.00%, 51.79%), and Qwen3-32B (34.42%, 39.29%). A more accurate teacher completes more tasks successfully, supplying a larger and higher-quality pool of successful trajectories from which richer memories are extracted. For the weaker Qwen3-4B student, however, this ordering breaks down: GPT-5-mini achieves the best stu7

Accuracy (%)

55 50 45 40 35 30

Table 4: Effect of memory representation on AppWorld. Our design choice achieves the best accuracy.

1

Workflow Subtask Function 2 3 4 Number of Memories

Function

Acc

Code Text Text Text Text

Code Code Text Code Text

Code Code Code Text Text

44.05 49.40 23.21 47.62 26.19

these results suggest that the optimal representation varies by memory granularity: high-level planning knowledge transfers best as natural language, while low-level execution knowledge is better conveyed through concrete code.

Effect of Retrieval Count

In Figure 5, we present AppWorld accuracy as the number of retrieved memories per type is varied from 1 to 5 (Qwen3-4B, GPT-5-mini teacher). Performance at k=1 is already optimal or near-optimal for all three memory types, and increasing k generally does not improve accuracy. The effect is most pronounced for Subtask memory, where accuracy drops monotonically from 49.40% to 33.34% as k increases. Workflow memory shows a moderate decline, while Function memory remains stable across k. We attribute this degradation to the limited capacity of small student models: injecting additional lower-ranked memory entries increases the likelihood of introducing irrelevant or loosely matched content, which interferes with task execution. This highlights the importance of precise, high-confidence memory injection over breadth. 5.5

Sub-task

5

Figure 5: Effect of retrieval count k on AMD performance. Accuracy at k=1 is near-optimal for all memory types, and increasing k generally degrades performance.

5.4

Workflow

5.6

Qualitative Results

Figure 6 presents a case study on a representative AppWorld task that requires an agent to approve all pending Venmo payment requests received within the current month and subsequently withdraw the remaining balance to a designated card. This task is well-suited for illustrating the cascading contribution of each memory type, as each type resolves a distinct failure mode that the previous configuration could not address. Without any memory injection, the agent misinterprets the temporal scope of the task and processes requests beyond the current month. Workflow memory corrects this by encoding the implied temporal constraint into the procedural template. This correction, however, exposes a lower-level datetime compatibility failure that traps the agent in a self-repair loop until it exhausts its step budget. Adding Subtask memory resolves this issue by injecting a verified parsing pattern derived from successful prior trajectories. With the temporal filtering now handled correctly, the agent successfully approves the target requests but encounters a runtime error at the withdrawal stage. The agent’s self-repair attempt fails to recover, and the task remains incomplete. Function memory resolves this final failure by providing the correct API usage pattern, enabling the agent to extract the balance and complete the full task. These results demonstrate that the three memory types form a complementary hierarchy operating at distinct layers of agent competence, spanning task planning, execution strategy, and API interaction. All three are necessary for the agent to reach a correct solution on tasks requiring their combined coverage.

Impact of Memory Representation

We ablate the representation format for each memory type, comparing natural language text against a code-centric format, and report the results in Table 4. For Workflow memory, a natural language insight outperforms a code-centric format (49.40% vs. 44.05%), as task-level strategies are more naturally and generalizably expressed in prose. For Subtask memory, the code-centric format, which pairs a brief textual description with concrete executable code blocks, outperforms a purely natural language description (49.40% vs. 23.21%). Executable examples provide unambiguous, directly actionable patterns for API invocation that small models can follow more reliably than abstract descriptions. Replacing Function memory with natural language also degrades performance (47.62% vs. 49.40%), and replacing all three types with natural language yields a large drop (26.19%), underscoring the importance of retaining concrete code examples at the subtask and function levels. Together, 8

6

Conclusion

which teacher best suits a given student, thus remains an open problem for future work.

We presented Agent Memory Distillation (AMD), a training-free framework for transferring teacher agent experiences to small student agents through hierarchically structured memory. We first identified that naive memory transfer yields only marginal improvements due to the capability gap between teacher and student agents, and showed that this gap cannot be bridged by simply providing high-quality teacher memories. AMD addresses this by constructing three complementary memory types at different levels of task granularity: Workflow memory for high-level planning, Subtask memory for concrete behavioral references, and Function memory for fine-grained tool invocation guidance. Experiments across three benchmarks with four student models demonstrate that AMD consistently outperforms zero-shot baselines and all memory-based baselines, with some students approaching or even surpassing teacherlevel performance. Ablation studies further confirm that each memory type contributes distinctly to knowledge transfer, and that effective distillation requires careful alignment between memory complexity and student capacity. We hope AMD provides a foundation for future research on scalable and training-free knowledge transfer for small language model agents.

References Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, and 1 others. 2023. Gpt-4 technical report. arXiv preprint arXiv:2303.08774. Marc-Antoine Allard, Arnaud Teinturier, Victor Xing, and Gautier Viaud. 2026. Experiential reflective learning for self-improving llm agents. arXiv preprint arXiv:2603.24639. Gheorghe Comanici, Eric Bieber, Mike Schaekermann, Ice Pasupat, Noveen Sachdeva, Inderjit Dhillon, Marcel Blistein, Ori Ram, Dan Zhang, Evan Rosen, and 1 others. 2025. Gemini 2.5: Pushing the frontier with advanced reasoning, multimodality, long context, and next generation agentic capabilities. arXiv preprint arXiv:2507.06261. Liang Ding. 2026. Agenther: Hindsight experience replay for llm agent trajectory relabeling. arXiv preprint arXiv:2603.21357. Pengfei Du. 2026. Memory for autonomous llm agents: Mechanisms, evaluation, and emerging frontiers. arXiv preprint arXiv:2603.07670. Runnan Fang, Yuan Liang, Xiaobin Wang, Jialong Wu, Shuofei Qiao, Pengjun Xie, Fei Huang, Huajun Chen, and Ningyu Zhang. 2025. Memp: Exploring agent procedural memory. arXiv preprint arXiv:2508.06433.

Limitations First, AMD is evaluated only on text-based tool-use benchmarks that involve Python APIs or structured function calls, so its generalization to less structured agentic settings remains unverified. Such settings include multimodal environments in which agents must ground actions in visual observations, as well as coding tasks, where the action space is not a fixed set of callable operations but open-ended code that the agent must generate from scratch. Second, memory is constructed offline from a fixed set of teacher trajectories and remains frozen at inference time. The framework therefore cannot incorporate the student’s own successes and failures at test time, nor can it adapt to distribution shifts between the teacher’s demonstrations and the tasks the student actually encounters. Finally, AMD depends on the quality and suitability of the teacher trajectories. As shown in Table 3, a stronger teacher does not always yield larger student gains, since the benefit also hinges on teacher–student compatibility. Adaptive teacher selection, that is, determining

Google DeepMind. 2026. Gemma 4 e4b instruct. https://huggingface.co/google/ gemma-4-E4B-it. Accessed: 2026-05-25. Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad AlDahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, and 1 others. 2024. The llama 3 herd of models. arXiv preprint arXiv:2407.21783. Yuxian Gu, Li Dong, Furu Wei, and Minlie Huang. 2024. Minillm: Knowledge distillation of large language models. In International Conference on Learning Representations, volume 2024, pages 32694–32717. Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Peiyi Wang, Qihao Zhu, Runxin Xu, Ruoyu Zhang, Shirong Ma, Xiao Bi, and 1 others. 2025. Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning. arXiv preprint arXiv:2501.12948. Jia Guo, Minghao Chen, Yao Hu, Chen Zhu, Xiaofei He, and Deng Cai. 2020. Reducing the teacher-student gap via spherical knowledge distillation. arXiv preprint arXiv:2010.07485.

9

Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. 2015. Distilling the knowledge in a neural network. arXiv preprint arXiv:1503.02531.

Seyed Iman Mirzadeh, Mehrdad Farajtabar, Ang Li, Nir Levine, Akihiro Matsukawa, and Hassan Ghasemzadeh. 2020. Improved knowledge distillation via teacher assistant. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pages 5191–5198.

Cheng-Yu Hsieh, Chun-Liang Li, Chih-Kuan Yeh, Hootan Nakhost, Yasuhisa Fujii, Alex Ratner, Ranjay Krishna, Chen-Yu Lee, and Tomas Pfister. 2023. Distilling step-by-step! outperforming larger language models with less training data and smaller model sizes. In Findings of the Association for Computational Linguistics: ACL 2023, pages 8003–8017.

Siru Ouyang, Jun Yan, I Hsu, Yanfei Chen, Ke Jiang, Zifeng Wang, Rujun Han, Long T Le, Samira Daruki, Xiangru Tang, and 1 others. 2025. Reasoningbank: Scaling agent self-evolving with reasoning memory. arXiv preprint arXiv:2509.25140.

Michael Y Hu, Benjamin Van Durme, Jacob Andreas, and Harsh Jhamtani. 2025. Sample-efficient online learning in lm agents via hindsight trajectory rewriting. arXiv preprint arXiv:2510.10304.

Shishir G. Patil, Huanzhi Mao, Charlie Cheng-Jie Ji, Fanjia Yan, Vishnu Suresh, Ion Stoica, and Joseph E. Gonzalez. 2025. The berkeley function calling leaderboard (bfcl): From tool use to agentic evaluation of large language models. In Forty-second International Conference on Machine Learning.

Humaid Ibrahim, Nikolai Rozanov, and Marek Rei. 2025. Fine-tuning with rag for improving llm learning of new skills. arXiv preprint arXiv:2510.01375.

Jiahao Qiu, Xinzhe Juan, Yimin Wang, Ling Yang, Xuan Qi, Tongcheng Zhang, Jiacheng Guo, Yifu Lu, Zixin Yao, Hongru Wang, and 1 others. 2025. Agentdistill: Training-free agent distillation with generalizable mcp boxes. arXiv preprint arXiv:2506.14728.

Minki Kang, Jongwon Jeong, Seanie Lee, Jaewoong Cho, and Sung Ju Hwang. 2026. Distilling llm agent into small models with retrieval and code tools. Advances in Neural Information Processing Systems, 38:106501–106538.

Victor Sanh, Lysandre Debut, Julien Chaumond, and Thomas Wolf. 2019. Distilbert, a distilled version of bert: smaller, faster, cheaper and lighter. arXiv preprint arXiv:1910.01108.

Kangsan Kim, Minki Kang, Taeil Kim, Yanlai Yang, Mengye Ren, and Sung Ju Hwang. 2026. Memory transfer learning: How memories are transferred across domains in coding agents. arXiv preprint arXiv:2604.14004.

Kangning Shen, Jingyuan Zhang, Chenxi Sun, Wencong Zeng, and Yang Yue. 2026. Structurally aligned subtask-level memory for software engineering agents. arXiv preprint arXiv:2602.21611.

Yusheng Liao, Shuyang Jiang, Yanfeng Wang, and Yu Wang. 2025. Reflectool: Towards reflectionaware tool-augmented clinical agents. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 13507–13531.

Weizhou Shen, Chenliang Li, Hongzhan Chen, Ming Yan, Xiaojun Quan, Hehong Chen, Ji Zhang, and Fei Huang. 2024. Small llms are weak tool learners: A multi-llm agent. In Proceedings of the 2024 conference on empirical methods in natural language processing, pages 16658–16680.

Jun Liu, Zhenglun Kong, Peiyan Dong, Changdi Yang, Tianqi Li, Hao Tang, Geng Yuan, Wei Niu, Wenbin Zhang, Pu Zhao, and 1 others. 2025. Structured agent distillation for large language model. arXiv preprint arXiv:2505.13820.

Noah Shinn, Federico Cassano, Ashwin Gopinath, Karthik Narasimhan, and Shunyu Yao. 2023. Reflexion: Language agents with verbal reinforcement learning. Advances in neural information processing systems, 36:8634–8652.

Jiarui Lu, Thomas Holleis, Yizhe Zhang, Bernhard Aumayer, Feng Nan, Felix Bai, Shuang Ma, Shen Ma, Mengyu Li, Guoli Yin, Zirui Wang, and Ruoming Pang. 2024. Toolsandbox: A stateful, conversational, interactive evaluation benchmark for llm tool use capabilities. Preprint, arXiv:2408.04682.

Xiangru Tang, Tianrui Qin, Tianhao Peng, Ziyang Zhou, Daniel Shao, Tingting Du, Xinming Wei, Peng Xia, Fang Wu, He Zhu, and 1 others. 2025. Agent kb: Leveraging cross-domain experience for agentic problem solving. arXiv preprint arXiv:2507.06229. Harsh Trivedi, Tushar Khot, Mareike Hartmann, Ruskin Manku, Vinty Dong, Edward Li, Shashank Gupta, Ashish Sabharwal, and Niranjan Balasubramanian. 2024. Appworld: A controllable world of apps and people for benchmarking interactive coding agents. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 16022–16076.

Jinghao Luo, Yuchen Tian, Chuxue Cao, Ziyang Luo, Hongzhan Lin, Kaixin Li, Chuyi Kong, Ruichao Yang, and Jing Ma. 2026. From storage to experience: A survey on the evolution of llm agent memory mechanisms. Yuanjie Lyu, Chengyu Wang, Jun Huang, and Tong Xu. 2025. From correction to mastery: Reinforced distillation of large language model agents. arXiv preprint arXiv:2509.14257.

Zora Zhiruo Wang, Jiayuan Mao, Daniel Fried, and Graham Neubig. 2024. Agent workflow memory. arXiv preprint arXiv:2409.07429.

10

Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed H. Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. 2022. Emergent abilities of large language models. Trans. Mach. Learn. Res., 2022.

Longtao Zheng, Rundong Wang, Xinrun Wang, and Bo An. 2024. Synapse: Trajectory-as-exemplar prompting with memory for computer control. In International Conference on Learning Representations, volume 2024, pages 19036–19066.

Yaxiong Wu, Sheng Liang, Chen Zhang, Yichao Wang, Yongyue Zhang, Huifeng Guo, Ruiming Tang, and Yong Liu. 2025. From human memory to ai memory: A survey on memory mechanisms in the era of llms. arXiv preprint arXiv:2504.15965. Siyu Xia, Zekun Xu, Jiajun Chai, Wentian Fan, Yan Song, Xiaohan Wang, Guojun Yin, Wei Lin, Haifeng Zhang, and Jun Wang. 2025. From experience to strategy: Empowering llm agents with trainable graph memory. arXiv preprint arXiv:2511.07800. Haoyuan Xu, Chang Li, Xinyan Ma, Xianhao Ou, Zihan Zhang, Tao He, Xiangyu Liu, Zixiang Wang, Jiafeng Liang, Zheng Chu, and 1 others. 2026. The evolution of tool use in llm agents: From singletool call to multi-tool orchestration. arXiv preprint arXiv:2603.22862. Wenda Xu, Rujun Han, Zifeng Wang, Long Le, Dhruv Madeka, Lei Li, William Wang, Rishabh Agarwal, Chen-Yu Lee, and Tomas Pfister. 2025. Speculative knowledge distillation: Bridging the teacher-student gap through interleaved sampling. In International Conference on Learning Representations, volume 2025, pages 64616–64646. An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, and 1 others. 2025. Qwen3 technical report. arXiv preprint arXiv:2505.09388. Guibin Zhang, Haotian Ren, Chong Zhan, Zhenhong Zhou, Junhao Wang, He Zhu, Wangchunshu Zhou, and Shuicheng Yan. 2025. Memevolve: Metaevolution of agent memory systems. arXiv preprint arXiv:2512.18746. Shengtao Zhang, Jiaqian Wang, Ruiwen Zhou, Junwei Liao, Yuchen Feng, Zhuo Li, Yujie Zheng, Weinan Zhang, Ying Wen, Zhiyu Li, and 1 others. 2026. Memrl: Self-evolving agents via runtime reinforcement learning on episodic memory. arXiv preprint arXiv:2601.03192. Andrew Zhao, Daniel Huang, Quentin Xu, Matthieu Lin, Yong-Jin Liu, and Gao Huang. 2024a. Expel: Llm agents are experiential learners. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 38, pages 19632–19642. Hao Zhao, Maksym Andriushchenko, Francesco Croce, and Nicolas Flammarion. 2024b. Is in-context learning sufficient for instruction following in llms? arXiv preprint arXiv:2405.19874.

11

A

Algorithmic Details

cause the model to deviate from the planned execution rather than correct its behavior. This observation is consistent with the general finding that weaker models benefit less from additional memory injection when their comprehension capacity is already near its limit. For Gemma4-E4B, adding FN memory consistently improves performance across both benchmarks and all configurations. On AppWorld, for instance, accuracy rises from 30.36% under WF to 40.48% under WF+FN. This suggests that the model has a relatively stronger capacity for incorporating reactive error-correction guidance than models of similar scale. Across all models, the Student Memory variant yields results close to zero-shot on AppWorld and substantially below AMD on both benchmarks. This confirms that the quality of teacher trajectories is a critical factor. The student’s own experience is dominated by unsuccessful trajectories and therefore does not provide the structured and reliable knowledge necessary for effective memory-guided execution.

Algorithm 1 presents the complete AMD inference pipeline. At the beginning of each task, the student agent π S retrieves the top-k workflow memory entry from Mwf using the task instruction s as the retrieval query, and the retrieved insight is prepended to the system prompt. π S then decomposes s into an ordered sequence of subtask labels T = {t1 , . . . , tL }, each of which is used as an independent retrieval query against Mst . Deduplication is applied across retrieved segments to prevent the same segment from being injected multiple times when multiple subtask labels map to the same memory entry. Both the workflow insight and the retrieved subtask segments are injected into the system prompt before any tool calls are issued. During the execution loop, each tool call ai ∈ F is conditioned on the preceding observation oi−1 . When oi−1 reports an error, the failing function names are extracted from it. The extracted names serve as the query for looking up candidate records in Mf n . The retrieved records are then added to the context used to generate ai . When multiple records exist for the same function, they are ranked by the cosine similarity between the current task context, and the top-k examples are formatted as a hint block. This reactive injection is applied only upon failure, so that the context is not inflated during successful execution. The loop continues until the task is marked complete or the maximum number of steps Tmax is reached.

B

Additional Experiment Results

B.1

Impact of Each Memory Type

B.2

Detailed Case Studies by Memory Type

Figure 7, Figure 8, Figure 9 present three representative case studies corresponding to workflow, subtask, and function memory, respectively, illustrating how injected memory alters the agent’s behavior. In each case, the agent without memory and the agent with memory both reach the same intermediate state, but only the memory-augmented agent selects the correct next action. Without memory, the Qwen3-4B agent receives only the task instruction and lacks the procedural knowledge to act on it. These cases show that each failure is resolved when the teacher-generated memory provides the specific procedural knowledge that the small model is missing, such as a planning step, an API call sequence, or a response structure.

Table 2 presents the full ablation results across all four student models on AppWorld and BFCL V3. The contribution ordering holds for almost every model and benchmark. Subtask (ST) memory provides the largest incremental gain when added on top of Workflow (WF) memory, and Function (FN) memory contributes additional but smaller improvements. Several model-specific patterns are worth noting. For LLaMA3.1-8B on AppWorld, adding FN memory to the WF+ST configuration decreases accuracy from 30.36% to 27.38%, a trend not observed in the other models. We attribute this to the relatively weaker instruction-following capacity of LLaMA3.1-8B. The additional context introduced by Function memory during error recovery may

Workflow Memory. Workflow memory captures high-level planning strategies and it is injected upfront before execution begins. In Figure 7, the agent without memory parses the trip note but does not know the intermediate step of resolving names into contact identities, so it calls a non-existent API and then repeatedly revisits the same API documentation until reaching the step limit. Injecting the workflow memory supplies the identity resolution procedure, enabling the agent to map all names and complete the transactions in substantially fewer 12

Algorithm 1 AMD: Student Agent Inference with Hierarchical Memory S S Require: Task s, student agent π S (decomposer πdecomp , coder πcoder ), memories Mwf , Mst , Mf n , retrieval count k, threshold δ, max subtasks N Ensure: Trajectory τ = {(a1 , o1 ), . . . , (aT , oT )}

1: m ← [ ]

▷ Initialize message history

// Proactive injection: once per task, before execution 2: H wf ← Mwf.retrieve(s, k, δ) 3: if H wf ̸= ∅ then m.append([Workflow] H wf ) 4: end if S 5: {t1 , . . . , tL } ← πdecomp (s, N )

▷ Retrieve workflow memory ▷ Inject workflow memory

▷ Decompose s into subtask labels ▷ Initialize subtask memory

st

6: H ← ∅ 7: for each subtask label tl do 8: Rlst ← Mst.retrieve(tl , k, δ)

9: H st ← H st ∪ { e ∈ Rlst : e.label ∈ / H st .labels } 10: end for 11: if H st ̸= ∅ then m.append([Subtask] H st ) 12: end if

▷ Top-k segments by similarity to tl ▷ Accumulate, dedup by label ▷ Inject subtask memory

// Execution loop: reactive injection on error 13: o0 ← ε

▷ No prior observation

14: repeat 15: Hfn ← ∅ 16: if DetectError(oi−1 ) then 17: f ← ExtractFuncNames(oi−1 ) 18: H f n ← Mf n.retrieve(f, k) 19: end if

▷ Initialize function memory ▷ Failing function names ▷ Lookup by function name

if H f n ̸= ∅ then S ai ← πcoder (m ∥ [Function] H f n ) else S ai ← πcoder (m) end if 25: oi ← Execute(ai ) 26: m.append(ai ); m.append(oi ) 27: until task complete or max steps reached 28: return τ 20: 21: 22: 23: 24:

▷ Coder with function memory ▷ Coder without function memory ▷ Run tool call ▷ Log action & observation

steps.

$391 withdrawal. The function memory provides a multi-key parser derived from the teacher’s successful call, so the agent reads the correct response field on the first attempt and completes the withdrawal.

Subtask Memory. Subtask memory records correct API call sequences for sub-goals and it is also injected upfront. In Figure 8, the agent without memory calls the wrong API endpoint and retrieves only a single page, producing an incorrect total of $341 instead of the correct $833. The subtask memory identifies the correct API call with a pagination loop, allowing the agent to retrieve all pages and compute the accurate total.

B.3

Robustness of Distilled Memory under Disjoint Evaluation

In our main experiments, memory is distilled and applied within the same benchmark. This raises a natural question about whether the observed gains reflect the real utility of the distilled memory, or whether a task could simply be benefiting from memory derived from the same task. To answer this, we evaluate our method under two protocols in which the tasks used to build memory are kept separate from those used at evaluation, so that every gain comes only from memory distilled from other

Function Memory. Function memory provides a successful API call example from the teacher when the student’s API call fails, serving as an on-demand correction at the point of failure. In Figure 9, the agent without memory parses the API response with the wrong key and silently skips a 13

C

tasks. All experiments in this section use Qwen34B as the student model.

Memory Generation For Workflow memory generation, we use the prompt shown in Figure 13. The teacher LLM is instructed to produce a single short insight describing the overall task-completion strategy at a high level, covering the apps and tools involved, key preconditions, decision rules, validation cues, and common failure patterns to avoid, and explicitly mentioning key API functions in app.function_name form. Concrete runtime values such as user IDs, credentials, and file paths are replaced with typed placeholders (e.g., <ID>, <EMAIL>, <FILE_PATH>), so that the insight remains applicable to future tasks with different specific inputs. For Subtask memory segmentation, we use the prompt shown in Figure 14. The teacher LLM is prompted to identify semantic boundaries within the trajectory and to produce, for each resulting segment, a short phrase label and a onesentence description. To guide this process, we additionally provide the teacher LLM with rule-based breakpoint hints derived from API call boundaries, and the prompt recommends keeping the number of subtask segments per trajectory to at most six. For Function memory, each memory stores the function name together with a concrete example drawn from a successful teacher trajectory. This example comprises the function call and its surrounding context, from which the rationale for the call can be inferred. For benchmarks with rich API documentation such as AppWorld, we additionally attach the corresponding argument and response schema to each memory. For benchmarks with minimal tool schemas, such as BFCL V3 and ToolSandbox, each memory uses only the concrete example drawn from the successful teacher trajectory.

Cross-split evaluation We split each benchmark into disjoint memory-construction and evaluation subsets at a 7:3 ratio, distill memory from the memory-construction subset alone, and test on the held-out evaluation subset. Self-excluded retrieval We distill memory over the full benchmark, but during evaluation, each task retrieves memory distilled from other tasks, never its own. Compared to the cross-split setup, this preserves a larger memory pool while ensuring that no task uses memory distilled from itself. Results Table 6 reports success rates for both protocols on AppWorld, BFCL V3, and ToolSandbox. Both protocols preserve monotonic gains from Zero-shot to WF, WF+ST, and WF+ST+FN, and the full configuration clearly outperforms the Zeroshot baseline on every benchmark. Since no task can rely on memory from itself in either setup, these results indicate that the improvements come from the utility of the distilled memory rather than from memory construction and evaluation sharing the same tasks. On AppWorld, self-excluded retrieval slightly outperforms cross-split evaluation, which is consistent with the larger memory pool available when distilling over the full task set. We further note that the full configuration (WF+ST+FN) results under both protocols stay close to the final AMD accuracy for Qwen3-4B in the main results (Table 1), indicating that AMD retains substantial gains even when memory construction and evaluation are disjoint. B.4

Additional Implementation Details

Robustness of Distilled Memory across Repeated Runs

Memory Retrieval All memory entries are encoded using OpenAI’s text-embedding-3-small model. Retrieval is performed via cosine similarity between the query embedding and all stored memory embeddings. A minimum similarity threshold δ is applied, below which candidates are discarded. We set k=1 for all three memory types in the main experiments, retrieving the top-1 Workflow entry, the top-1 Subtask segment per decomposed subtask label, and the top-1 Function record per failing function. Deduplication is applied across retrieved Subtask segments to prevent the same segment from being injected multiple times when multiple subtask labels map to the same memory entry.

We assess run-to-run robustness by repeating the zero-shot and AMD configurations five times under the same experimental setup, using Qwen3-4B as the student model. Table 5 reports the mean and standard deviation of the success rate across the five runs. AMD achieves higher mean success rates than the zero-shot baseline across all three benchmarks. The standard deviations remain below one percentage point in all settings and are substantially smaller than the corresponding mean improvements, demonstrating that AMD’s gains are stable across repeated runs. 14

Table 5: Mean ± standard deviation of success rate (%) across five runs for each benchmark with Qwen3-4B as the student model. Method

AppWorld

BFCL V3

ToolSandbox

Zero-shot AMD

14.48 ± 0.69 49.60 ± 0.91

15.33 ± 0.76 38.67 ± 0.58

16.54 ± 0.44 20.16 ± 0.78

Table 6: Success rates under the two disjoint-evaluation protocols with Qwen3-4B as the student model. WF, ST, and FN denote workflow, subtask, and function memory. Protocol

Success Rate (%)

Memory AppWorld

BFCL V3

ToolSandbox

Cross-split evaluation

Zero-shot WF WF + ST WF + ST + FN

16.07 21.43 39.29 41.07

16.13 25.81 27.42 30.65

16.67 18.75 20.83 22.92

Self-excluded retrieval

Zero-shot WF WF + ST WF + ST + FN

14.88 23.21 40.48 46.43

15.50 22.50 30.50 31.00

16.28 19.38 20.16 23.26

D

Student Subtask Decomposition At the beginning of each task, π S is prompted to decompose the task instruction into an ordered sequence of subtask labels using the prompt shown in Figure 15. Decomposition is performed prior to any tool calls and is constrained to at most six subtasks. The resulting labels are then used as independent retrieval queries against Mst .

Memory Examples and Generation Prompts

We present concrete examples and generation details for each of the three memory types introduced in our framework. Figure 10 through Figure 12 show representative Workflow, Subtask, and Function memory entries, illustrating how successful teacher trajectories are distilled into structured, reusable knowledge at each level of granularity. We also provide the prompts used to construct these memories, namely the Workflow generation prompt in Figure 13 and the Subtask segmentation prompt in Figure 14. Finally, Figure 15 shows the prompt with which the student agent decomposes each task instruction into an ordered list of subtask labels, which then serve as queries for retrieving Subtask memory.

Benchmark-Specific Details On AppWorld, the teacher agent accesses Python API calls and a supervisor application for retrieving credentials, and we evaluate on the test-normal subset of 168 tasks. Since AppWorld provides rich API documentation, each function memory is augmented with the corresponding argument and response schema. On BFCL V3, we use the multi-turn base subset of 200 tasks, and on ToolSandbox we use the base subset of 129 tasks. Both benchmarks have only minimal, signature-derived tool schemas rather than rich documentation, so on both we build function memory solely from the concrete examples in successful teacher trajectories.

Inference All student agents are allowed a maximum of 40 interaction steps per task and are served with vLLM for efficient inference. For the Qwen3 models, we disable thinking mode during inference to ensure a fair comparison with the other student models. The teacher agent, GPT-5-mini, is queried through the OpenAI API. 15

Case Study: Cascading Effect of Each Memory Type Task ccf4b82_1: Approve all pending Venmo payment requests I have received in this month, and withdraw the remaining Venmo balance, if any, to my card ending in 8907. WF Memory

ST Memory (5 segments)

FN Memory

Always retrieve Venmo credentials from

1. retrieve passwords and login

venmo_balance_resp =

supervisor.show_account_passwords and

2. fetch pending requests

venmo.login, then paginate show_received_payment_requests (status=‘pending’) and approve only those with created_at in the current month via approve_payment_request(payment_request_id=<ID>, access_token=<TOKEN>). After approvals, call show_venmo_balance to get the numeric balance, locate the target card by matching last four digits with show_payment_cards, and call withdraw_from_venmo_balance(amount=<AMOUNT>, payment_card_id=<ID>, access_token=<TOKEN>). Validate: each approval response contains "message" and withdrawal returns bank_transfer_id. Avoid missing pagination, incorrect date parsing, or absent

show_venmo_balance(...)

while True: page = show_received_payment_requests( status=‘pending’, page_index=pi) if not page: break pending.extend(page); pi += 1 3. approve payment requests for req in pending_requests: created_dt = fromisoformat( req.get(‘created_at’)) if created_dt.year==now.year and created_dt.month==now.month: pending_this_month.append(req) ... for req in pending_this_month: pid = req.get(‘payment_request_id’) resp = approve_payment_request(pid, ...) approved_ids.append(pid)

venmo_balance = 0.0 if isinstance( venmo_balance_resp, dict): for k in (‘balance’, ‘amount’, ‘venmo_balance’, ‘current_balance’): if k in venmo_balance_resp and isinstance( venmo_balance_resp[k],(int,float)): venmo_balance= float(venmo_balance_resp[k]) break

4. withdraw balance and complete

payment_request_id.

if num.endswith(‘8907’): target_id = c[‘payment_card_id’] if venmo_balance > 0.0: withdraw_from_venmo_balance( amount=venmo_balance, payment_card_id=target_id) 5. supervisor.complete_task()

(1) Workflow Memory month-scope filter Zero-shot (✗ with 17 steps)

WF (✗ with 40 steps)

Step 6 Without a date filter, all 38 all-time pending requests are collected.

Step 3 The WF hint triggers a month filter, narrowing the list to 19 requests.

while True: page = apis.venmo.show_received_payment_requests( access_token=venmo_access_token, status=‘pending’, page_index=page_index) if not page: break payment_requests.extend(page) page_index += 1 # 38 requests (all-time); IDs 213,1992,4598,...not this month

now = datetime.now(timezone.utc) pending_this_month = [] for req in pending_requests: created_dt = datetime.fromisoformat( req.get(‘created_at’)) if (created_dt.year == now.year and created_dt.month == now.month): pending_this_month.append(req) # Found 19 pending requests created this month

(2) Subtask Memory escape parse loop and reach withdrawal WF (✗ with 40 steps)

WF+ST (✗ with 8 steps)

Steps 7–40 The date-parse loop exhausts the step limit and withdrawal is never reached.

Steps 3–4 Seg.3 supplies a working date parse and approve loop, passing all 19 requests.

# TypeError: ‘>=’ not supported # between str and FakeDatetime # 30+ retry variations; step limit (40) # exhausted –- complete_task() never called # answer = “not_given” ✗

# [ST segment #3: approve payment requests] created_dt = datetime.fromisoformat(created_at) if created_dt.year==now.year and created_dt.month==now.month: pending_this_month.append(req) # 19 requests; then approved all 19 # approved_ids: [6166,6167,...,214]

(3) Function Memory show_venmo_balance dict-key fix WF+ST (✗ with 8 steps)

WF+ST+FN (✓ with 7 steps)

Step 5 The dict response is compared as a float, causing a crash. Self-repair picks the wrong key.

Step 6 The FN teacher example iterates candidate keys, extracts $391, and completes the withdrawal.

venmo_balance = apis.venmo.show_venmo_balance( access_token=venmo_access_token) # Response: {"venmo_balance": 391.0} if venmo_balance > 0.0: # TypeError: dict > float venmo_balance[‘balance’] # KeyError: ‘balance’ (correct key: ‘venmo_balance’) # withdrawal never executed ✗

# [FN: venmo.show_venmo_balance] venmo_balance_resp = apis.venmo.show_venmo_balance(...) venmo_balance = 0.0 if isinstance(venmo_balance_resp, dict): for k in (‘balance’, ‘amount’, ‘venmo_balance’, ‘current_balance’): if k in venmo_balance_resp and isinstance( venmo_balance_resp[k], (int, float)): venmo_balance = float(venmo_balance_resp[k]) break # venmo_balance = 391.0 withdraw $391

Analysis. WF memory constrains approval to requests created within the current month, without which the baseline processes all 38 historical requests and withdraws a stale $17 instead of $391. ST memory supplies a working date-parsing pattern that resolves the timestamp type mismatch causing the WF-only agent to exhaust its 40-step budget before reaching the withdrawal step. FN memory supplies a key-iteration pattern for the show_venmo_balance response that both WF-only and WF+ST agents incorrectly pass into a float comparison, correctly extracting the balance of $391 and completing the withdrawal that passes the remaining 5 test cases.

Figure 6: Cascading Effect of Each Memory Type

16

Workflow Memory — Planning and High-level Strategy Injected memory search travel related notes, resolve names into contacts, and then send transactions. ‘. . . inspect api_docs.show_api_doc and fetch credentials first, then page through simple_note.search_notes / show_note to locate the trip note and parse lines: I owe <NAME> $<AMT> → payment, <NAME> owes me $<AMT> → request. Resolve identities via phone.search_contacts and venmo.search_users’ before calling create_transaction / create_payment_request. . . .

Both runs reach Trip note parsed, and debtor/creditor names known. Without memory (✗ with 40 steps)

With memory (✓ with 23 steps)

Step 8 Call a non-existent API without checking docs.

Step 13 Map all 8 names to contacts via phone.search_contacts.

# calls non-existent API for debtor, amount in transactions: result = apis.venmo.create_request( recipient=debtor, amount=amount, note=‘For Miami trip’) # Exception: No API named # ‘create_request’ found in venmo

# resolve all 8 names erika_c = apis.phone.search_contacts( access_token=phone_token, query=‘Erika’) troy_c = apis.phone.search_contacts( access_token=phone_token, query=‘Troy’) # ... same pattern for remaining names

Steps 10–40 Re-read the same doc 31× and never resolve contacts.

Step 14 Send all 8 transactions and requests in a single loop.

# repeated ×31 print(apis.api_docs.show_api_doc( app_name=‘venmo’, api_name=‘create_transaction’)) # step limit; 0 transactions sent

# send all 8 in one loop for t in transactions: if t[‘direction’] == ‘receive’: apis.venmo.create_payment_request( access_token=venmo_token, contact=t[‘contact’], amount=t[‘amount’], description=t[‘description’]) else: apis.venmo.create_transaction( access_token=venmo_token, contact=t[‘contact’], amount=t[‘amount’], description=t[‘description’]) # 8 payments / requests completed

Analysis Without memory, the agent could not connect parsed names to payment identities, so it got stuck and repeatedly checked the same API documentation until it hit the step limit. With memory, it followed a clear identity-resolution step, used phone.search_contacts to map names, and completed all 8 payments within 23 steps.

Figure 7: Case Study for Workflow Memory

17

Subtask Memory — Detailed Subtask Execution Example Injected memory paginate through show_received_payment_requests, filter the results by date, and sum the amounts. from datetime import datetime, timedelta today = datetime.utcnow().date() start_date = today - timedelta(days=9) # paginate all received payment requests, filter by date while True: page = apis.venmo.show_received_payment_requests( access_token=venmo_access_token, page_index=page_index, page_limit=20) if not page: break for req in page: if start_date <= created_date <= today: total_requested += float(req[‘amount’]) page_index += 1 ... apis.supervisor.complete_task(answer=total_requested)

Both runs reach Venmo login completed, payment requests fetched and filtered by date. Without memory (✗ with 9 steps)

With memory (✓ with 4 steps)

Step 6 Fetch sent requests, page 0 only.

Step 3 Paginate received requests across all pages.

sent_payment_requests = apis.venmo.show_sent_payment_requests( access_token=venmo_access_token, page_index=0, page_limit=5) # 5 results (page 0 only, wrong direction)

while True: page = apis.venmo.show_received_\ payment_requests( access_token=venmo_access_token, page_index=page_index, page_limit=20) if not page: break for req in page: if start_date <= created_date: total_requested += float( req[‘amount’]) page_index += 1 # Total: $833.00

Step 8 Sum the 5 fetched amounts. total_amount = sum( request[‘amount’] for request in filtered_requests) # Total: $341.00 (page 0 only, wrong direction)

Analysis Without memory, the agent used show_sent_payment_requests, and only retrieved the first page (page_index=0, page_limit=5), so it saw just 5 entries and incorrectly computed a total of $341. With memory, the agent correctly used show_received_payment_requests, iterated through all pages using a pagination loop, applied the correct date filter, and accurately computed the total as $833 in 4 steps.

Figure 8: Case Study for Subtask Memory

18

Function Memory — API Request and Response Structure for Error-fix Injected memory parse the response dict for the balance and extract it as a float value. venmo_balance_resp = apis.venmo.show_venmo_balance(access_token=...) # injected immediately after show_venmo_balance returns venmo_balance = 0.0 if isinstance(venmo_balance_resp, dict): for k in (‘balance’, ‘amount’, ‘venmo_balance’, ‘current_balance’): if k in venmo_balance_resp and isinstance(venmo_balance_resp[k], (int, float)): venmo_balance = float(venmo_balance_resp[k]) break # response (success): {‘venmo_balance’: 391.0}

Both runs reach show_venmo_balance function call returns {‘venmo_balance’:

391.0}

Without memory (✗ with 8 steps)

With memory (✓ with 7 steps)

Step 7 Assume key balance and hit a KeyError.

Step 6 Use the injected memory to read the balance from any key.

venmo_balance = apis.venmo.show_venmo_balance( access_token=venmo_access_token) print(f‘Venmo balance: ...’) if venmo_balance[‘balance’] > 0.0: withdraw_resp = apis.venmo.withdraw_from_venmo_balance(...) # KeyError: ‘balance’

venmo_balance_resp = apis.venmo.show_venmo_balance( access_token=venmo_access_token) venmo_balance = 0.0 if isinstance(venmo_balance_resp, dict): for k in (‘balance’, ‘amount’, ‘venmo_balance’, ‘current_balance’): if k in venmo_balance_resp and \ isinstance(venmo_balance_resp[k], (int, float)): venmo_balance = float(venmo_balance_resp[k]) break # venmo_balance: 391.0

Step 8 Recover with a membership guard, but the wrong key makes it False. if ‘balance’ in venmo_balance \ and venmo_balance[‘balance’] > 0.0: withdraw_resp = apis.venmo.withdraw_from_venmo_balance(...) else: print(‘No Venmo balance to withdraw.’) apis.supervisor.complete_task() # guard False, withdrawal skipped, $391 left

Step 7 Execute the withdrawal with the parsed value. if venmo_balance > 0.0: withdraw_resp = apis.venmo.withdraw_from_venmo_balance( amount=venmo_balance, payment_card_id=target_card_id, access_token=venmo_access_token) apis.supervisor.complete_task() # Money withdrawn from Venmo balance.

Analysis Without memory, the agent encountered a KeyError, recovered using a fallback check based on wrong key balance, and silently skipped the withdrawal, leaving $391 remaining in the account. With memory, the agent correctly applied a multi-key parser at the error point, identified the correct field venmo_balance = 391.0 on the first attempt, and completed the withdrawal successfully.

Figure 9: Case Study for Function Memory

19

Workflow Memory Example Source: teacher

Task ID: 1150ed6_3

Apps: phone, spotify, supervisor Query: Play any song released in 2020 from my Spotify playlists (use my Spotify account, ensure 〈access_token〉, enumerate playlists with paging and collect unique song IDs before starting playback). Insight: When automating cross-app work, first retrieve credentials via supervisor.show_account_passwords and inspect each endpoint with apis.api_docs.show_api_doc to confirm required params (e.g., 〈access_token〉) and response fields. Use robust paging (while True with page_index) when enumerating libraries (spotify.show_playlist_library) and collect unique IDs before calling detail endpoints (spotify.show_playlist / spotify.show_song); resolve recipients with phone.search_contacts and locate threads with phone.search_text_messages before sending via phone.send_text_message. Validation cue: always assert presence of 〈access_token〉 and that returned lists/ids are non-empty (or log raw content) before acting; common failure pattern to avoid is brittle free-text parsing of note content or assuming contact name uniqueness—fall back to scanning raw note text if parsing fails.

Figure 10: Workflow Memory Example

20

Sub-task Memory Example Task ID: 652485c_3

Segment Index: 1

Label: retrieve liked songs

Apps: spotify

Description: Fetch the list of liked songs from Spotify.

Code Block 1: Check available Spotify API descriptions. print(apis.api_docs.show_api_descriptions(app_name='spotify'))

Observation 1: Returns a list of all available Spotify API names and descriptions, including show_liked_songs, show_playlist_library, play_music, add_to_queue, etc. Code Block 2: Inspect the show_liked_songs API documentation. print(apis.api_docs.show_api_doc(app_name='spotify', api_name='show_liked_songs'))

Observation 2: API doc reveals that show_liked_songs requires access_token (string, required), and accepts optional page_index (integer, ≥ 0), page_limit (integer, 1–20), and sort_by (string). Response returns a list of song objects with song_id, title, album_id, album_title, duration, artists, and liked_at. Code Block 3: Attempt to fetch liked songs with page_limit=50 (incorrect). spotify_access_token = login_result["access_token"] liked_songs = [] page_index = 0 page_limit = 50 # Increase page limit to get more songs in fewer pages while True: page_result = apis.spotify.show_liked_songs( access_token=spotify_access_token, page_index=page_index, page_limit=page_limit ) if not page_result: break liked_songs.extend(page_result) page_index += 1 print(f"Found {len(liked_songs)} liked songs")

Observation 3: Execution failed. Exception: {"message":"Validation error.

Response status code is 422: Reason: page_limit: Input should be less than or equal to 20"}

Code Block 4: Fetch liked songs with corrected page_limit=20. spotify_access_token = login_result["access_token"] liked_songs = [] page_index = 0 page_limit = 20 # Maximum allowed page limit while True: page_result = apis.spotify.show_liked_songs( access_token=spotify_access_token, page_index=page_index, page_limit=page_limit ) if not page_result: break liked_songs.extend(page_result) page_index += 1 print(f"Found {len(liked_songs)} liked songs")

Observation 4: Found 9 liked songs

Figure 11: Sub-task Memory Example

21

Function Memory Example Function: phone.search_contacts Teacher example: # Step 2: Find Melissa in contacts using the existing phone_login_result phone_access_token = phone_login_result['access_token'] melissa_contacts = apis.phone.search_contacts(access_token=phone_access_token, query='Melissa') print(melissa_contacts)

Parameters: - access_token (string, required): Access token obtained from phone app login. - query (string, optional, default=): Search query for the contacts list. - relationship (string, optional): Relationship with the person in the contacts list to filter by. - page_index (integer, optional, default=0, value ≥ 0.0): The index of the page to return.

- page_limit (integer, optional, default=5, value ≥ 1.0, ≤ 20.0): The maximum number of results to return per page. Response (success): [{"contact_id":1,"first_name":"string","last_name":"string", "email":"user@example.com","phone_number":"string", "relationships":["string"],"birthday":"string", "home_address":"string","work_address":"string", "created_at":"2019-01-01T00:00:00"}]

Figure 12: Function Memory Example

22

Workflow Memory Build Prompt for AppWorld Tasks You are provided with an AppWorld task instruction and a trajectory of Python code steps taken to solve it. Each step shows the code the agent wrote and the output it received from the AppWorld environment. The agent called various app APIs to complete the task. Your job is to generate a retrieval-friendly memory for future similar tasks. Assume this memory is stored only for successful tasks. Rules: - Output exactly one short paragraph (2–4 sentences) as generalized insight. - Keep the wording principle-level, not task-specific script. - You MUST mention the key API functions used in app.function_name form (for example, venmo.login, venmo.show_transactions, file_system.show_directory). Include all APIs that are broadly reusable across similar tasks. - Include only APIs/actions that are supported by the trajectory evidence; do not invent unseen APIs. - Focus on decision rules and verification logic, not call-by-call steps. - Replace concrete values with placeholders when needed (for example 〈ID〉, 〈AMOUNT〉, 〈EMAIL〉). - Do not repeat or paraphrase the task goal; the query already stores the instruction. - Include at least one validation cue and one common failure pattern to avoid. - Keep it under 120 words. - Output only the paragraph (no bullets, no markdown, no extra commentary). - Your output MUST contain at least one token matching the pattern: 〈app〉.〈function〉 (e.g. venmo.login, gmail.send_email). If it does not, your response is invalid. Example output: "To transfer money on Venmo, use venmo.login to authenticate, then venmo.create_payment to send funds to <RECIPIENT_EMAIL> with <AMOUNT>. Retrieve the access token from supervisor. show_account_passwords before any API call. A common failure is using the wrong user ID instead of email; always verify the recipient identifier from venmo.get_profile first." Task Instruction: {{instruction}} Trajectory: {{trajectory}}

Figure 13: Workflow Memory Build Prompt for AppWorld Tasks

23

Sub-task Memory Segmentation Prompt for AppWorld Tasks You are analysing a successful AppWorld agent trajectory to identify natural sub-task boundaries. Task instruction: {{task_instruction}} Trajectory ({{n_steps}} steps): {{trajectory_text}} {{hint_text}} Identify the sub-task segments. Each segment should be a coherent, self-contained unit of work (e.g., "authenticate to Venmo", "find contact by name", "send payment", "verify completion"). Rules: - A segment must contain at least one step. - Steps must not overlap or be skipped; together they must cover all {{n_steps}} steps. - Use the heuristic hints as a starting point, but override them if the semantic boundary falls elsewhere (e.g., keep show_account_passwords + login together as one auth segment). - api_docs browsing steps belong to whichever segment uses the information they reveal. - supervisor.complete_task must be its own final segment. - Label: short verb-phrase (≤ 5 words), e.g. "authenticate to venmo". - Description: one sentence explaining what this segment accomplishes. Reply with ONLY a JSON array — no prose, no markdown fences: [

]

{"start_step": 1, "end_step": 3, "label": "authenticate to venmo", "description": "Retrieve credentials and log in to Venmo."}, {"start_step": 4, "end_step": 6, "label": "find contact by name", "description": "Search for the target user and retrieve their contact ID."}, ...

Figure 14: Sub-task Memory Segmentation Prompt for AppWorld Tasks

24

Student Agent Sub-Task Decompose Prompt for AppWorld Tasks Break the given task into sequential subtasks. Rules: - The FIRST subtask must always be: retrieve account passwords from Supervisor, then log in to all required apps using the credentials provided in the task. - Each subtask should be a concise description of one specific operation. - Reply with ONLY a JSON array of strings. At most {{max_subtasks}} subtasks. Examples: Task: Create a Todoist task to return my most recent Amazon order. [

]

"Log in to Supervisor to retrieve account passwords, then log in to Amazon and Todoist using the provided credentials", "Fetch the most recent Amazon order and extract its details", "Create a Todoist task with the return information for the order", "Mark the task as complete via Supervisor"

Task: Today is my daughter’s birthday. Venmo her thrice the money I sent her on her last birthday, privately, with a description note, "Many happy returns of the day!". Then leave her a phone text message, "Happy Birthday daughter! Looking forward to meet you soon!". [

]

"Log in to Supervisor to retrieve account passwords, then log in to Phone and Venmo using the provided credentials", "Search Phone contacts to find the daughter's contact and get her phone number and Venmo email", "Fetch past Venmo transactions to find the amount sent to her on her last birthday", "Send a private Venmo payment to the daughter for three times that amount with description 'Many happy returns of the day!'", "Send a phone text message to the daughter saying 'Happy Birthday daughter! Looking forward to meet you soon!'", "Mark the task as complete via Supervisor"

Task: I went on a trip with friends to Maui recently. I have maintained a note of money I owe to others and others owe me from the trip in simple note. Make private venmo payments or requests accordingly. In the payments/requests, add a note, "For Maui trip". [

]

"Log in to Supervisor to retrieve account passwords, then log in to Simple Note, Phone, and Venmo using the provided credentials", "Find the Maui trip note in Simple Note and parse who owes whom and how much", "Search Phone contacts to resolve friend names to their Venmo email addresses", "For each person I owe money to, send a private Venmo payment with note 'For Maui trip'", "For each person who owes me money, send a private Venmo payment request with note 'For Maui trip'", "Mark the task as complete via Supervisor"

Task: {{instruction}}

Figure 15: Student Agent Sub-task Decompose Prompt for AppWorld Tasks

25

Related documents

Record · ID 440386 · SHA-256 319635b2ddbdd074
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive