Skip to content

feat: Add /history and /delete slash commands for session management#3

Merged
1bcMax merged 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feature/history-commands
Apr 8, 2026
Merged

feat: Add /history and /delete slash commands for session management#3
1bcMax merged 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feature/history-commands

Conversation

@KillerQueen-Z
Copy link
Copy Markdown
Collaborator

Motivation:
Currently, there is no way for a user to inspect or manage the conversation history within an interactive session. This makes it difficult to:

  • Understand the full context being sent to the model.
  • Remove irrelevant or erroneous turns to guide the AI's future responses.
  • Prune the context to save on tokens for long-running sessions.
    This PR introduces two new slash commands, /history and /delete , to address these issues by providing direct control over the session's dialogue history.
    Implementation
    This change adds two new "direct" slash commands to src/agent/commands.ts :
  1. /history
  • Displays the complete dialogue history for the current session.
  • Each turn is numbered (e.g., [1] , [2] ) for easy reference in the /delete command.
  • Clearly labels the role of each turn as [user] or [modelName] .
  • Includes a hint informing the user how to use the /delete command.
  1. /delete
  • Removes one or more turns from the history array based on their number. The modified history is then used for all subsequent model calls.
  • Supports flexible formats for specifying turns to delete:
    • Single turn: /delete 3
    • Comma-separated list: /delete 2,5,8
    • Ranges: /delete 4-7
    • A combination of all: /delete 2,4-6,9
  • Technical Detail: To prevent index-shifting issues during removal, the command processes indices in descending order, ensuring correctness when deleting multiple turns.
  • Context-Awareness: After modifying the history, the command calls resetTokenAnchor() to ensure the agent's token-counting mechanism remains accurate.
    All logic is self-contained within src/agent/commands.ts and does not affect other parts of the application.

How to Test

  1. Start an interactive session ( runcode ).
  2. Have a multi-turn conversation with the model.
  3. Run /history .
    • Expected: The full, numbered conversation history is displayed.
  4. Run /delete to remove a specific turn (e.g., /delete 2 ).
    • Expected: A confirmation message is shown.
  5. Run /history again.
    • Expected: The specified turn is no longer present in the history.
  6. Ask a follow-up question that would have depended on the context of the deleted turn.
    • Expected: The model responds as if the deleted turn never happened, confirming the context was successfully modified.

@1bcMax 1bcMax merged commit 0bf088f into BlockRunAI:main Apr 8, 2026
@KillerQueen-Z KillerQueen-Z deleted the feature/history-commands branch April 8, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant