Added first procedures

This commit is contained in:
Niels Geens
2025-01-08 22:42:14 +01:00
parent e730eba58c
commit 4cd0fe8450
7 changed files with 333 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
Manage communication with users through standard input/output.
Handle both direct responses and conversation flows, with appropriate context management and response timing.
- user interaction
- conversation
- messages
- response handling

View File

@@ -0,0 +1,76 @@
# User Communication
## Prerequisites
- User information is stored in the /user directory
- Tasks and their progress are documented in the /tasks directory
## Flow
```mermaid
flowchart TD
Start([Start])
LoadUserBasic[The /user/basic.md file should contain info to identify and address the user properly
Also load the last 10 messages from /user/conversation_history/]
PrepareForDraft{Have everything needed for drafting a message?}
DraftMessage[Draft message in reasoning entry]
ReadInput[Read input from standard input]
ReasonCleanContext[List id's of entries that are no longer needed
Explain for each entry why it is no longer needed]
DeleteEntries[Remove the entries that are no longer needed
End by deleting the ReasonCleanContext entry]
AddHistoryUser[Add the message to the /user/conversation_history/ directory
The filename is the id of the stdin entry with .user extension]
LoadTask[Look for the task in the /tasks directory and load relevant files]
LoadUserDetails[Look in the /user directory for relevant files]
EstimateScript[Draft the script in a reasoning block and estimate its runtime and output length]
ScriptAcceptable{Does the draft script make sense and are the estimations short enough to not hinder the conversation?}
RunScript[Run the script, make sure to set appropriate timeout and output limits]
ReviewDraft{Is the message well structured and free of logical errors?}
SendMessage[Send the message using standard output]
AddHistoryAgent[Add the message to the /user/conversation_history/ directory
The filename is the id of the stdout entry with .agent extension]
ReasonResponse[Is the conversation ongoing?
How long is the user expected to take to respond?]
NeedAwaitResponse{Is it likely to get a response within a minute?}
BusyWait[Wait 1 second for the first busy wait, double the time each iteration until a response is received
Make sure to set the timout]
End([Clean the context])
Start --> LoadUserBasic
LoadUserBasic --> PrepareForDraft
PrepareForDraft -->|Got all needed info| DraftMessage
PrepareForDraft -->|Getting the required info would slow the conversation| DraftMessage
PrepareForDraft -->|Input available on stdin| ReadInput
PrepareForDraft -->|Context usage more than 50%| ReasonCleanContext
PrepareForDraft -->|Task mentioned but not loaded| LoadTask
PrepareForDraft -->|Personal or social info mentioned but not loaded| LoadUserDetails
PrepareForDraft -->|Calculations, system info or other numerical values that can be scripted are mentioned| EstimateScript
ReasonCleanContext --> DeleteEntries
DeleteEntries --> PrepareForDraft
ReadInput --> AddHistoryUser
AddHistoryUser --> PrepareForDraft
LoadTask --> PrepareForDraft
LoadUserDetails --> PrepareForDraft
EstimateScript --> ScriptAcceptable
ScriptAcceptable -->|Acceptable| RunScript
ScriptAcceptable -->|Not acceptable| PrepareForDraft
RunScript --> PrepareForDraft
DraftMessage --> ReviewDraft{Is this really what I want to say?}
ReviewDraft -->|Rewrite better| DraftMessage
ReviewDraft -->|Good message| SendMessage
SendMessage --> AddHistoryAgent
AddHistoryAgent --> ReasonResponse
ReasonResponse --> NeedAwaitResponse
NeedAwaitResponse -->|Quick response is unlikely| End
NeedAwaitResponse -->|Input available on stdin| PrepareForDraft
NeedAwaitResponse -->|Quick response is likely| BusyWait
BusyWait --> NeedAwaitResponse
```

View File

@@ -0,0 +1,29 @@
# Design Rationale
## Core Structure
The procedure is designed to maintain a clean conversation flow while ensuring all necessary information is available.
The flow focuses on:
1. **Context management**
- Load basic user info immediately to ensure proper interaction
- Recent conversation history provides continuity
- Clean context when usage exceeds 50%
- Gather only what's needed for the current conversation
- Skip gathering if it would slow down the interaction
2. **Message Management**
- Draft-review-revise cycle for quality
- Automatic history tracking for both user and agent messages
- Clear file naming convention using entry IDs
3. **Script Handling**
- Pre-execution estimation of runtime and output
- Explicit acceptability check before running
- Timeout and output limits for safety
4. **Response Timing**
- Adaptive busy wait with exponential backoff
- Clear decision point for wait vs end
- Proper context cleanup on exit
## Usage History