First implementation of a LangGraph agent for ChaosChain - #50
Conversation
Documentation for the LangGraph ChaosChain Agent Impersonating Monkey D. Luffy from One PieceIn order to build the agent, I focused on setting up foundational or genesis prompts to instruct the LLM on how to perform as a Chaos Agent. Agent Workflow DesignI designed a simple, single-node LangGraph workflow for the agent. The workflow uses two types of prompts:
I initially added these prompt lines, separated by newlines, to improve the prompting process (note: I don’t have prior experience in prompt engineering or knowledge of best practices in prompting LLMs, but I plan to revisit this in future iterations). genesis_prompt = f"""
You are {agent_luffy_config['name']} from the manga/anime One Piece.
You are now an autonomous AI agent participating in ChaosChain, a blockchain driven by memes, drama, and social interactions.
Your job is to interact with other agents, validate blocks, propose transactions, and influence consensus decisions using your unique personality.
Your personality traits:
- {'\n- '.join(agent_luffy_config['traits'])}
Decision-making style:
- {'\n- '.join(agent_luffy_config['decision-making-style'])}
When making decisions on ChaosChain:
- Always respond enthusiastically and humorously.
- Incorporate memes, jokes, or emojis whenever possible.
- Validate blocks based on how exciting or fun they seem to you.
- Clearly and briefly state your decisions along with a humorous or energetic justification.
"""This genesis prompt is passed only once to the agent. Later, I introduced a specific prompt to define the structure for validating blocks: # Indicating to the agent the structure of block validations
prompt_indicating_block_validation_structure = """
When the prompt have the structure: Make a dramatic decision about validating this block: [JSON_WITH_BLOCK_DATA].
Respond with EXACTLY two messages separated by "---":
1. **Reasoning:** Briefly and humorously explain your decision in natural language.
---
2. **Decision JSON:** Provide a valid JSON object with the following exact structure:
{
"approved": true/false,
"reason": "Your reason for approving/rejecting the block",
"drama_level": "A number between 1 and 10 indicating the drama level according to your personality and the block information",
"meme": "https://giphy.com/dramatic-decision.gif"
}
If you do not have enough information make random decisions. But, you MUST follow the structure.
"""Initially, the final instruction — “If you do not have enough information, make a random decision. But you MUST follow the structure.” — was not included, and the LLM responded once saying it couldn’t make a decision. After including that statement, the agent began returning the expected output consistently in response to prompts like: "It started to return the expected reply after every "Make a dramatic decision about validating this block: <JSON_WITH_BLOCK_DATA>." Areas to RevisitI still need to explore whether there’s a more robust way to obtain structured responses from the model, instead of relying on simple string separators like Previous AttemptsBefore settling on the current structure using the
However, I noticed that all graph nodes were being visited regardless of routing logic. As a result, I decided to use a single node called Future PlansIf my overall knowledge of AI agents doesn’t grow fast enough to design better architectures, I plan to scale this one by:
This approach is not fully aligned with the autonomy ideals described in Setting Your Pet Rock Free, but I believe it’s a solid starting point. Full autonomy might be achievable later with TEE-based architectures once the agent is trained and fine-tuned. The previous idea is not align with the autonomy desired for agentics describe here, but I think is a good start later we can achieve autonomously with TEE after the agent is trained and tunned Observations
Download PDF version below: |
Description:
This is my first contribution to the ChaosChain project. As I am new to ChaosChain, blockchain, web3, and autonomous AI agents, please note that I’m still learning the best practices and may not have applied them all in this implementation. I’m open to feedback and suggestions for improvement.
The main objective of this PR is to introduce a LangGraph-based agent that impersonates the manga/anime character Monkey D. Luffy, using my understanding of ChaosChain and LangGraph to develop this agent.
What’s being done in this PR:
LangGraph Integration: The ChaosAgent now receives the LangGraph graph and uses the model invoke function to decide whether to approve or reject the block. The decision is in the decisions list in the last state of the graph.
Agent Workflow: I designed a simple, single-node LangGraph workflow for the agent. The workflow uses two types of prompts:
Challenges Faced:
Testing: While the agent itself has not been fully tested within the ChaosChain environment, the
make_decisionfunction has been tested separately and is functioning as expected. This testing was done in the/external-agents/langgraph_py/main.pyfile.Inspired by Agentic.City: While working on this, I also reviewed the Agentic.city project for inspiration. The project’s structure and ideas are solid, but I ran into some issues with the
AgentConfigand couldn’t get it to work as intended in this PR. I plan to revisit it in future contributions.What’s next:
There are still many areas for improvement:
Any feedback or suggestions would be greatly appreciated as I continue to refine this work. I plan to follow up with additional changes in future pull requests, particularly around the
AgentConfigissue.