yearn_for_mines Local Implementation Insights
Target: yearn_for_mines
Goal: Extract implementation patterns to improve our small /probe Minecraft LLM agent.
Core Takeaways
yearn_for_mines wraps Minecraft actions in MCP tools within a perceive -> plan -> execute -> verify -> remember loop. While the full implementation (MemPalace, extensive toolsets) is too heavy for our dialogue probe, three patterns are highly relevant:
- Observation Post-Tool: The result of a tool execution immediately becomes part of the next observation.
- Error Stratification: The runtime strictly separates transient/system errors from actual game logic errors.
- Macro Tools: Grouping repetitive, error-prone micro-steps into a single, safe runtime command.
Agent Loop & Observation
The agent loop explicitly defines execution phases. The observation builder compresses bot status, inventory, and nearby entities into a ContextFrame, formatting it into readable sections (=== Outcome ===, === Vital Stats ===, etc.).
- What works: The next LLM turn doesn't need to wait for a separate "observe" action; the previous tool's outcome and the new world state are immediately available.
- For
/probe: Keep the context bundle compact. We only need actor status, visible actors (with distance and busy states), recent conversation (4-8 utterances), recent memory notes, and allowed tools.
MCP / Tool Boundaries
Tools wrap Mineflayer APIs, exposing high-level intents (gather_materials, interact) to the LLM.
- Good Boundaries: The runtime owns the complex execution (pathfinding, block validation). Failures return context so the LLM can adjust its plan.
- Danger Zone: In
yearn_for_mines, many gameplay failures (pathfinding failed, missing blocks) returnisError: falsetext results. This breaks retry logic. - For
/probe: Tool results MUST be strictly structured (e.g.,{ ok: boolean, status: "blocked" | "invalid" | "transient", message: string }).ok: falsemust be used for game failures to enable proper retry/alternative routing.
Macro Tools
Tools like craft_macro bundle multiple steps (find table, place, craft, cleanup).
- For
/probe: We don't need crafting macros yet, but we do need social macros. Anapproach_and_converse(target, text)macro—which handles distance checks, movement, and chat delivery in one validated step—will drastically reduce LLM failure rates.
Retry & Alternative Behavior
If the agent fails the same tool call 3 times, yearn_for_mines injects a system prompt demanding a different strategy.
- For
/probe: Adopt a simpler version. If an actor receivesblockedfor the same tool/args twice, inject an instruction:Do not repeat the same action; choose wait, move_to, or a different utterance.
Memory & Verification
yearn_for_mines uses a complex MemPalace for long-term knowledge and relies on the LLM to verify goal completion.
- For
/probe: Avoid external DBs. Use short episodic memory (recent heard chats, target actor notes, last failed action). Verification must be deterministic and runtime-owned (e.g., "4 turns completed, both actors spoke").
Action Items for /probe
- Structured Tool Results: Enforce strict success/failure statuses.
- Compact Context: Focus only on dialogue-relevant observations.
- First-Class
converseTool: Must handle target validation, distance, and availability, returningblockedif the target is busy. - Social Macros: Implement
approach_and_converse. - Anti-Repeat Prompts: Detect repeated failures and force alternative actions via prompt injection.
- Runtime Verification: Hardcode success conditions for the initial proof.
- File-Based Memory: Stick to JSON snapshots alongside transcripts.
- Error Separation: Treat
bot_connectfailures differently fromtarget_too_far.