arrows-spinAgent Loop

The seven-step cycle that turns a message into a tool-backed answer.

The agent loop is the reasoning core of DragonClaw.

Every incoming message runs through the same cycle.

The cycle

1. Receive message
2. Find relevant skills
3. Retrieve memories
4. Build system prompt
5. Call LLM
6. Parse tool blocks
7. Return text or execute tools, then return final answer

Prompt construction

The system prompt is rebuilt on every message.

It includes:

  1. Agent persona

  2. Language directive

  3. Binance key status

  4. Relevant skill instructions

  5. Memory context

  6. Tool call rules

Session management

Each channelId keeps its own conversation history.

History is capped at 30 messages and trimmed FIFO.

Tool execution

When the model emits a tool block, DragonClaw:

  1. Parses the JSON

  2. Routes it to the correct executor

  3. Runs the tool

  4. Feeds raw output back to the model

  5. Returns a human-readable answer

Memory extraction

After each exchange, DragonClaw looks for preferences and facts such as:

  • 我喜欢追踪 Solana meme

  • I prefer conservative trades

  • 记住我只看 BSC 链上的项目

Matching statements are stored with userId and timestamp.

Last updated