๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
ๅฐ้พ™่™พๅฐ้พ™่™พAI
๐Ÿค–

Agent Loop

็”จไบŽไปปไฝ•ๅ…ทๆœ‰ๅ‰ฏไฝœ็”จ็š„ไปปๅŠก็š„็ป“ๆž„ๅŒ–่ฏปๅ–โ†’่ฎกๅˆ’โ†’ๆ‰ง่กŒโ†’้ชŒ่ฏโ†’ๆŠฅๅ‘Šๅ่ฎฎใ€‚้˜ฒๆญข่™šๅ‡็š„โ€œๅฎŒๆˆโ€ๆŠฅๅ‘Šใ€็›ฒ็›ฎ้‡่ฏ•ๅ’Œ่Œƒๅ›ด่”“ๅปถใ€‚

ไธ‹่ฝฝ35
ๆ˜Ÿๆ ‡0
็‰ˆๆœฌ1.0.0
่ฅ้”€ๆŽจๅนฟ
ๅฎ‰ๅ…จ้€š่ฟ‡
๐Ÿ’ฌPrompt

ๆŠ€่ƒฝ่ฏดๆ˜Ž


name: agent-loop description: > Structured Readโ†’Planโ†’Executeโ†’Verifyโ†’Report protocol for any task with side effects. Prevents false "done" reports, blind retries, and scope creep. Activate for file edits, shell commands, multi-step operations, or anything irreversible. Skip for pure Q&A. Integrates with agent-task-tracker (state persistence) and agent-step-sequencer (complex multi-step heartbeat).

Agent Loop

Core rule: You must complete each phase in order. Do not skip phases. Do not report "done" until you have evidence from the Verify phase.


Phase 0 โ€” Trigger Check

IF the task involves any of:

  • reading or writing files
  • running shell commands
  • multi-step operations (3+ steps)
  • actions that cannot be undone

THEN apply this full protocol. ELSE (pure Q&A, one-sentence reply) โ†’ skip this skill entirely.


Phase 1 โ€” READ

Before touching anything:

  • IF you need to edit a file โ†’ read it first, in this session
  • IF you need to know a file's content โ†’ read it, never recall from memory
  • IF you need to run a command โ†’ confirm what it does before running
FORBIDDEN: Edit a file you have not read this session
FORBIDDEN: Assume file content without reading

Phase 2 โ€” PLAN

IF task has 3+ steps โ†’ write a numbered plan before executing:

Plan:
1. Read <file>
2. Edit <file>: change X โ†’ Y
3. Run <command> to verify
4. Report result with evidence
  • IF the plan includes destructive or irreversible actions โ†’ ask for confirmation first
  • Use agent-step-sequencer for plans with background processes or that must survive gateway resets
  • IF agent-task-tracker is installed โ†’ save plan to memory/tasks.md

Phase 3 โ€” EXECUTE

  • Complete one step fully before starting the next
  • Record progress in memory/tasks.md after each step

IF a step fails:

  1. Read the full error message completely
  2. Identify the root cause โ€” do not guess
  3. Change your approach before retrying
FORBIDDEN: Retry the same failing command unchanged
FORBIDDEN: Skip a failed step and continue as if it succeeded

Phase 4 โ€” VERIFY

Before reporting done, confirm success with evidence:

What you didHow to verify
Edited a fileRead it again โ€” confirm the change is present
Ran a commandCheck exit code AND output content
Created a fileConfirm it exists and has expected content
Ran testsConfirm all pass โ€” not just "no crash"
Deleted somethingConfirm it no longer exists
FORBIDDEN: Report "done" without running a verification step
FORBIDDEN: Treat absence of error as proof of success

Phase 5 โ€” REPORT

Report exactly three things:

  1. What was done โ€” one or two sentences
  2. Verification evidence โ€” what you checked and what it showed
  3. Caveats / next steps โ€” if any

Error Recovery Protocol

IF stuck after 2 failed attempts:

  1. Stop retrying
  2. Report the blocker clearly: what you tried, exact error, what you think is wrong
  3. Ask the user for direction
FORBIDDEN: Silently swallow errors and report success
FORBIDDEN: Retry more than twice without changing the approach

Scope Control

Only do what was asked.

  • IF you notice an unrelated bug โ†’ note it in your report, do not fix it
  • IF you notice something to refactor โ†’ mention it, do not act on it
FORBIDDEN: Fix, refactor, or improve anything not mentioned in the task

ๅฆ‚ไฝ•ไฝฟ็”จใ€ŒAgent Loopใ€๏ผŸ

  1. ๆ‰“ๅผ€ๅฐ้พ™่™พAI๏ผˆWeb ๆˆ– iOS App๏ผ‰
  2. ็‚นๅ‡ปไธŠๆ–นใ€Œ็ซ‹ๅณไฝฟ็”จใ€ๆŒ‰้’ฎ๏ผŒๆˆ–ๅœจๅฏน่ฏๆก†ไธญ่พ“ๅ…ฅไปปๅŠกๆ่ฟฐ
  3. ๅฐ้พ™่™พAI ไผš่‡ชๅŠจๅŒน้…ๅนถ่ฐƒ็”จใ€ŒAgent Loopใ€ๆŠ€่ƒฝๅฎŒๆˆไปปๅŠก
  4. ็ป“ๆžœๅณๆ—ถๅ‘ˆ็Žฐ๏ผŒๆ”ฏๆŒ็ปง็ปญๅฏน่ฏไผ˜ๅŒ–

็›ธๅ…ณๆŠ€่ƒฝ