How to Split Huge Prompts and Reduce Agent Token Waste
TuBrief 편집팀
2026년 3월 14일
0
Computing/Software원본 영상을 바탕으로 AI의 도움을 받아 작성했습니다. 원본 영상이 기준입니다.
커뮤니티의 다른 글
댓글 (0)
Log in to leave a comment
아직 작성된 글이 없습니다
원본 영상을 바탕으로 AI의 도움을 받아 작성했습니다. 원본 영상이 기준입니다.
Log in to leave a comment
아직 작성된 글이 없습니다
Monolithic structures that cram all sorts of guidelines and tools into a single system prompt quickly show their limits. Even with a slightly longer conversation, the agent forgets instructions written in the middle of the prompt. Inference costs skyrocket due to repeatedly sending tens of thousands of tokens with every request, and users have to wait a long time for the first token to appear.
In practice, this problem is solved through a step-by-step context loading structure based on the agentskills.io open specification. This approach saves tokens by loading appropriate skills only when needed.
Monolithic system prompts should be split based on domain boundaries, tool execution permissions, and execution frequency. To prevent skills from conflicting during embedding similarity search, you should keep the number of simultaneously activated skills in a single session to 3 or fewer.
At the top of the separated skill file, specify a YAML front matter containing an identifier using only hyphens, lowercase English letters, and numbers, along with the operational purpose.
name: backend-api-generator
description: Generates Spring Boot REST API controller and service boilerplate code. Use when the user asks to create API endpoints, build REST controllers, or define DTO mappings for backend services.
when_to_use:
`
The process of building a step-by-step loading structure is simple.
Replacing a monolithic structure that constantly occupies 15,000 to 30,000 tokens with the SKILL.md lazy-loading structure reduces initial token overhead by over 90%. Based on Anthropic internal test data, the p95 latency can be shortened from 12% to 40% and average token consumption per conversation can be reduced by 29.6%.
When multiple skills are loaded sequentially, instructions from previous skills often remain in the session and distort subsequent tasks. For high-risk inspections or tasks leaving heavy logs, you should add a sub-context branching (context: fork) setting in the YAML front matter to isolate them at the process level.
`
Clearly defining input/output data contracts (Data Contracts) is also essential.
allowed-tools) in the YAML metadata to prevent arbitrary Bash executions or reckless network calls.`markdown
All responses must strictly adhere to the following JSON structure without markdown wrapping:
{
"status": "SUCCESS" | "FAILED",
"generated_files": [
{
"path": "string",
"content": "string"
}
],
"error_message": "string | null"
}
`
Isolating into sub-processes prevents tool-calling logs from flooding into the main session. Since the main conversation session stays clean, the probability of errors when passing data between sub-agents is also reduced.
When requirements are ambiguous or tool-calling errors repeat, agents fall into infinite retry loops. This is the moment when dozens of dollars in API costs vanish within minutes. Putting a step-by-step Verification Checklist in the skill file body allows agents to perform self-verification before finishing tasks.
`markdown
Before declaring the task finished, you MUST sequentially execute the following verification checklist:
`
Writing a Circuit Breaker that physically breaks loops is also straightforward.
MAXIMUM_TOOL_CALL_LIMIT: 3) at the top of the skill.`markdown
[SKILL EXECUTION HALTED]
Skill Name: backend-api-generator
Failure Reason: [Brief error description]
Attempts Made: [Number of retries]
Suggested Action: [Action required by backend developer]
`
For dangerous tasks like file deletion or database drops, it is safer to apply the disable-model-invocation: true option. This prevents agents from calling them autonomously and restricts execution so that developers must manually type the slash command (/skill-name).
When team members write skills together, following the agentskills.io standard directory architecture prevents struggles with markdown file conflicts. Clearly divide and arrange bodies, CLI scripts, reference documents, and static template assets within parent folders.
| Directory and File Path | Role | Writing Guidelines |
|---|---|---|
| skills/api-generator/SKILL.md | Required entry point document | Contains YAML front matter and core procedural instructions (under 500 lines) |
| skills/api-generator/scripts/ | Executable code folder | Location of Python/Bash CLI scripts called by agents when needed |
| skills/api-generator/references/ | Auxiliary reference document folder | Houses large API specs, DB schemas, style guide documents |
| skills/api-generator/assets/ | Static resource template folder | Stores generated code boilerplates and configuration file samples |
When verifying skill quality, utilize the promptfoo evaluation framework.
SKILL.md path and LLM model in the promptfooconfig.yaml file.npx promptfoo@latest eval command in the terminal to measure instruction compliance rates.`yaml
description: "Backend Agent Skills Validation Suite"
prompts:
`
When deploying, combine a trunk-based development strategy using short-lived branches with Git tags (v1.2.0). If an agent behaves unexpectedly in production, you can immediately roll back to a previous tag point using the git checkout tags/v1.1.0 -b hotfix/rollback command.