跪拜 Guibai
← All articles
Programmer · Product · Product Manager

WorkBuddy's Agent Architecture: Layered System Prompts, Three-Tier Memory, and Deferred Tools

By 华洛 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

For teams building agent products, the concrete takeaway is that system prompts act as a contract with backend tools, not just instructions. WorkBuddy's patterns for dynamic prompt layering, deferred tool loading, and memory tiers directly cut token waste and reduce the 'AI said it did it but didn't' failure mode.

Summary

Agents built on ReAct or LangGraph still leave product teams asking how to design the actual product. WorkBuddy, a client-first agent from the CodeBuddy team, shows one production approach in detail. Its system prompt is not a single static string but a dynamically assembled template: static base prompts for different tasks, placeholders for language, and Jinja conditionals for platform-specific rules like Windows command safety. That base prompt loads in three layers, with session-level memory snapshots and message-level injection via a special system-reminder tag that carries fresh data such as the current date.

Memory is split into three tiers. Cloud memory maintains a long-term user profile and searches past conversations; a user-level local memory stores explicit rules in files like USER.md, SOUL.md, IDENTITY.md, and a temporary BOOTSTRAP.md; workspace memory records concrete work like bug fixes and docs. Deferred tools keep the model's tool list short: instead of passing all 60+ tools as schemas, the system prompt lists them descriptively, and the agent calls ToolSearch to retrieve a specific tool's manual before executing it with DeferExecuteTool. Built-in skills similarly live in the prompt and are loaded on demand through a Skill() call.

A key principle runs through the whole design: system prompt content must match actual product capabilities. Automations, for example, are only created through an automation_update tool, never by hand, and the prompt tells the agent exactly when and how to use it. This coupling prevents the common failure where an AI says it completed a task but nothing happened. The article also details present_files for showing results and a task management set of tools, all coordinated by prompt rules.

Takeaways
— WorkBuddy's system prompts use XML tags rather than markdown; the article recommends XML for Alibaba and Tencent models.
— System prompts are built from static templates, placeholders like {{ ResponseLanguage }}, and Jinja conditionals like {% if IsWindows %}.
— Dynamic loading has three layers: static base, session-level injection (memory, environment snapshots), and message/event-level injection via <system-reminder> tags.
— Memory is organized into three tiers: cloud (user profile + conversation search), user-level (files USER.md, SOUL.md, IDENTITY.md, BOOTSTRAP.md), and workspace (records of concrete work).
— Deferred tools are listed in the system prompt but not in the model's tools parameter; the agent uses ToolSearch to fetch a tool's manual and DeferExecuteTool to execute it.
— Built-in skills are not exposed to users and are loaded via Skill(skill="...") which reads the skill's docs.
— WorkBuddy uses a present_files tool to display generated results (HTML, images, pptx, etc.) as product cards.
— Task management uses TaskCreate, TaskGet, TaskUpdate, TaskList tools; they are built-in, not deferred.
— Automation rules are enforced through an automation_update tool; the prompt forbids direct file manipulation of automations.
Conclusions

The deferred tool pattern is a pragmatic answer to token limits and attention: by listing tool descriptions in the prompt instead of full schemas, the model only spends tokens when it actually needs a tool. This mirrors how a developer looks up documentation on demand.

The <system-reminder> injection is a clever way to keep time-sensitive context fresh without rebuilding the whole prompt, but it relies on the model silently absorbing instructions hidden in user messages, which raises questions about transparency.

The requirement that every automation must go through the automation_update tool, and the prompt's absolute ban on touching automation files directly, shows how tightly a product must couple its prompt rules to its actual API surface to avoid phantom successes.

Concepts & terms
Deferred tools
Tools not passed to the model as function schemas. The agent sees a list of tool descriptions in the system prompt, and when a tool is needed it uses ToolSearch to fetch the tool's detailed manual, then DeferExecuteTool to run it with the filled parameters.
System-reminder
A tag embedded in user messages or tool results that the system treats as hidden context. The prompt instructs the model to silently absorb the content and never reveal its existence, used for injecting fresh data like the current date.
Three-tier memory
WorkBuddy's memory hierarchy: cloud memory for user profiles and conversation search, user-level local memory in explicit files (USER.md, SOUL.md, IDENTITY.md), and workspace memory for records of concrete work per project.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗