Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alfred_origin

Where the legacy begins. Before the gadgets and the cave, there was just a loyal mind solving complex problems. This is Alfred, stripped down to his brilliant core.

Working notes

2026.02.24 day0

This is the first day of Alfred ai agent, where the legacy begins.

On the first day, I want to invoke at least three llm services.

I found that SiliconFlow is a good service where I can directly call on LLMs from different vendors without paying for foreign internet access. Additionally, I discovered some free services which are beneficial for my testing prototype phase.

I have diceded to start with three free APIs:

  • deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
  • Qwen/Qwen3-8B
  • Qwen/Qwen2.5-7B-Instruct

Now let's start!

Unfortunately, I found that distilled model DeepSeek-R1-Distill-Qwen-7B has not supported function call, but instead it occured that THUDM/GLM-Z1-9B-0414 supports function call.

According to the cat-cafe-tutorials, the Gemini SDK does not support function calling. I'm confused because it then implements a CLI to handle that functionality and write such a long document.

2026.02.25 day1

Yesterday I achieved most basic LLM function call service, but there still a significant gap before it becomes truly usable. Thus, I will consider the following issues:

  • Enable long-term dialogue;
  • Implement inter-agent communication;
  • Function discovering.

Long-term dialogue && inter-communication

The first step is to consider the simplist implementation, which is the sessionId. I had taken it for granted that each conversation maintained a sessionId automatically to enable long-term dialogue, but I'm shocked to find that it didn't! Each API call is a stateless service, which means the sessionId must be managed manully, and the historical information must be maintained independently as well.

This raised two key issues: how to manage sessionId and how to handle historical information.

  • sessionId management
    • Each agent own its private sessionId;
    • A center class is required to maintain a public sessionId and associated agents.
  • Historical Information management
    • This necessitates considering how to compress historical data. If every agent maintains a complete copy of the entire history, the storage would grow to M * N (where M is the number of agents and N is the number of dialogue turns). This could quickly fill the context window, as maximum context length is limited, and also lead to significant, unnecessary cost escalation since some historical data is irrelevant.
    • However, over-compressing all information is not feasible either, as it would strip away many crucial details.

As above, a balanced approach is under consideration:

  • The center class maintains compressed historical information, public sessionId and associated agents;
  • The agent itself manages its private sessionId and retain only the most recent few rounds of key dialogue for immediate context.

However, all of these are just my off-the-cuff ideas, and more details that need attention will likely emerge during the actual implementation process.

LangGraph LangGraph (Directed Graph) is a key component in agent architectures.

Implementation

I implement a multi-agent collaboration long-term dialogue system with a two-tier architecture featuring global state management and agent state ioslation. Through session-level history info compression and agent-level cognitive updates, it achieves efficient leng-term dialogue.

Key Features:

  • State Isolation: Each agent maintains its private history and cognitive state.
  • Information Sharing: Global session provides shared context across agents.
  • Dynamic Compression: Intelligent conversation history management prevents context overflow.
  • Reflective Learning: Agents update cognition based on execution results and user feedback.

Implementation details:

  • The GlobalSession maintains a public sessionIdand a summary of responses from all agents. The AgentSession maintains its own private sessionIdand a private list of conversation history.

  • The historical information summary maintained by GlobalSession needs to be refined with the latest response or user feedback. AgentSession maintains a conversation history list with a max_history_turns parameter representing the maximum number of historical entries an agent can preserve. Note that the first entry in the history list is always a role:system​ message. When the maximum turn count is reached, the first entry (role:system) and the second entry (role:user) can be merged into a new single entry (role:system), and then the latest message can be appended to the queue.

    • The GlobalSession.refine_history() method synthesizes a new global state by reconciling agent actions with user intent, applying strategic pruning, fact consolidation, logical chain alignment, and inconsistency resolution.
    • The AgentSession.compress_history_head() method specifically implements the merging of the first two messages (system + user) into a new system message when the history length exceeds max_history_turns, creating a structured summary that preserves user intent and key conclusions while discarding intermediate reasoning steps.
  • The termination criterion for long-term dialogue is reached when there is no function call and only text output remains. Currently, a maximum iteration count is implemented as a provisional measure. Future enhancements in this area will involve more sophisticated mechanisms.

2026.02.26 day2

首先我添加了两个测试文件,测试文件里面需要添加模拟函数以及用户的对话。两个测试文件是test_conversation_investment.py和test_conversation_werewolf.py, 分别是一个投资建议的对话测试和狼人杀的对话测试。但是现在我发现了一个问题,就是agent之间并不能对话,我认为这是不合理的。我现在想实现的是真正的对话。那么这里就涉及到router, 这还挺

I achieved the long-term dialogue yesterday. Thus,

About

Where the legacy begins. Before the gadgets and the cave, there was just a loyal mind solving complex problems. This is Alfred, stripped down to his brilliant core.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages