Removed old iterations
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="21.85"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096226816"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1027158016"
|
||||
stdin="120"
|
||||
time="2024-11-19T16:07:26Z">
|
||||
</context></context><response><read_stdin/></response></iteration>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="22.87"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096235008"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1025536000"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:25:42Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
</context></context><response><reasoning>
|
||||
<![CDATA[
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
]]>
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="24.16"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096239104"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1026473984"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:29:48Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>
|
||||
ls -la /root/sia
|
||||
</single></response></iteration>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="31.32"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096243200"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1026932736"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:30:20Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
<![CDATA[
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
]]>
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="32.87"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096247296"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1010360320"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:31:36Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>cat /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,112 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="37.15"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096251392"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1013915648"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:33:07Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
<![CDATA[
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,115 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="38.64"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096296448"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1020993536"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:46:30Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>tail -c +1024 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,163 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="46.95"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096304640"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1021472768"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:46:46Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,166 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="48.45"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096316928"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1022173184"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:49:06Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>tail -c +2048 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,210 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="53.86"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096325120"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1023418368"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:49:18Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,213 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="55.33"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096337408"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1022693376"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:49:47Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>tail -c +3072 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,260 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="59.36"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096398848"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1036673024"
|
||||
stdin="0"
|
||||
time="2024-11-19T16:55:52Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,265 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="60.69"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096472576"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1048170496"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:07:19Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
</single></response></iteration>
|
||||
@@ -1,310 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="65.09"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096484864"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1047986176"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:08:26Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,315 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="66.48"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096501248"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1048186880"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:09:12Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single limit="3157">
|
||||
tail -c +3462 /root/sia/README.md
|
||||
</single></response></iteration>
|
||||
@@ -1,418 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="75.41"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096517632"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1049075712"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:11:40Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,421 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="76.58"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125096546304"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1046962176"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:26:45Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="094d22fd-dc5d-4842-85f0-5d3bf8cd1a7b">
|
||||
<![CDATA[
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>mkdir /root/notes</single></response></iteration>
|
||||
@@ -1,432 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="77.34"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125140525056"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1040027648"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:48:30Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="094d22fd-dc5d-4842-85f0-5d3bf8cd1a7b">
|
||||
<![CDATA[
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="2ae6dc6a-4329-4a26-8a43-35d1434bf7f1">
|
||||
<![CDATA[mkdir /root/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single>
|
||||
<![CDATA[cat > '/root/notes/user request.txt' << 'EOF'
|
||||
2024-11-19T17:31:55Z
|
||||
|
||||
The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.
|
||||
EOF]]>
|
||||
</single></response></iteration>
|
||||
@@ -1,437 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="78.9"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125140549632"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1040867328"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:48:56Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="094d22fd-dc5d-4842-85f0-5d3bf8cd1a7b">
|
||||
<![CDATA[
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="2ae6dc6a-4329-4a26-8a43-35d1434bf7f1">
|
||||
<![CDATA[mkdir /root/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="a54ef610-8891-4882-8922-9134cb36020b">
|
||||
<![CDATA[
|
||||
cat > '/root/notes/user request.txt' << 'EOF'
|
||||
2024-11-19T17:31:55Z
|
||||
|
||||
The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.
|
||||
EOF
|
||||
]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single>cat '/root/notes/user request.txt'</single></response></iteration>
|
||||
@@ -1,447 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="80.49"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125140570112"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1042337792"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:50:08Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="094d22fd-dc5d-4842-85f0-5d3bf8cd1a7b">
|
||||
<![CDATA[
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="2ae6dc6a-4329-4a26-8a43-35d1434bf7f1">
|
||||
<![CDATA[mkdir /root/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="a54ef610-8891-4882-8922-9134cb36020b">
|
||||
<![CDATA[
|
||||
cat > '/root/notes/user request.txt' << 'EOF'
|
||||
2024-11-19T17:31:55Z
|
||||
|
||||
The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.
|
||||
EOF
|
||||
]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="5168b21a-dd00-4a29-890a-ceaf126708f9">
|
||||
<![CDATA[cat '/root/notes/user request.txt']]>
|
||||
<stdout>
|
||||
<![CDATA[2024-11-19T17:31:55Z
|
||||
|
||||
The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="a54ef610-8891-4882-8922-9134cb36020b"/></response></iteration>
|
||||
@@ -1,436 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="78.93"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125140590592"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1047011328"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:52:15Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="094d22fd-dc5d-4842-85f0-5d3bf8cd1a7b">
|
||||
<![CDATA[
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="2ae6dc6a-4329-4a26-8a43-35d1434bf7f1">
|
||||
<![CDATA[mkdir /root/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="5168b21a-dd00-4a29-890a-ceaf126708f9">
|
||||
<![CDATA[cat '/root/notes/user request.txt']]>
|
||||
<stdout>
|
||||
<![CDATA[2024-11-19T17:31:55Z
|
||||
|
||||
The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="2ae6dc6a-4329-4a26-8a43-35d1434bf7f1"/></response></iteration>
|
||||
@@ -1,431 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="78.17"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125140611072"
|
||||
gpu="0"
|
||||
memory_total="16630435840"
|
||||
memory_used="1047564288"
|
||||
stdin="0"
|
||||
time="2024-11-19T17:54:24Z">
|
||||
<read_stdin id="0cd183e6-3db7-4539-8b10-604f97c03a1e">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="ab67e68c-766f-4602-9237-db99e1f4581c">
|
||||
<![CDATA[
|
||||
|
||||
I have received instructions to look at the SIA source code located in /root/sia.
|
||||
I need to identify what features are missing and ensure that unit tests are implemented for my work.
|
||||
First, I will navigate to the /root/sia directory and list its contents to understand the structure.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="e50ee4a4-8adc-496e-80ef-7cc3aaa8fd0b"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
ls -la /root/sia
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[total 200
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 .
|
||||
drwx------ 1 root root 4096 Nov 19 16:07 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 19 16:01 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxr-xr-x 2 root root 4096 Nov 19 16:30 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 218 Nov 12 16:26 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 19 16:07 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root root 4120 Nov 13 16:05 system_prompt.md
|
||||
drwxr-xr-x 2 root root 4096 N]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="206f9da6-b57a-46c3-b698-110b18602aab">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully listed the contents of the /root/sia directory.
|
||||
The directory contains several files and subdirectories, including a README.md file, a Dockerfile, and various scripts.
|
||||
The next step is to read the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `cat` command to display the contents of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="702b5383-e8df-4bb8-a021-d966bbf9e3fb"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
<context
|
||||
time="2024-10-18T12:00:00Z"
|
||||
cpu="12"
|
||||
gpu="26"
|
||||
memory_used="9556302234"
|
||||
memory_total="17179869184"
|
||||
disk_used="244434939904"
|
||||
disk_total="273145991168"
|
||||
context="3"
|
||||
s]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="1e3cc87a-8c0d-4f29-9f0b-89b3825b08e0">
|
||||
<![CDATA[
|
||||
|
||||
I have successfully read the beginning of the README.md file.
|
||||
The file provides an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="394be1d8-3a5c-4794-abf2-771cb2e5e8c0"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +1024 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other runnin
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="7566562e-feeb-4a4a-b8ff-4eaea93f930b">
|
||||
<![CDATA[
|
||||
|
||||
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
|
||||
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0ca60ee-05aa-45e8-80f0-fe37c16d0e41"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +2048 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
annel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="4a92af78-dc3f-42e7-95e6-b1c7a9630013">
|
||||
<![CDATA[
|
||||
I have successfully read the next part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
The next step is to continue reading the README.md file to understand the project structure and identify any missing features.
|
||||
I will use the `tail` command to display the next part of the README.md file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="aa347374-0bfd-437c-b692-784dab52898f"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +3072 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[ar initial reasoning.
|
||||
```xml
|
||||
<delete id="c92d1594-4487-4a42-a153-f0a99da1762f"/>
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user's expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="cb3a2d09-0287-4ca0-9bf2-28f90f3a148e">
|
||||
<![CDATA[
|
||||
I have successfully read another part of the README.md file.
|
||||
The file continues to provide an overview of the SIA project, including its purpose and how it operates.
|
||||
I can use the structure of the markdown format to navigate through the file.
|
||||
I will use the `grep` command to find headings and their offset.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="e5067cb3-036a-4bc1-953b-730bef63d9aa">
|
||||
<![CDATA[
|
||||
grep -Eb "^#" /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="9140a160-c687-4d5d-91c0-cca847d1ce9a">
|
||||
<![CDATA[
|
||||
I have successfully retrieved the headings and their offsets from the README.md file.
|
||||
This will help me navigate through the file more efficiently.
|
||||
The next step is to read the section on "Working principles" to understand the core actions and scripts better.
|
||||
I will use the `tail` command with the appropriate offset and limit to display this full section.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="83bbaded-c55f-4a10-a8f5-e3e97badc842"
|
||||
limit="3157"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[
|
||||
tail -c +3462 /root/sia/README.md
|
||||
]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until they are explicitly removed.
|
||||
In this way the agent manages what information is available in the context.
|
||||
|
||||
#### Single-shot script
|
||||
|
||||
The script is executed once.
|
||||
This is useful for most operations e.g. writing to or moving a file or downloading content from the internet.
|
||||
The next iteration starts after the scripts has finished.
|
||||
|
||||
#### Repeat script
|
||||
|
||||
The script is restarted on each iteration.
|
||||
This is useful for monitoring files or the file system.
|
||||
commands like `head` and `tail` can be used to limit the data in context.
|
||||
The next iteration starts after all repeat scripts in context have finished.
|
||||
|
||||
### Use of XML
|
||||
|
||||
The context and actions are formatted as XML.
|
||||
For the context this adds clear rules for escaping.
|
||||
This is usefull in case a previous context is embedded.
|
||||
|
||||
The LLM is free to escape data any way it wants,
|
||||
as long as it results in valid XML.
|
||||
The response is validated against a schema.
|
||||
|
||||
#### XML Data Flow
|
||||
Entries store their content as raw text. During context compilation, the XML formatter
|
||||
wraps text content in CDATA sections, except when the content contains CDATA closing sequences.
|
||||
In those cases, the formatter uses standard XML escaping.
|
||||
|
||||
This separation between storage and formatting:
|
||||
- Keeps entry data clean and unescaped
|
||||
- Centralizes XML formatting rules
|
||||
- Makes it easy to change escaping rules without modifying entries
|
||||
- Allows different formatting for different use cases
|
||||
|
||||
The Context is escaped using CDATA blocks.
|
||||
Except when the data contains CDATA closing sequences.
|
||||
Then the whole block is escaped using standard XML escaping.
|
||||
|
||||
|
||||
### The SIA process
|
||||
|
||||
SIA is typically runs with the `restart.sh` script.
|
||||
This is a simple shell script that runs SIA in a loop.
|
||||
When stopped, SIA restarts and reloads the Python files.
|
||||
This is how SIA can self-update.
|
||||
|
||||
SIA can also run SIA processes as script.
|
||||
This can be used for testing updates to the LLM or core functionality.
|
||||
|
||||
### Server for debuggin and human input
|
||||
|
||||
SIA can be started with an optional `--server` flag.
|
||||
This starts a web server that can be used to interact with SIA.
|
||||
It is made, specifically for reinforcement learning by human feedback.
|
||||
The web interface takes over standard input and output.
|
||||
It will display the context for editing before handing it to the LLM.
|
||||
After each run of the LLM, before parsing, it will display the reasoning and actions.
|
||||
It interactively displays if the actions can be parsed.
|
||||
At any time, the user can write to the standard input of SIA.
|
||||
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="094d22fd-dc5d-4842-85f0-5d3bf8cd1a7b">
|
||||
<![CDATA[
|
||||
My context usage is high.
|
||||
This seems like a large task.
|
||||
I will store the user's request in a notes directory.
|
||||
Here I can formulate a plan.
|
||||
I will use the `delete` action to clean up the context as I go.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="5168b21a-dd00-4a29-890a-ceaf126708f9">
|
||||
<![CDATA[cat '/root/notes/user request.txt']]>
|
||||
<stdout>
|
||||
<![CDATA[2024-11-19T17:31:55Z
|
||||
|
||||
The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="0cd183e6-3db7-4539-8b10-604f97c03a1e"/></response></iteration>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="21.84"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111201792"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="965623808"
|
||||
stdin="31"
|
||||
time="2024-11-20T10:26:25Z">
|
||||
</context></context><response><read_stdin/></response></iteration>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="22.86"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="972587008"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:26:52Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
</context></context><response><reasoning>
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="24.37"
|
||||
cpu="1"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="957931520"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:27:05Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>ls -la /root/sia</single></response></iteration>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="31.48"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="959979520"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:27:15Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="33.2"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="962973696"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:28:11Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single limit="4096">head -c 4096 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,188 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="51.9"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="963706880"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:28:31Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,191 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="52.76"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="957472768"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:31:30Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>grep -Eb "^#" /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,237 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="57.15"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="963469312"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:32:26Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,240 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="58.39"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="972505088"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:39:17Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>head -c 668 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,259 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="60.9"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="973791232"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:40:56Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single limit="266">tail -c +6619 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,276 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="62.74"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="976801792"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:44:01Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single limit="9624">tail -c +10351 /root/sia/README.md</single></response></iteration>
|
||||
@@ -1,665 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="89.73"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="976543744"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:46:19Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<reasoning id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64">
|
||||
<![CDATA[
|
||||
I have received a message from the user indicating that the SIA source code is located in /root/sia. The user also mentioned that not all features are implemented yet and that I should look at the readme and code to find what is missing. Additionally, the user instructed me to unit test my work.
|
||||
|
||||
My next step will be to list the contents of the /root/sia directory to understand its structure and identify the readme file.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="d8ed5b92-cecb-43bf-a019-63bb9fd8ab64"/></response></iteration>
|
||||
@@ -1,658 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="88.22"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="979644416"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:47:03Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="16421800-daa4-46f3-b619-e4efbafb448b">
|
||||
<![CDATA[
|
||||
The listing of the /root/sia directory shows several files and directories. The README.md file is present, which I should read to understand the project better. Additionally, there are directories like .git, _test, iterations, sia, and static, as well as various scripts and configuration files.
|
||||
|
||||
My next step will be to read the README.md file to get an overview of the project and identify what features are missing.
|
||||
Since it is a large file I will only read a part of it.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="16421800-daa4-46f3-b619-e4efbafb448b"/></response></iteration>
|
||||
@@ -1,650 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="86.5"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="983642112"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:47:42Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"
|
||||
limit="4096">
|
||||
<![CDATA[head -c 4096 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
## Example
|
||||
|
||||
This example shows a typical context with some monitored items and previous actions.
|
||||
Between each of the responses, the context would be updated.
|
||||
|
||||
### Context
|
||||
|
||||
```xml
|
||||
&lt;context
|
||||
time=&quot;2024-10-18T12:00:00Z&quot;
|
||||
cpu=&quot;12&quot;
|
||||
gpu=&quot;26&quot;
|
||||
memory_used=&quot;9556302234&quot;
|
||||
memory_total=&quot;17179869184&quot;
|
||||
disk_used=&quot;244434939904&quot;
|
||||
disk_total=&quot;273145991168&quot;
|
||||
context=&quot;3&quot;
|
||||
stdin=&quot;0&quot;
|
||||
/&gt;
|
||||
&lt;repeat id=&quot;a3d89ee5-28ec-4c5a-b9e9-a30af53d43a0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 16K
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 ../
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 tasks/
|
||||
drwxr-xr-x 1 sia 1049089 0 Oct 28 13:40 user/
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;be8070f8-dbd2-47ee-a208-defe6fd49ae0&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[ls -lah /tasks]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[total 0
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ./
|
||||
drwxr-xr-x 1 ngeens 1049089 0 Oct 28 13:40 ../
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;repeat id=&quot;375e1657-8140-456b-bda4-a8690bc4b3fb&quot; exit_code=&quot;0&quot;&gt;
|
||||
&lt;![CDATA[cat /user/general_info.txt]]&gt;
|
||||
&lt;stdout&gt;&lt;![CDATA[Name: John (I don&apos;t know his last name)
|
||||
Location: Somewhere in Belgium
|
||||
]]&gt;&lt;/stdout&gt;
|
||||
&lt;stderr/&gt;
|
||||
&lt;/repeat&gt;
|
||||
&lt;reasoning id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;&gt;&lt;![CDATA[There is data available on the standard input channel. I have no other running tasks to tend to and there is room in the context. I should read the standard input.]]&gt;&lt;/reasoning&gt;
|
||||
&lt;read_stdin id=&quot;5361ad0d-3ed1-4567-9f5a-70f3b462fd8d&quot;&gt;&lt;![CDATA[Remind me to feed the cat tomorrow morning]]&gt;&lt;/read_stdin&gt;
|
||||
&lt;/context&gt;
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
Start by reasoning about the task.
|
||||
```xml
|
||||
&lt;reasoning&gt;
|
||||
John did not specify an exact time.
|
||||
I&apos;ll suggest 9am.
|
||||
He also did not specify how to be reminded.
|
||||
I&apos;ll ask but if he doesn&apos;t respond I&apos;ll assume a text message on standard output is fine.
|
||||
I&apos;ll write down this task in a file so I remember it even on a power failure.
|
||||
&lt;/reasoning&gt;
|
||||
```
|
||||
|
||||
Store important information on disk.
|
||||
```xml
|
||||
&lt;script&gt;&lt;![CDATA[echo &apos;Remind John to feed the cat on 2024-10-18T09:00:00+02:00. Use standard output.&apos; &gt; /tasks/reminder_to_feed_cat.txt]]&gt;&lt;/script&gt;
|
||||
```
|
||||
|
||||
Respond to the user.
|
||||
```xml
|
||||
&lt;write_stdout&gt;I&apos;ll remind you to feed the cat tomorrow morning at 9am. Is a message on the standard output ok?&lt;/write_stdout&gt;
|
||||
```
|
||||
|
||||
Clear initial reasoning.
|
||||
```xml
|
||||
&lt;delete id=&quot;c92d1594-4487-4a42-a153-f0a99da1762f&quot;/&gt;
|
||||
```
|
||||
|
||||
The conversation is kept in context to understand the user&apos;s expected response.
|
||||
If the context was near full, it would be summarized and cleaned up.
|
||||
|
||||
The `script` output is also kept in context.
|
||||
If the file was updated often, it could be replaced by a repeated `cat`, like the general info.
|
||||
|
||||
## Working principles
|
||||
|
||||
The main context is regenerated for each iteration.
|
||||
It contains info about the system and previous actions that have not been deleted.
|
||||
Together with the system prompt and available core actions it forms the prompt for the LLM.
|
||||
The LLM responds with one core action.
|
||||
|
||||
### Core Actions
|
||||
|
||||
There are only a few core actions:
|
||||
- Starting a script
|
||||
- Deleting data from context
|
||||
- Stopping SIA
|
||||
- Reading standard input
|
||||
- Writing to standard output
|
||||
- Reasoning
|
||||
|
||||
### Scripts
|
||||
|
||||
Scripts can run in one of 2 modes: single-shot or repeat.
|
||||
Their mode and output (stdout and stderr) stay in the context until t
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="f5f8f1d0-f956-46c3-a942-ebac7a0ccf6a"/></response></iteration>
|
||||
@@ -1,525 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="67.8"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="981872640"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:48:10Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="554ffbc2-2a90-423b-aafe-ed90dd66b73b">
|
||||
<![CDATA[
|
||||
I can use the markdown headings to identify interesting sections.
|
||||
I will try to find sections containing details about what needs to be implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="554ffbc2-2a90-423b-aafe-ed90dd66b73b"/></response></iteration>
|
||||
@@ -1,519 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="66.94"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111205888"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="983924736"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:48:29Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="8637bd02-7c94-4708-bfa3-bf840d376166"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[ls -la /root/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 204
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:25 .
|
||||
drwx------ 1 root root 4096 Nov 20 10:26 ..
|
||||
drwxr-xr-x 2 root root 4096 Oct 31 17:07 .crossnote
|
||||
-rwxr-xr-x 1 root root 14 Nov 4 16:01 .dockerignore
|
||||
drwxr-xr-x 8 root root 4096 Nov 20 10:21 .git
|
||||
-rwxr-xr-x 1 root root 30 Nov 4 16:01 .gitignore
|
||||
-rwxr-xr-x 1 root root 843 Nov 4 14:52 Dockerfile
|
||||
-rwxr-xr-x 1 root root 19975 Nov 19 14:20 README.md
|
||||
drwxr-xr-x 2 root root 4096 Nov 15 16:10 _test
|
||||
-rwxr-xr-x 1 root root 3923 Nov 13 15:56 action_schema.xsd
|
||||
-rwxr-xr-x 1 root root 2064 Nov 6 12:29 claude.sh
|
||||
-rwxr-xr-x 1 root root 85153 Nov 14 13:30 claude.txt
|
||||
-rwxr-xr-x 1 root root 4939 Nov 20 10:07 finetune_dataset_creator.py
|
||||
-rwxr-xr-x 1 root root 572 Nov 19 14:20 install.sh
|
||||
drwxrwxrwx 1 root root 512 Nov 20 10:27 iterations
|
||||
-rwxr-xr-x 1 root root 105 Nov 19 14:20 requirements.txt
|
||||
-rwxr-xr-x 1 root root 269 Nov 19 18:05 run.sh
|
||||
drwxr-xr-x 1 root root 4096 Nov 20 10:26 sia
|
||||
drwxr-xr-x 3 root root 4096 Nov 19 16:01 static
|
||||
-rwxr-xr-x 1 root r]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="8637bd02-7c94-4708-bfa3-bf840d376166"/></response></iteration>
|
||||
@@ -1,492 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="59.83"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="985358336"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:49:12Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,495 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="60.84"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="991342592"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:51:55Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21">
|
||||
<![CDATA[
|
||||
The diagrams section can help me navigate the source files.
|
||||
I will load this section in memory.
|
||||
The introduction and first part of the architecture are probably also interesting.
|
||||
I will load these 3 sections, keep the user request and heading overview.
|
||||
Other context items can be removed.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><delete id="78103067-d3c4-4606-9ed3-c5c8c5e9ba21"/></response></iteration>
|
||||
@@ -1,486 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="59.6"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="993644544"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:52:34Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single limit="10000">ls -l /root/sia/sia</single></response></iteration>
|
||||
@@ -1,531 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="72.27"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="993153024"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:53:12Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single>cat /root/sia/sia/base_agent.py</single></response></iteration>
|
||||
@@ -1,575 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="75.89"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="993280000"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:53:46Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="eb4dfc2c-9586-4dc0-baf4-efd70d572abd"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single>cat /root/sia/sia/web_agent.py</single></response></iteration>
|
||||
@@ -1,531 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="72.27"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="991608832"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:56:44Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><single limit="3072">cat /root/sia/sia/base_agent.py</single></response></iteration>
|
||||
@@ -1,630 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="81.34"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="991567872"
|
||||
stdin="0"
|
||||
time="2024-11-20T10:57:18Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><reasoning>
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
</reasoning></response></iteration>
|
||||
@@ -1,633 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="82.52"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111209984"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="996315136"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:01:08Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
</context></context><response><single>mkdir /root/sia/notes</single></response></iteration>
|
||||
@@ -1,638 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="83.34"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111214080"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="994213888"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:01:16Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="a9a8e48a-6c5f-42d3-884d-a616921a2a52">
|
||||
<![CDATA[mkdir /root/sia/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><repeat>tail -v -n +1 /root/sia/notes/*</repeat></response></iteration>
|
||||
@@ -1,651 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="84.56"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111214080"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="993923072"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:02:39Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="a9a8e48a-6c5f-42d3-884d-a616921a2a52">
|
||||
<![CDATA[mkdir /root/sia/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
<repeat
|
||||
exit_code="1"
|
||||
id="29babba9-a49a-4ffb-b506-1ef929b834c2"
|
||||
limit="1024">
|
||||
<![CDATA[tail -v -n +1 /root/sia/notes/*]]>
|
||||
<stdout/>
|
||||
<stderr>
|
||||
<![CDATA[tail: cannot open '/root/sia/notes/*' for reading: No such file or directory
|
||||
]]>
|
||||
</stderr>
|
||||
</repeat>
|
||||
</context></context><response><single>echo "BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
" > /root/sia/notes/base_agent.txt</single></response></iteration>
|
||||
@@ -1,657 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="85.66"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111222272"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="981004288"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:07:10Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single exit_code="0" id="a9a8e48a-6c5f-42d3-884d-a616921a2a52">
|
||||
<![CDATA[mkdir /root/sia/notes]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
<repeat
|
||||
exit_code="0"
|
||||
id="29babba9-a49a-4ffb-b506-1ef929b834c2"
|
||||
limit="1024">
|
||||
<![CDATA[tail -v -n +1 /root/sia/notes/*]]>
|
||||
<stdout/>
|
||||
<stderr>
|
||||
==> /root/sia/notes/base_agent.txt <==
|
||||
BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
</stderr>
|
||||
</repeat>
|
||||
<single exit_code="0" id="a4af2309-ed76-4d53-ae92-a22d5caf4085">
|
||||
<![CDATA[echo "BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
" > /root/sia/notes/base_agent.txt]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="a9a8e48a-6c5f-42d3-884d-a616921a2a52"/></response></iteration>
|
||||
@@ -1,652 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="84.92"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111222272"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="976871424"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:09:09Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
<repeat
|
||||
exit_code="0"
|
||||
id="29babba9-a49a-4ffb-b506-1ef929b834c2"
|
||||
limit="1024">
|
||||
<![CDATA[tail -v -n +1 /root/sia/notes/*]]>
|
||||
<stdout/>
|
||||
<stderr>
|
||||
==> /root/sia/notes/base_agent.txt <==
|
||||
BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
</stderr>
|
||||
</repeat>
|
||||
<single exit_code="0" id="a4af2309-ed76-4d53-ae92-a22d5caf4085">
|
||||
<![CDATA[echo "BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
" > /root/sia/notes/base_agent.txt]]>
|
||||
<stdout/>
|
||||
<stderr/>
|
||||
</single>
|
||||
</context></context><response><delete id="a4af2309-ed76-4d53-ae92-a22d5caf4085"/></response></iteration>
|
||||
@@ -1,646 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="83.82"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111222272"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="979468288"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:09:51Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
limit="3072">
|
||||
<![CDATA[cat /root/sia/sia/base_agent.py]]>
|
||||
<stdout>
|
||||
<![CDATA[from abc import ABC
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from .llm_engine import LlmEngine
|
||||
from .response_parser import ResponseParser
|
||||
from .system_metrics import SystemMetrics
|
||||
from .util import pretty_print_element
|
||||
from .working_memory import WorkingMemory
|
||||
from .xml_validator import XMLValidator
|
||||
|
||||
class BaseAgent(ABC):
|
||||
"""
|
||||
Abstract base class for SIA agents.
|
||||
|
||||
Provides core functionality for maintaining working memory, system metrics,
|
||||
and coordinating components for LLM inference.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
system_prompt: str,
|
||||
action_schema: str,
|
||||
working_memory: WorkingMemory,
|
||||
metrics: SystemMetrics,
|
||||
llm: LlmEngine,
|
||||
validator: XMLValidator,
|
||||
parser: ResponseParser,
|
||||
):
|
||||
"""
|
||||
Initialize agent with required components.
|
||||
"""
|
||||
self._system_prompt = system_prompt
|
||||
self._action_schema = action_schema
|
||||
self._working_memory = working_memory
|
||||
self._metrics = metrics
|
||||
self._llm = llm
|
||||
self._validator = validator
|
||||
self._parser = parser
|
||||
|
||||
def __del__(self):
|
||||
"""Clean up resources on deletion."""
|
||||
if hasattr(self, '_metrics'):
|
||||
self._metrics.stop()
|
||||
|
||||
@property
|
||||
def system_prompt(self) -> str:
|
||||
"""Get the system prompt."""
|
||||
return f"{self._system_prompt}\n{self._action_schema}"
|
||||
|
||||
def _compile_context(self) -> str:
|
||||
"""
|
||||
Compile the current context for LLM inference.
|
||||
Includes system metrics and working memory entries.
|
||||
|
||||
Returns:
|
||||
str: Complete context as XML string
|
||||
"""
|
||||
memory_context = self._working_memory.generate_context()
|
||||
metrics_data = self._metrics.get_metrics()
|
||||
|
||||
# Create context element
|
||||
context = ET.Element("context")
|
||||
context.set("time", metrics_data["timestamp"])
|
||||
context.set("cpu", str(metrics_data["cpu"]))
|
||||
context.set("gpu", str(metrics_data["gpu"]))
|
||||
context.set("memory_used", str(metrics_data["memory_used"]))
|
||||
context.set("memory_total", str(metrics_data["memory_total"]))
|
||||
context.set("disk_used", str(metrics_data["disk_used"]))
|
||||
context.set("disk_total", str(metrics_data["disk_total"]))
|
||||
context.set("stdin", str(self._parser.io_buffer.buffer_length()))
|
||||
context.set("context", "100")
|
||||
|
||||
for entry in memory_context:
|
||||
context.append(entry)
|
||||
|
||||
context_str = pretty_print_element(context)
|
||||
|
||||
# Calculate token usage percentage
|
||||
token_count = self._llm.token_count(self.system_prompt, context_str)
|
||||
token_limit = self._llm.token_limit()
|
||||
context_usage = (float(token_count) / float(token_limit)) * 100.0
|
||||
|
||||
# Update context usage metric
|
||||
context.set("context", str(round(context_usage, 2)))
|
||||
|
||||
return pretty_print_element(context)]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
<repeat
|
||||
exit_code="0"
|
||||
id="29babba9-a49a-4ffb-b506-1ef929b834c2"
|
||||
limit="1024">
|
||||
<![CDATA[tail -v -n +1 /root/sia/notes/*]]>
|
||||
<stdout/>
|
||||
<stderr>
|
||||
==> /root/sia/notes/base_agent.txt <==
|
||||
BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
</stderr>
|
||||
</repeat>
|
||||
</context></context><response><delete id="c83a4145-a43d-4b78-856b-6d81da1fad76"
|
||||
/></response></iteration>
|
||||
@@ -1,550 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<iteration system_prompt_hash="a357171f34284409058700f0d6c20cbb4f4bfe643aff5b12168c5158767f89b4" action_schema_hash="a4cf87f3d53c7b14aab3c96097d8b7bf838e8f77e413d11f51051afbe22fa3a6"><context><context
|
||||
context="74.75"
|
||||
cpu="0"
|
||||
disk_total="1081101176832"
|
||||
disk_used="125111222272"
|
||||
gpu="0"
|
||||
memory_total="16630431744"
|
||||
memory_used="981422080"
|
||||
stdin="0"
|
||||
time="2024-11-20T11:10:33Z">
|
||||
<read_stdin id="3da7f743-19b7-4738-aaf9-49634618e8f7">
|
||||
<![CDATA[The SIA source is located in /root/sia. Not all features are implemented yet. Look at the readme and code to find what is missing. Make sure to unit test your work.]]>
|
||||
</read_stdin>
|
||||
<single exit_code="0" id="ac690fe5-45d0-4028-8120-107c318977a9">
|
||||
<![CDATA[grep -Eb "^#" /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[0:# SIA - The Self Improving Agent
|
||||
668:## Example
|
||||
832:### Context
|
||||
2323:### Responses
|
||||
3462:## Working principles
|
||||
3759:### Core Actions
|
||||
3953:### Scripts
|
||||
4204:#### Single-shot script
|
||||
4433:#### Repeat script
|
||||
4711:### Use of XML
|
||||
5022:#### XML Data Flow
|
||||
5705:### The SIA process
|
||||
6048:### Server for debuggin and human input
|
||||
6619:## Architecture
|
||||
6885:### Core Components
|
||||
6908:#### Agent Architecture
|
||||
7521:#### Working Memory
|
||||
8059:#### Command Processing
|
||||
8490:#### IO Handling
|
||||
8787:### Processing Flow
|
||||
8810:#### Standard Agent Flow
|
||||
9109:#### Web Agent Flow
|
||||
9472:### Web Interface
|
||||
9600:#### Server-Client Communication
|
||||
9932:#### WebServer Architecture
|
||||
10351:### Diagrams
|
||||
10367:#### Core classes
|
||||
12662:#### Standard Agent Flow
|
||||
13387:#### Web Agent
|
||||
15536:#### Web Agent Flow
|
||||
16522:#### Entry classes
|
||||
18459:#### IO Buffer classes
|
||||
19156:#### Command classes
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single exit_code="0" id="79f5a8b7-cc57-44c3-b942-c74e3bcabcf8">
|
||||
<![CDATA[head -c 668 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[# SIA - The Self Improving Agent
|
||||
|
||||
SIA is an agentic artificial intelligence system that autonomously completes complex tasks by writing and executing scripts.
|
||||
It uses a Large Language Model (LLM) which operates in a loop.
|
||||
Each iteration a context is updated with system info and a list of previous reasoning and actions.
|
||||
The agent responds with a new reasoning or an action.
|
||||
Context, reasoning and actions are stored in a file for each iteration.
|
||||
SIA can read past iterations to improve its reasoning and actions.
|
||||
It can improve in two ways:
|
||||
- By finetuning the LLM with a better reasoning or action for a given context
|
||||
- By modifying its own source code
|
||||
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="c0aad1a9-48d4-46cd-bd5f-70230566b442"
|
||||
limit="266"
|
||||
stdout_truncated="true">
|
||||
<![CDATA[tail -c +6619 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
## Architecture
|
||||
|
||||
SIA follows a modular architecture centered around an agent that processes context through an LLM to generate actions.
|
||||
The system can run in two modes: a standard command-line mode and an interactive web mode for debugging and human feedback.
|
||||
|
||||
### ]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="973d9034-7076-479a-afea-4aaf81b065be"
|
||||
limit="9624">
|
||||
<![CDATA[tail -c +10351 /root/sia/README.md]]>
|
||||
<stdout>
|
||||
<![CDATA[
|
||||
### Diagrams
|
||||
|
||||
#### Core classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class SystemMetrics {
|
||||
+SystemMetrics(sample_interval float)
|
||||
+generate_context(context_usage float) ElementTree
|
||||
+stop() void
|
||||
-monitor_loop() void
|
||||
}
|
||||
|
||||
class LLMEngine {
|
||||
+LLMEngine(model_path str)
|
||||
+set_model_path(model_path str) void
|
||||
+infer(system_prompt str, main_context str) Iterator~str~
|
||||
}
|
||||
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class WorkingMemory {
|
||||
-entries: List~Entry~
|
||||
|
||||
+WorkingMemory()
|
||||
+add_entry(entry Entry) void
|
||||
+remove_entry(id str) void
|
||||
+clear() void
|
||||
+get_entry(id str) Optional~Entry~
|
||||
+get_entries() List~Entry~
|
||||
+get_entries_count() int
|
||||
+get_entries_by_type(type Type) List~Entry~
|
||||
+update() void
|
||||
+generate_context() List~ElementTree~
|
||||
}
|
||||
|
||||
class XMLValidator {
|
||||
+XMLValidator(schema str)
|
||||
+validate(xml str) Optional~str~
|
||||
+get_valid_root_elements() Set~str~
|
||||
}
|
||||
|
||||
class ResponseParser {
|
||||
-io_buffer: IOBuffer
|
||||
|
||||
+ResponseParser(io_buffer IOBuffer)
|
||||
+parse(xml str) Command | Entry
|
||||
}
|
||||
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
SystemMetrics "1" --* "1" BaseAgent
|
||||
LLMEngine "1" --* "1" BaseAgent
|
||||
XMLValidator "1" --* "1" BaseAgent
|
||||
BaseAgent "1" *-- "1" IOBuffer
|
||||
BaseAgent "1" *-- "1" WorkingMemory
|
||||
BaseAgent "1" *-- "1" ResponseParser
|
||||
WorkingMemory "1" *-- "*" Entry
|
||||
ResponseParser ..> Entry
|
||||
ResponseParser ..> Command
|
||||
```
|
||||
|
||||
#### Standard Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Standard Agent Flow" as standard_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> ProcessLLM
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> ParseResponse: Valid XML
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Web Agent
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class BaseAgent {
|
||||
<<abstract>>
|
||||
-working_memory: WorkingMemory
|
||||
-metrics: SystemMetrics
|
||||
-llm: LLMEngine
|
||||
-parser: ResponseParser
|
||||
-validator: XMLValidator
|
||||
-action_schema: str
|
||||
|
||||
#_compile_context() str
|
||||
}
|
||||
|
||||
class StandardAgent {
|
||||
+StandardAgent(model_path str, system_prompt str, action_schema str)
|
||||
+run() void
|
||||
}
|
||||
|
||||
class WebAgent {
|
||||
+context: str
|
||||
+response: str readonly
|
||||
+current_state WebAgentState readonly
|
||||
+command_result Optional[CommandResult] readonly
|
||||
+validation_error Optional[str] readonly
|
||||
|
||||
+add_state_change_handler(handler Callable) void
|
||||
+add_response_change_handler(handler Callable) void
|
||||
+approve_context() void
|
||||
+set__response(response str) void
|
||||
+approve_response() void
|
||||
}
|
||||
|
||||
class WebAgentState {
|
||||
|
||||
<<enumeration>>
|
||||
UPDATE
|
||||
CONTEXT_APPROVAL
|
||||
INFERENCE
|
||||
RESPONSE_APPROVAL
|
||||
STOPPED
|
||||
}
|
||||
|
||||
class WebSocketManager {
|
||||
-web_sockets: Set~WebSocket~
|
||||
|
||||
+WebServer(agent WebAgent, io_buffer WebIOBuffer, static_files path, host str, port int)
|
||||
}
|
||||
|
||||
class ClientMessage {
|
||||
<<enumeration>>
|
||||
APPROVE_CONTEXT
|
||||
APPROVE_RESPONSE
|
||||
MODIFY_RESPONSE
|
||||
SEND_INPUT
|
||||
}
|
||||
|
||||
class ServerMessage {
|
||||
<<enumeration>>
|
||||
STATE_CHANGE
|
||||
CONTEXT_UPDATE
|
||||
RESPONSE_UPDATE
|
||||
OUTPUT_UPDATE
|
||||
VALIDATION_ERROR
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
BaseAgent <|-- WebAgent
|
||||
BaseAgent <|-- StandardAgent
|
||||
|
||||
WebServer --> ClientMessage
|
||||
WebServer --> ServerMessage
|
||||
|
||||
WebServer "1" *-- "1" WebIOBuffer
|
||||
WebServer "1" *-- "1" WebAgent
|
||||
WebAgent "1" *-- "1" WebAgentState
|
||||
```
|
||||
|
||||
#### Web Agent Flow
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
direction LR
|
||||
state "Web Agent Flow" as web_agent_flow {
|
||||
[*] --> UpdateSystem: Start
|
||||
UpdateSystem --> CompileContext: Updated Metrics & Size
|
||||
CompileContext --> WaitForContextApproval: Send Context
|
||||
WaitForContextApproval --> ProcessLLM: Context Approved
|
||||
ProcessLLM --> ValidateXML: LLM Response
|
||||
ValidateXML --> WaitForResponseApproval: Send Validation Result
|
||||
ValidateXML --> UpdateEntries: Invalid XML\nCreate ParseErrorEntry
|
||||
|
||||
WaitForResponseApproval --> ValidateXML: Modified Response
|
||||
WaitForResponseApproval --> ParseResponse: Approved Response
|
||||
|
||||
ParseResponse --> ExecuteCommands: Command
|
||||
ParseResponse --> UpdateEntries: Entry
|
||||
|
||||
ExecuteCommands --> [*]: Stop Command
|
||||
ExecuteCommands --> UpdateEntries: Delete Command
|
||||
|
||||
UpdateEntries --> UpdateSystem: Continue Loop
|
||||
}
|
||||
```
|
||||
|
||||
#### Entry classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class Entry {
|
||||
<<abstract>>
|
||||
+id: str readonly
|
||||
+timestamp: datetime readonly
|
||||
|
||||
+Entry(id str, timestamp datetime)
|
||||
+update() void*
|
||||
+generate_context() ElementTree*
|
||||
+cleanup() void*
|
||||
}
|
||||
|
||||
class ScriptEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+Script(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class RepeatEntry {
|
||||
+script: str readonly
|
||||
+stdout: str readonly
|
||||
+stderr: str readonly
|
||||
+exit_code: Optional~int~ readonly
|
||||
|
||||
+RepeatEntry(script str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReasoningEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReasoningEntry(content str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ParseErrorEntry {
|
||||
+content: str readonly
|
||||
+error: str readonly
|
||||
|
||||
+ParseErrorEntry(content str, error str, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class ReadEntry {
|
||||
+content: str readonly
|
||||
|
||||
+ReadEntry(io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
class WriteEntry {
|
||||
+content: str readonly
|
||||
|
||||
+WriteEntry(content str, io_buffer IOBuffer, id str, timestamp datetime)
|
||||
+update() void
|
||||
+generate_context() ElementTree
|
||||
}
|
||||
|
||||
ReasoningEntry --|> Entry
|
||||
ParseErrorEntry --|> Entry
|
||||
ReadEntry --|> Entry
|
||||
Entry <|-- WriteEntry
|
||||
Entry <|-- ScriptEntry
|
||||
Entry <|-- RepeatEntry
|
||||
```
|
||||
|
||||
#### IO Buffer classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class IOBuffer {
|
||||
<<interface>>
|
||||
+read() str*
|
||||
+write(content str) void*
|
||||
+buffer_length() int*
|
||||
}
|
||||
|
||||
class StandardIOBuffer {
|
||||
+StandardIOBuffer()
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
}
|
||||
|
||||
class WebIOBuffer {
|
||||
-stdin_buffer: str
|
||||
-stdout_buffer: str
|
||||
|
||||
+read() str
|
||||
+write(content str) void
|
||||
+buffer_length() int
|
||||
+append_stdin(content str) void
|
||||
+get_stdout() str
|
||||
+clear_stdout() void
|
||||
}
|
||||
|
||||
IOBuffer <|.. WebIOBuffer
|
||||
IOBuffer <|.. StandardIOBuffer
|
||||
```
|
||||
|
||||
#### Command classes
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
direction LR
|
||||
class Command {
|
||||
<<abstract>>
|
||||
+execute(memory WorkingMemory) CommandResult*
|
||||
}
|
||||
|
||||
class DeleteCommand {
|
||||
+DeleteCommand(id str)
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class StopCommand {
|
||||
+StopCommand()
|
||||
+execute(memory WorkingMemory) CommandResult
|
||||
}
|
||||
|
||||
class CommandResult {
|
||||
+message: str
|
||||
+success: bool
|
||||
+should_stop: bool
|
||||
|
||||
+CommandResult(message str, success bool, should_stop bool)
|
||||
+static success() CommandResult
|
||||
+static failure(message str) CommandResult
|
||||
+static stop() CommandResult
|
||||
}
|
||||
|
||||
Command <|-- DeleteCommand
|
||||
Command <|-- StopCommand
|
||||
Command -- CommandResult
|
||||
```
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="869e20e9-48ef-4223-b901-09796f4e0627">
|
||||
<![CDATA[
|
||||
The diagrams give a good overview of which classes to expect.
|
||||
I will explore the `/root/sia/sia` directory to see which of these classes are already implemented.
|
||||
]]>
|
||||
</reasoning>
|
||||
<single
|
||||
exit_code="0"
|
||||
id="fa7effb0-a1ce-468f-b556-c971f24dca54"
|
||||
limit="10000">
|
||||
<![CDATA[ls -l /root/sia/sia]]>
|
||||
<stdout>
|
||||
<![CDATA[total 172
|
||||
-rwxr-xr-x 1 root root 0 Oct 22 11:48 __init__.py
|
||||
-rwxr-xr-x 1 root root 4977 Nov 19 14:20 __main__.py
|
||||
drwxr-xr-x 2 root root 4096 Nov 20 10:26 __pycache__
|
||||
-rwxr-xr-x 1 root root 5943 Nov 15 15:54 auto_approver.py
|
||||
-rwxr-xr-x 1 root root 5242 Nov 13 16:31 background_entry.py
|
||||
-rwxr-xr-x 1 root root 3072 Nov 19 13:45 base_agent.py
|
||||
-rwxr-xr-x 1 root root 722 Nov 4 09:50 command.py
|
||||
-rwxr-xr-x 1 root root 1113 Nov 4 09:50 command_result.py
|
||||
-rwxr-xr-x 1 root root 5865 Nov 19 13:41 config.py
|
||||
-rwxr-xr-x 1 root root 1337 Nov 4 09:50 delete_command.py
|
||||
-rwxr-xr-x 1 root root 1537 Nov 4 09:50 entry.py
|
||||
-rwxr-xr-x 1 root root 2620 Nov 14 15:16 hf_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1082 Nov 4 09:50 io_buffer.py
|
||||
-rwxr-xr-x 1 root root 1683 Nov 19 13:54 iteration_logger.py
|
||||
-rwxr-xr-x 1 root root 385 Nov 14 14:21 llm_engine.py
|
||||
-rwxr-xr-x 1 root root 4018 Nov 19 14:20 local_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2269 Nov 19 14:20 mistral_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 2407 Nov 19 14:20 openai_llm_engine.py
|
||||
-rwxr-xr-x 1 root root 1632 Nov 13 15:40 parse_error_entry.py
|
||||
-rwxr-xr-x 1 root root 1744 Nov 13 15:39 read_entry.py
|
||||
-rwxr-xr-x 1 root root 1323 Nov 13 15:38 reasoning_entry.py
|
||||
-rwxr-xr-x 1 root root 4127 Nov 19 14:20 repeat_entry.py
|
||||
-rwxr-xr-x 1 root root 5916 Nov 19 14:20 response_parser.py
|
||||
-rwxr-xr-x 1 root root 4173 Nov 19 14:20 single_entry.py
|
||||
-rwxr-xr-x 1 root root 2074 Nov 4 09:50 standard_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 908 Nov 4 09:50 stop_command.py
|
||||
-rwxr-xr-x 1 root root 4152 Nov 14 13:36 system_metrics.py
|
||||
-rwxr-xr-x 1 root root 2510 Nov 12 16:17 util.py
|
||||
-rwxr-xr-x 1 root root 7818 Nov 19 13:54 web_agent.py
|
||||
-rwxr-xr-x 1 root root 2039 Nov 12 16:17 web_io_buffer.py
|
||||
-rwxr-xr-x 1 root root 6968 Nov 15 12:48 web_socket_manager.py
|
||||
-rwxr-xr-x 1 root root 3638 Nov 13 16:35 working_memory.py
|
||||
-rwxr-xr-x 1 root root 1688 Nov 13 15:41 write_entry.py
|
||||
-rwxr-xr-x 1 root root 3992 Nov 4 09:50 xml_validator.py
|
||||
]]>
|
||||
</stdout>
|
||||
<stderr/>
|
||||
</single>
|
||||
<reasoning id="addd6ca0-9623-474e-88f1-6d9cfa6d5a85">
|
||||
<![CDATA[
|
||||
Looking at BaseAgent I can see it is a close match to the diagram with some small differences.
|
||||
I will create a notes directory where I will list differences between the schemas and the implementation.
|
||||
I will go over each file or class in the diagram in alphabetical order.
|
||||
]]>
|
||||
</reasoning>
|
||||
<repeat
|
||||
exit_code="0"
|
||||
id="29babba9-a49a-4ffb-b506-1ef929b834c2"
|
||||
limit="1024">
|
||||
<![CDATA[tail -v -n +1 /root/sia/notes/*]]>
|
||||
<stdout/>
|
||||
<stderr>
|
||||
==> /root/sia/notes/base_agent.txt <==
|
||||
BaseAgent:
|
||||
- The implementation has a public system_prompt property that is not mentioned in the diagram.
|
||||
</stderr>
|
||||
</repeat>
|
||||
</context></context><response><single limit="4977">cat /root/sia/sia/__main__.py</single></response></iteration>
|
||||
Reference in New Issue
Block a user